From 8320ed5a92d966a86d2f65adb101a539748cca56 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 7 Mar 2021 18:34:06 +0100 Subject: [PATCH] Bugfixes. --- wled00/bus_manager.h | 4 ---- wled00/ntp.cpp | 41 ++++++++++++++++++++++++++--------------- wled00/wled.h | 2 +- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 73d483e21..d036d6159 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -287,10 +287,6 @@ class BusPwm : public Bus { uint8_t getPins(uint8_t* pinArray) { uint8_t numPins = NUM_PWM_PINS(_type); for (uint8_t i = 0; i < numPins; i++) { - #ifdef WLED_DEBUG - Serial.print(F("Getting pin=")); - Serial.println(_pins[i]); - #endif pinArray[i] = _pins[i]; } return numPins; diff --git a/wled00/ntp.cpp b/wled00/ntp.cpp index c46098bb4..c615d59c7 100644 --- a/wled00/ntp.cpp +++ b/wled00/ntp.cpp @@ -296,34 +296,45 @@ void checkTimers() } if (sunrise && sunset) daytime = difftime(localTime, sunrise) > 0 && difftime(localTime, sunset) < 0; + DEBUG_PRINTF("Local time: %02d:%02d\n", hour(localTime), minute(localTime)); for (uint8_t i = 0; i < 8; i++) { if (timerMacro[i] != 0 && (timerHours[i] == hour(localTime) || timerHours[i] == 24) //if hour is set to 24, activate every hour && timerMinutes[i] == minute(localTime) && (timerWeekday[i] & 0x01) //timer is enabled - && timerWeekday[i] >> weekdayMondayFirst() & 0x01) //timer should activate at current day of week + && ((timerWeekday[i] >> weekdayMondayFirst()) & 0x01)) //timer should activate at current day of week { applyPreset(timerMacro[i]); } } // sunrise macro - if (sunrise && timerMacro[8] != 0 - && (hour(sunrise) == hour(localTime)) - && (minute(sunrise) + timerMinutes[8]) == minute(localTime) - && (timerWeekday[8] & 0x01) //timer is enabled - && timerWeekday[8] >> weekdayMondayFirst() & 0x01) //timer should activate at current day of week - { - applyPreset(timerMacro[8]); + if (sunrise) { + time_t tmp = sunrise + timerMinutes[8]*60; // NOTE: may not be ok + DEBUG_PRINTF("Trigger time: %02d:%02d\n", hour(tmp), minute(tmp)); + if (timerMacro[8] != 0 + && hour(tmp) == hour(localTime) + && minute(tmp) == minute(localTime) + && (timerWeekday[8] & 0x01) //timer is enabled + && ((timerWeekday[8] >> weekdayMondayFirst()) & 0x01)) //timer should activate at current day of week + { + applyPreset(timerMacro[8]); + DEBUG_PRINTF("Sunrise macro %d triggered.",timerMacro[8]); + } } // sunset macro - if (sunset && timerMacro[9] != 0 - && (hour(sunrise) == hour(localTime)) - && (minute(sunrise) + timerMinutes[9]) == minute(localTime) - && (timerWeekday[9] & 0x01) //timer is enabled - && timerWeekday[9] >> weekdayMondayFirst() & 0x01) //timer should activate at current day of week - { - applyPreset(timerMacro[9]); + if (sunset) { + time_t tmp = sunset + timerMinutes[9]*60; // NOTE: may not be ok + DEBUG_PRINTF("Trigger time: %02d:%02d\n", hour(tmp), minute(tmp)); + if (timerMacro[9] != 0 + && hour(tmp) == hour(localTime) + && minute(tmp) == minute(localTime) + && (timerWeekday[9] & 0x01) //timer is enabled + && ((timerWeekday[9] >> weekdayMondayFirst()) & 0x01)) //timer should activate at current day of week + { + applyPreset(timerMacro[9]); + DEBUG_PRINTF("Sunset macro %d triggered.",timerMacro[9]); + } } } } diff --git a/wled00/wled.h b/wled00/wled.h index 289c23d93..4ca18783b 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -8,7 +8,7 @@ */ // version code in format yymmddb (b = daily build) -#define VERSION 2103072 +#define VERSION 2103073 //uncomment this if you have a "my_config.h" file you'd like to use //#define WLED_USE_MY_CONFIG