Fix sunrise and sunset calculation (#2461)

5.12.0l
 * Fix sunrise and sunset calculation (#2461)
This commit is contained in:
Theo Arends 2018-04-17 17:05:24 +02:00
parent 5858ecdb79
commit 107379276b
3 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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;