From 96a0f5b1ff8f345b2b27a6a5511814d6d6aa661f Mon Sep 17 00:00:00 2001 From: Hadinger Date: Thu, 28 Nov 2019 21:07:59 +0100 Subject: [PATCH] Fix postpone saving settings to flash until Fade is complete, avoids pause in Fade --- tasmota/CHANGELOG.md | 1 + tasmota/xdrv_04_light.ino | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 2d0acc894..8934d00ee 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -6,6 +6,7 @@ - Change new Fade system much smoother, Speed now up to 40 (#6942, #3714) - Fix Arduino IDE function prototyping compile error (#6982) - Change update lib IRremoteESP8266 updated to v2.7.1, -2.7k flash and -1.5k RAM for Tasmota-IR +- Fix postpone saving settings to flash until Fade is complete, avoids pause in Fade ### 7.0.0.5 20191118 diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 3e06446ec..67fd0788a 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -1795,6 +1795,12 @@ void LightApplyFade(void) { // Note: Settings.light_speed is the number of half-seconds for a 100% fade, // i.e. light_speed=1 means 1024 steps in 10 ticks (500ms) Light.fade_duration = (distance * Settings.light_speed * 10) / 1024; + // Also postpone the save_data for the duration of the Fade (in seconds) + uint32_t delay_seconds = 1 + (Light.fade_duration + 19) / 20; // add one more second + // AddLog_P2(LOG_LEVEL_INFO, PSTR("delay_seconds %d, save_data_counter %d"), delay_seconds, save_data_counter); + if (save_data_counter < delay_seconds) { + save_data_counter = delay_seconds; // pospone + } } else { // no fade needed, we keep the duration at zero, it will fallback directly to end of fade }