From a2e41aa61ac37f3af85ce813ee92a31e3d555a52 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 14 Dec 2020 19:47:10 +0100 Subject: [PATCH] Command ``SetOption117 1`` for light fading to be fixed duration instead of fixed slew rate (#10109) --- CHANGELOG.md | 1 + tasmota/settings.h | 2 +- tasmota/xdrv_04_light.ino | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a9ce16b6..324d013fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. - Support for SPI connected MFRC522 13.56MHz rfid card reader (#9916) - Letsencrypt R3 in addition to X3 CA (#10086) - Zigbee add visual map of network +- Command ``SetOption117 1`` for light fading to be fixed duration instead of fixed slew rate (#10109) ### Breaking Changed - KNX DPT9 (16-bit float) to DPT14 (32-bit float) by Adrian Scillato (#9811, #9888) diff --git a/tasmota/settings.h b/tasmota/settings.h index d55fcc76f..72d0477ce 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -142,7 +142,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t mqtt_switches : 1; // bit 0 (v9.0.0.3) - SetOption114 - (Switch) Detach Switches from relays and enable MQTT action state for all the SwitchModes (1) uint32_t mi32_enable : 1; // bit 1 (v9.1.0.1) - SetOption115 - (ESP32 BLE) Enable ESP32 MI32 BLE (1) uint32_t zb_disable_autoquery : 1; // bit 2 (v9.1.0.1) - SetOption116 - (Zigbee) Disable auto-query of zigbee lights and devices (1) - uint32_t spare03 : 1; // bit 3 + uint32_t fade_fixed_duration : 1; // bit 3 (v9.1.0.2) - SetOption117 - (Light) run fading at fixed duration instead of fixed slew rate uint32_t spare04 : 1; // bit 4 uint32_t spare05 : 1; // bit 5 uint32_t spare06 : 1; // bit 6 diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index c12fc8b95..9af684987 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -2137,7 +2137,10 @@ bool LightApplyFade(void) { // did the value chanegd and needs to be applied // compute the duration of the animation // Note: Settings.light_speed is the number of half-seconds for a 100% fade, // i.e. light_speed=1 means 1024 steps in 500ms - Light.fade_duration = (distance * Settings.light_speed * 500) / 1023; + Light.fade_duration = Settings.light_speed * 500; + if (!Settings.flag5.fade_fixed_duration) { + Light.fade_duration = (distance * Light.fade_duration) / 1023; // time is proportional to distance, except with SO117 + } if (Settings.save_data) { // Also postpone the save_data for the duration of the Fade (in seconds) uint32_t delay_seconds = 1 + (Light.fade_duration + 999) / 1000; // add one more second