From 107379276be99fae7a72d9e2a347b345997d042a Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Tue, 17 Apr 2018 17:05:24 +0200 Subject: [PATCH] Fix sunrise and sunset calculation (#2461) 5.12.0l * Fix sunrise and sunset calculation (#2461) --- sonoff/_releasenotes.ino | 1 + sonoff/support.ino | 2 +- sonoff/xdrv_09_timers.ino | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index bc760ec2f..229aae0b4 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -3,6 +3,7 @@ * Prepare for feature release - call on translators to update their language files * Add timer sunrise and sunset offset (#2378) * Fix negative Latitude and Longitude value entry (#2461) + * Fix sunrise and sunset calculation (#2461) * * 5.12.0k * Prepare for simple rules of up to 255 characters by enlarging Settings area to now 2048 bytes diff --git a/sonoff/support.ino b/sonoff/support.ino index 3d46ea004..4d1e51516 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -1409,7 +1409,7 @@ void RtcSecond() } } local_time += time_offset; - time_timezone = time_offset / (SECS_PER_HOUR / 10); + time_timezone = time_offset / 360; // (SECS_PER_HOUR / 10) fails as it is defined as UL } BreakTime(local_time, RtcTime); if (!RtcTime.hour && !RtcTime.minute && !RtcTime.second && RtcTime.valid) { diff --git a/sonoff/xdrv_09_timers.ino b/sonoff/xdrv_09_timers.ino index 4f7b5d2af..dfdcd647d 100644 --- a/sonoff/xdrv_09_timers.ino +++ b/sonoff/xdrv_09_timers.ino @@ -123,9 +123,12 @@ void DuskTillDawn(uint8_t *hour_up,uint8_t *minute_up, uint8_t *hour_down, uint8 h (D) = -18.0 astronomische Dämmerung */ double h = -50/60.0*RAD; - double B = ((double)Settings.latitude/1000000) * RAD; // geographische Breite - double GeographischeLaenge = (double)Settings.longitude/1000000; - double Zeitzone = (double)time_timezone / 10; + double B = (((double)Settings.latitude)/1000000) * RAD; // geographische Breite + double GeographischeLaenge = ((double)Settings.longitude)/1000000; +// double Zeitzone = 0; //Weltzeit +// double Zeitzone = 1; //Winterzeit +// double Zeitzone = 2.0; //Sommerzeit + double Zeitzone = ((double)time_timezone) / 10; double Zeitgleichung = BerechneZeitgleichung(&DK, T); double Minuten = Zeitgleichung * 60.0; double Zeitdifferenz = 12.0*acos((sin(h) - sin(B)*sin(DK)) / (cos(B)*cos(DK)))/pi;