mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2025-10-29 11:33:20 +00:00
fix handling of "sunset" events (#1834)
* fix handling of "sunset" events:
Old code was
if (e->sunflags & (SUNRISE_FLAG || SUNSET_FLAG)) {
This will ignore sunset events ( SUNSET_FLAG = 1 << 1)
for the or of two values ( 1 || 2) is always true
and will result in testing (sunflags & 1)
so never true for sunset (2 & 1) is false.
probaly meant
if ((e->sunflags & SUNRISE_FLAG) || (e->sunflags & SUNSET_FLAG))
but it's sufficient to check is "sunsetflags" is not 0, so simple fix:
if (e->sunflags){
Additionally added code to change liste vents ("listClockEvents") so it also shows if a time is derived from sunset or sunrise:
before the output would be like:
Info:CMD:Ev 32 - 7:31:0, days 0xff, cmd setChannel 0 0
Info:CMD:Ev 31 - 19:7:0, days 0xff, cmd setChannel 0 1
and you won't see this is an "dynamic" time. Now it's (I also used %02i to fix time format)
Info:CMD:Ev 32 - 07:31:00 (sunrise), days 0xff, cmd setChannel 0 0
Info:CMD:Ev 31 - 19:07:00 (sunset), days 0xff, cmd setChannel 0 1
* forgot to commit fix for time display using "%02i" for hours, minutes and seconds
This commit is contained in:
parent
f5a3b2642b
commit
1a291a82ad
@ -186,7 +186,7 @@ void NTP_RunEventsForSecond(time_t runTime) {
|
||||
// weekday check
|
||||
if (BIT_CHECK(e->weekDayFlags, ltm->tm_wday)) {
|
||||
#if ENABLE_NTP_SUNRISE_SUNSET
|
||||
if (e->sunflags & (SUNRISE_FLAG || SUNSET_FLAG)) {
|
||||
if (e->sunflags) {
|
||||
if (e->lastDay != ltm->tm_wday) {
|
||||
e->lastDay = ltm->tm_wday; /* stop any further sun events today */
|
||||
dusk2Dawn(&sun_data, e->sunflags, &e->hour, &e->minute,
|
||||
@ -437,8 +437,19 @@ int NTP_PrintEventList() {
|
||||
|
||||
while (e) {
|
||||
// Print the command
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_CMD, "Ev %i - %i:%i:%i, days 0x%02x, cmd %s\n", (int)e->id, (int)e->hour, (int)e->minute, (int)e->second, (int)e->weekDayFlags, e->command);
|
||||
|
||||
#if ENABLE_CLOCK_SUNRISE_SUNSET
|
||||
char sun[25] = {0};
|
||||
if (e->sunflags) {
|
||||
if (e->sunflags & SUNRISE_FLAG){
|
||||
sprintf(sun," (sunrise)");
|
||||
} else{
|
||||
sprintf(sun," (sunset)");
|
||||
}
|
||||
}
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_CMD, "Ev %i - %02i:%02i:%02i%s, days 0x%02x, cmd %s\n", (int)e->id, (int)e->hour, (int)e->minute, (int)e->second, sun, (int)e->weekDayFlags, e->command);
|
||||
#else
|
||||
addLogAdv(LOG_INFO, LOG_FEATURE_CMD, "Ev %i - %02i:%02i:%02i, days 0x%02x, cmd %s\n", (int)e->id, (int)e->hour, (int)e->minute, (int)e->second, (int)e->weekDayFlags, e->command);
|
||||
#endif
|
||||
t++;
|
||||
e = e->next;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user