Add Option to Activate PWM CT mode without select module 48

Hello,

I would like to share with you my extension of the code.
I have some new lamps that have 2 PWM channels that are not classically wired. The first one is for brightness and the other channel is for color temperature.
Tasmota has already integrated the possibility to switch between CWWW and CTBRI. I only built the possibility to set it up manually.

greetings,
Jens

PS: This is my first commit. If I did something wrong, please report it.
This commit is contained in:
dermm 2020-04-22 19:43:57 +02:00
parent 717f3b9d47
commit 809a377154
4 changed files with 6 additions and 4 deletions

View File

@ -283,6 +283,7 @@
#define LIGHT_CHANNEL_MODE false // [SetOption68] Enable multi-channels PWM instead of Color PWM
#define LIGHT_SLIDER_POWER false // [SetOption77] Do not power off if slider moved to far left
#define LIGHT_ALEXA_CT_RANGE false // [SetOption82] Reduced CT range for Alexa
#define LIGHT_PWM_CT_MODE false // [SetOption92] Set PWM Mode from regular PWM to ColorTemp control (Xiaomi Philips ...) a.k.a. module 48 mode
// -- Energy --------------------------------------
#define ENERGY_VOLTAGE_ALWAYS false // [SetOption21] Enable show voltage even if powered off

View File

@ -111,7 +111,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t zigbee_distinct_topics : 1; // bit 7 (v8.1.0.10) - SetOption89 - Distinct MQTT topics per device for Zigbee (#7835)
uint32_t only_json_message : 1; // bit 8 (v8.2.0.3) - SetOption90 - Disable non-json MQTT response
uint32_t fade_at_startup : 1; // bit 9 (v8.2.0.3) - SetOption91 - Enable light fading at start/power on
uint32_t spare10 : 1;
uint32_t pwm_ct_mode : 1; // bit 10 () - SetOption92 - Set PWM Mode from regular PWM to ColorTemp control (Xiaomi Philips ...)
uint32_t spare11 : 1;
uint32_t spare12 : 1;
uint32_t spare13 : 1;

View File

@ -947,6 +947,7 @@ void SettingsDefaultSet2(void)
Settings.flag3.pwm_multi_channels = LIGHT_CHANNEL_MODE;
Settings.flag3.slider_dimmer_stay_on = LIGHT_SLIDER_POWER;
Settings.flag4.alexa_ct_range = LIGHT_ALEXA_CT_RANGE;
Settings.flag4.pwm_ct_mode = LIGHT_PWM_CT_MODE;
Settings.pwm_frequency = PWM_FREQ;
Settings.pwm_range = PWM_RANGE;

View File

@ -1986,7 +1986,7 @@ bool isChannelGammaCorrected(uint32_t channel) {
if (!Settings.light_correction) { return false; } // Gamma correction not activated
if (channel >= Light.subtype) { return false; } // Out of range
#ifdef ESP8266
if (PHILIPS == my_module_type) {
if ((PHILIPS == my_module_type) || (Settings.flag4.pwm_ct_mode)) {
if ((LST_COLDWARM == Light.subtype) && (1 == channel)) { return false; } // PMW reserved for CT
if ((LST_RGBCW == Light.subtype) && (4 == channel)) { return false; } // PMW reserved for CT
}
@ -1997,7 +1997,7 @@ bool isChannelGammaCorrected(uint32_t channel) {
// is the channel a regular PWM or ColorTemp control
bool isChannelCT(uint32_t channel) {
#ifdef ESP8266
if (PHILIPS == my_module_type) {
if ((PHILIPS == my_module_type) || (Settings.flag4.pwm_ct_mode)) {
if ((LST_COLDWARM == Light.subtype) && (1 == channel)) { return true; } // PMW reserved for CT
if ((LST_RGBCW == Light.subtype) && (4 == channel)) { return true; } // PMW reserved for CT
}
@ -2181,7 +2181,7 @@ void calcGammaBulbs(uint16_t cur_col_10[5]) {
uint16_t white_bri10_1023 = (white_bri10 > 1023) ? 1023 : white_bri10; // max 1023
#ifdef ESP8266
if (PHILIPS == my_module_type) { // channel 1 is the color tone, mapped to cold channel (0..255)
if ((PHILIPS == my_module_type) || (Settings.flag4.pwm_ct_mode)) { // channel 1 is the color tone, mapped to cold channel (0..255)
// Xiaomi Philips bulbs follow a different scheme:
cur_col_10[cw1] = light_state.getCT10bits();
// channel 0=intensity, channel1=temperature