demo of PWM 100% problem on ESP32

This commit is contained in:
Barbudor 2021-04-18 23:02:08 +02:00
parent 862c1caeda
commit 9fa9f1ab01
1 changed files with 7 additions and 2 deletions

View File

@ -122,7 +122,7 @@
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_04 4 #define XDRV_04 4
// #define DEBUG_LIGHT #define DEBUG_LIGHT
enum LightSchemes { LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MAX }; enum LightSchemes { LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MAX };
@ -1967,7 +1967,12 @@ void LightSetOutputs(const uint16_t *cur_col_10) {
cur_col = cur_col > 0 ? changeUIntScale(cur_col, 0, Settings.pwm_range, Light.pwm_min, Light.pwm_max) : 0; // shrink to the range of pwm_min..pwm_max cur_col = cur_col > 0 ? changeUIntScale(cur_col, 0, Settings.pwm_range, Light.pwm_min, Light.pwm_max) : 0; // shrink to the range of pwm_min..pwm_max
} }
if (!Settings.flag4.zerocross_dimmer) { if (!Settings.flag4.zerocross_dimmer) {
analogWrite(Pin(GPIO_PWM1, i), bitRead(TasmotaGlobal.pwm_inverted, i) ? Settings.pwm_range - cur_col : cur_col); uint16_t pwm = bitRead(TasmotaGlobal.pwm_inverted, i) ? Settings.pwm_range - cur_col : cur_col;
#ifdef ESP32
if (pwm = Settings.pwm_range) pwm = Settings.pwm_range+1; // ESP32 full PWM is 1024 (1023 on ESP8266)
#endif
//AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("LIT: PWM%d = %d"), i, pwm);
analogWrite(Pin(GPIO_PWM1, i), pwm);
} }
#ifdef USE_PWM_DIMMER #ifdef USE_PWM_DIMMER
// Animate brightness LEDs to follow PWM dimmer brightness // Animate brightness LEDs to follow PWM dimmer brightness