From 9363718fd0712fd198f42be77dc576019ae1618f Mon Sep 17 00:00:00 2001 From: pimlie Date: Tue, 27 Aug 2024 12:47:02 +0200 Subject: [PATCH 1/3] fix: check correct ifdef macro fix: only increment day of week for sunday=0 --- src/activity.cpp | 2 +- src/time.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/activity.cpp b/src/activity.cpp index a07fd24..5e18fbb 100644 --- a/src/activity.cpp +++ b/src/activity.cpp @@ -81,7 +81,7 @@ void runActivities(void *params) Serial.printf("[ACTIVITY] starting activity: %d\n", activityNext); bool doQuickSleep = activityNext == GuestWifi || activityNext == Info; -#ifdef sleepSchedule +#ifdef UTIL_SLEEP_DURATION_H TimeInfo time = { .dow = getDayOfWeek(true), .hour = getHour(), diff --git a/src/time.cpp b/src/time.cpp index ff70890..76c85d4 100644 --- a/src/time.cpp +++ b/src/time.cpp @@ -130,7 +130,13 @@ int getDayOfWeek(bool weekStartsOnMonday) { // return -1 as long as rtc is not set return -1; } - return rtc.getDayofWeek() + (weekStartsOnMonday ? 1 : 0); + + int dow = rtc.getDayofWeek(); + if (dow == 0) { + return dow + 1; + } else { + return dow; + } } int getHour() { From 47b3f310d52bce41ed07ff354dee5d80ec746128 Mon Sep 17 00:00:00 2001 From: pimlie Date: Tue, 27 Aug 2024 12:58:01 +0200 Subject: [PATCH 2/3] fix: add new ifdef macro for config.cpp --- src/activity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activity.cpp b/src/activity.cpp index 5e18fbb..2a2838a 100644 --- a/src/activity.cpp +++ b/src/activity.cpp @@ -81,7 +81,7 @@ void runActivities(void *params) Serial.printf("[ACTIVITY] starting activity: %d\n", activityNext); bool doQuickSleep = activityNext == GuestWifi || activityNext == Info; -#ifdef UTIL_SLEEP_DURATION_H +#ifdef CONFIG_CPP TimeInfo time = { .dow = getDayOfWeek(true), .hour = getHour(), From c0493d0a2111ddc3d4713216f527a44b352765ad Mon Sep 17 00:00:00 2001 From: pimlie Date: Tue, 27 Aug 2024 13:05:19 +0200 Subject: [PATCH 3/3] chore: update config example --- src/config_example.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/config_example.cpp b/src/config_example.cpp index e69c8a1..d2e8834 100644 --- a/src/config_example.cpp +++ b/src/config_example.cpp @@ -1,7 +1,9 @@ -// NOTE: THIS FILE IS ONLY NEEDED WHEN CONFIGURING A CUSTOM SLEEP -// SCHEDULE. -// IF USING A SINGLE/STATIC SLEEP DURATION THEN THIS FILE CAN BE OMITTED -// #include "config.h" +// Note: +// This file is only needed when configuring a custom sleep schedule. +// If using a single/static sleep duration then this file can be omitted +/* REMOVE THIS LINE TO ENABLE THE SLEEP SCHEDULE +#include "config.h" +#define CONFIG_CPP // How long to sleep between image refreshes // - there is no validation of any kind, make sure your slots are continuous @@ -9,7 +11,7 @@ // - a schedule slot is configured per day, i.e. cronjob style // - dow = DayOfWeek, starts at 1 = Monday to 7 = Sunday // SleepScheduleSlot sleepSchedule[] = { - /* EXAMPLE BLOCKS + // EXAMPLE BLOCKS { // On each workday from 00:00 to 08:30 sleep for 1 hour .start_dow = 1, .start_hour = 0, @@ -55,7 +57,7 @@ .end_minute = 0, .sleep_in_seconds = 300, }, - */ -// }; +}; -//const size_t sleepScheduleSize = sizeof(sleepSchedule) / sizeof(sleepSchedule[0]); +const size_t sleepScheduleSize = sizeof(sleepSchedule) / sizeof(sleepSchedule[0]); +/**/