Skip to content

Commit

Permalink
Fix sunrise and sunset calculation (#2461)
Browse files Browse the repository at this point in the history
5.12.0l
 * Fix sunrise and sunset calculation (#2461)
  • Loading branch information
arendst committed Apr 17, 2018
1 parent 5858ecd commit 1073792
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions sonoff/_releasenotes.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sonoff/support.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions sonoff/xdrv_09_timers.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1073792

Please sign in to comment.