From a47f6baf2fc36ba903392a27263587c2d125caa4 Mon Sep 17 00:00:00 2001 From: cybermaus Date: Tue, 25 Oct 2022 22:39:30 +0200 Subject: [PATCH] Deduplicate xdrv_09_timers.ino also Turns out even TimerGetTimeOfDay was duplicate code from ApplyTimerOffsets Did add a fix for the permanent day/night situation --- tasmota/tasmota_xdrv_driver/xdrv_09_timers.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_09_timers.ino b/tasmota/tasmota_xdrv_driver/xdrv_09_timers.ino index 438ade4d5..8c1fd530e 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_09_timers.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_09_timers.ino @@ -253,10 +253,10 @@ uint16_t TimerGetTimeOfDay(uint8_t index) int16_t xtime = xtimer.time; #ifdef USE_SUNRISE if (xtimer.mode) { - if (xtime >= 12*60) xtime = 12*60 - xtime; - xtime += (int16_t)SunMinutes(xtimer.mode-1); - if (xtime < 0) xtime += 24*60; - if (xtime >= 24*60) xtime -= 24*60; + ApplyTimerOffsets(&xtimer); + xtime = xtimer.time; + if (xtime==2047 && xtimer.mode==1) xtime *= -1; // Sun always has already rises + if (xtime==2046 && xtimer.mode==2) xtime *= -1; // Sun always has already set } #endif return xtime;