From fb179c27aff44b90e037469dc7b2521fb6dae2db Mon Sep 17 00:00:00 2001 From: George Date: Tue, 19 May 2020 21:43:11 +1000 Subject: [PATCH] Fixes * Setting commands don't update if no data is sent * Didn't understand how pin mapping worked duh. Fixed. --- tasmota/support_command.ino | 21 ++++++++++++--------- tasmota/support_tasmota.ino | 14 +++++++++++--- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index b48723575..b5ce6d074 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1893,24 +1893,27 @@ void CmndDriver(void) void CmndSetLedPwmOff(void) { - if (XdrvMailbox.payload < 0) { + if (XdrvMailbox.data_len > 0) { + if (XdrvMailbox.payload < 0) { Settings.ledpwm_off = 0; - } else if (XdrvMailbox.payload > Settings.pwm_range) { + } else if (XdrvMailbox.payload > Settings.pwm_range) { Settings.ledpwm_off = Settings.pwm_range; - } else { - Settings.ledpwm_off = XdrvMailbox.payload; - } + } else { + Settings.ledpwm_off = XdrvMailbox.payload; + } ResponseCmndNumber(Settings.ledpwm_off); } void CmndSetLedPwmOn(void) { - if (XdrvMailbox.payload < 0) { + if (XdrvMailbox.data_len > 0) { + if (XdrvMailbox.payload < 0) { Settings.ledpwm_on = 0; - } else if (XdrvMailbox.payload > Settings.pwm_range) { + } else if (XdrvMailbox.payload > Settings.pwm_range) { Settings.ledpwm_on = Settings.pwm_range; - } else { - Settings.ledpwm_on = XdrvMailbox.payload; + } else { + Settings.ledpwm_on = XdrvMailbox.payload; + } } ResponseCmndNumber(Settings.ledpwm_on); } diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 2508566ea..ba4b0fb1d 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -353,11 +353,19 @@ void SetLedPowerIdx(uint32_t led, uint32_t state) } uint16_t led_pwm_set = 0; if (bitRead(led_inverted, led)) { - led_pwm_set = state ? Settings.pwm_range - Settings.ledpwm_on : Settings.pwm_range - Settings.ledpwm_off; + if (state) { + led_pwm_set = Settings.pwm_range - Settings.ledpwm_on; + } else { + led_pwm_set = Settings.pwm_range - Settings.ledpwm_off; + } } else { - led_pwm_set = state ? Settings.ledpwm_on : Settings.ledpwm_off; + if (state) { + led_pwm_set = Settings.ledpwm_on; + } else { + led_pwm_set = Settings.ledpwm_off; + } } - analogWrite(led, led_pwm_set); + analogWrite(Pin(GPIO_LED1, led), led_pwm_set); } #ifdef USE_BUZZER if (led == 0) {