From 785d8a75b5bccb380a61eaec85516a8562d42ed7 Mon Sep 17 00:00:00 2001 From: Barbudor Date: Tue, 20 Apr 2021 08:18:25 +0200 Subject: [PATCH] move the fix to esp32 adaptation layer --- lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h | 1 + tasmota/xdrv_04_light.ino | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h index 25f6f539b..2555b0808 100644 --- a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h +++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h @@ -89,6 +89,7 @@ inline void analogAttach(uint32_t pin, uint32_t channel) { inline void analogWrite(uint8_t pin, int val) { uint32_t channel = _analog_pin2chan(pin); + if ( val >> (_pwm_bit_num-1) ) ++val; ledcWrite(channel + PWM_CHANNEL_OFFSET, val); // Serial.printf("write %d - %d\n",channel,val); } diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 702cc353e..f41ace288 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -1967,12 +1967,7 @@ 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 } if (!Settings.flag4.zerocross_dimmer) { - 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); + analogWrite(Pin(GPIO_PWM1, i), bitRead(TasmotaGlobal.pwm_inverted, i) ? Settings.pwm_range - cur_col : cur_col); } #ifdef USE_PWM_DIMMER // Animate brightness LEDs to follow PWM dimmer brightness