From 84352706e97635605d7e090cd2578f1a01abfa25 Mon Sep 17 00:00:00 2001 From: David Friedland Date: Mon, 8 Mar 2021 22:35:38 -0800 Subject: [PATCH] support Dimmer < > and / for level move and stop --- tasmota/xdrv_04_light.ino | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 70390e67a..f6b58e491 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -1844,6 +1844,16 @@ uint16_t fadeGammaReverse(uint32_t channel, uint16_t vg) { } } +uint8_t LightGetCurFadeBri(void) { + uint8_t max_bri = 0; + uint8_t bri_i = 0; + for (uint8_t i = 0; i < LST_MAX; i++) { + bri_i = changeUIntScale(fadeGammaReverse(i, Light.fade_cur_10[i]), 4, 1023, 1, 100); + if (bri_i > max_bri) max_bri = bri_i ; + } + return max_bri; +} + bool LightApplyFade(void) { // did the value chanegd and needs to be applied static uint32_t last_millis = 0; uint32_t now = millis(); @@ -2711,12 +2721,18 @@ void CmndDimmer(void) } else { dimmer = light_state.getDimmer(XdrvMailbox.index); } - // Handle +/- special command + // Handle +/-/!/ special commands if (1 == XdrvMailbox.data_len) { if ('+' == XdrvMailbox.data[0]) { XdrvMailbox.payload = (dimmer > (100 - Settings.dimmer_step - 1)) ? 100 : dimmer + Settings.dimmer_step; } else if ('-' == XdrvMailbox.data[0]) { XdrvMailbox.payload = (dimmer < (Settings.dimmer_step + 1)) ? 1 : dimmer - Settings.dimmer_step; + } else if ('!' == XdrvMailbox.data[0] && Light.fade_running) { + XdrvMailbox.payload = LightGetCurFadeBri(); + } else if ('<' == XdrvMailbox.data[0] ) { + XdrvMailbox.payload = 1; + } else if ('>' == XdrvMailbox.data[0] ) { + XdrvMailbox.payload = 100; } } // If value is ok, change it, otherwise report old value