From 5932391c8b2178cc0beed9f4c2b0aa4a24ac7e1f Mon Sep 17 00:00:00 2001 From: SteveAmor Date: Sun, 7 Nov 2021 10:50:33 +0000 Subject: Chimes option --- src/components/datetime/DateTimeController.cpp | 16 ++++++++++++++++ src/components/datetime/DateTimeController.h | 2 ++ src/components/settings/Settings.h | 11 +++++++++++ 3 files changed, 29 insertions(+) (limited to 'src/components') diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index e9c5d870..2513e427 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -75,6 +75,22 @@ void DateTime::UpdateTime(uint32_t systickCounter) { minute = time.minutes().count(); second = time.seconds().count(); + if(minute == 0 and not isHourAlreadyNotified) { + isHourAlreadyNotified = true; + if(systemTask != nullptr) + systemTask->PushMessage(System::Messages::OnNewHour); + } else if (minute != 0) { + isHourAlreadyNotified = false; + } + + if((minute == 0 or minute == 30) and not isHalfHourAlreadyNotified) { + isHalfHourAlreadyNotified = true; + if(systemTask != nullptr) + systemTask->PushMessage(System::Messages::OnNewHalfHour); + } else if (minute != 0 and minute != 30) { + isHalfHourAlreadyNotified = false; + } + // Notify new day to SystemTask if (hour == 0 and not isMidnightAlreadyNotified) { isMidnightAlreadyNotified = true; diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h index 77ed68e8..cbc80447 100644 --- a/src/components/datetime/DateTimeController.h +++ b/src/components/datetime/DateTimeController.h @@ -86,6 +86,8 @@ namespace Pinetime { std::chrono::seconds uptime {0}; bool isMidnightAlreadyNotified = false; + bool isHourAlreadyNotified = true; + bool isHalfHourAlreadyNotified = true; System::SystemTask* systemTask = nullptr; }; } diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 871ff3b6..b7e4dcf6 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -41,6 +41,16 @@ namespace Pinetime { return settings.clockFace; }; + void SetChimesState(uint8_t state) { + if (state != settings.chimesState) { + settingsChanged = true; + } + settings.chimesState = state; + }; + uint8_t GetChimesState() const { + return settings.chimesState; + }; + void SetPTSColorTime(Colors colorTime) { if (colorTime != settings.PTS.ColorTime) settingsChanged = true; @@ -173,6 +183,7 @@ namespace Pinetime { Notification notificationStatus = Notification::ON; uint8_t clockFace = 0; + uint8_t chimesState = 0; PineTimeStyle PTS; -- cgit v1.2.3-70-g09d2 From 37de10f47dafc7207299e70843caba21c633081a Mon Sep 17 00:00:00 2001 From: SteveAmor Date: Sun, 7 Nov 2021 12:10:23 +0000 Subject: applied clang-format --- src/components/datetime/DateTimeController.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/components') diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index 2513e427..4e3076cd 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -75,17 +75,17 @@ void DateTime::UpdateTime(uint32_t systickCounter) { minute = time.minutes().count(); second = time.seconds().count(); - if(minute == 0 and not isHourAlreadyNotified) { + if (minute == 0 and not isHourAlreadyNotified) { isHourAlreadyNotified = true; - if(systemTask != nullptr) + if (systemTask != nullptr) systemTask->PushMessage(System::Messages::OnNewHour); } else if (minute != 0) { isHourAlreadyNotified = false; } - if((minute == 0 or minute == 30) and not isHalfHourAlreadyNotified) { + if ((minute == 0 or minute == 30) and not isHalfHourAlreadyNotified) { isHalfHourAlreadyNotified = true; - if(systemTask != nullptr) + if (systemTask != nullptr) systemTask->PushMessage(System::Messages::OnNewHalfHour); } else if (minute != 0 and minute != 30) { isHalfHourAlreadyNotified = false; @@ -116,4 +116,3 @@ const char* DateTime::MonthShortToStringLow(Months month) { void DateTime::Register(Pinetime::System::SystemTask* systemTask) { this->systemTask = systemTask; } - -- cgit v1.2.3-70-g09d2 From 822b6ae6a0305c20a02a3e6e79f6f58296d585d4 Mon Sep 17 00:00:00 2001 From: SteveAmor Date: Sun, 7 Nov 2021 13:12:01 +0000 Subject: format changes --- src/components/datetime/DateTimeController.cpp | 12 +++++++----- src/systemtask/SystemTask.cpp | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/components') diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index 4e3076cd..762cded4 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -75,19 +75,21 @@ void DateTime::UpdateTime(uint32_t systickCounter) { minute = time.minutes().count(); second = time.seconds().count(); - if (minute == 0 and not isHourAlreadyNotified) { + if (minute == 0 && !isHourAlreadyNotified) { isHourAlreadyNotified = true; - if (systemTask != nullptr) + if (systemTask != nullptr) { systemTask->PushMessage(System::Messages::OnNewHour); + } } else if (minute != 0) { isHourAlreadyNotified = false; } - if ((minute == 0 or minute == 30) and not isHalfHourAlreadyNotified) { + if ((minute == 0 || minute == 30) && !isHalfHourAlreadyNotified) { isHalfHourAlreadyNotified = true; - if (systemTask != nullptr) + if (systemTask != nullptr) { systemTask->PushMessage(System::Messages::OnNewHalfHour); - } else if (minute != 0 and minute != 30) { + } + } else if (minute != 0 && minute != 30) { isHalfHourAlreadyNotified = false; } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 1e546e16..c48307af 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -354,7 +354,7 @@ void SystemTask::Work() { break; case Messages::OnNewHour: using Pinetime::Controllers::AlarmController; - if (settingsController.GetChimesState() == 1 and alarmController.State() != AlarmController::AlarmState::Alerting) { + if (settingsController.GetChimesState() == 1 && alarmController.State() != AlarmController::AlarmState::Alerting) { if (isSleeping && !isWakingUp) { GoToRunning(); displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock); @@ -364,7 +364,7 @@ void SystemTask::Work() { break; case Messages::OnNewHalfHour: using Pinetime::Controllers::AlarmController; - if (settingsController.GetChimesState() == 2 and alarmController.State() != AlarmController::AlarmState::Alerting) { + if (settingsController.GetChimesState() == 2 && alarmController.State() != AlarmController::AlarmState::Alerting) { if (isSleeping && !isWakingUp) { GoToRunning(); displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock); -- cgit v1.2.3-70-g09d2 From c5282f94544c2f8a4247416e80a5c25966c0acdc Mon Sep 17 00:00:00 2001 From: SteveAmor Date: Sun, 7 Nov 2021 14:15:39 +0000 Subject: update settings version --- src/components/settings/Settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/components') diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index b7e4dcf6..09886011 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -173,7 +173,7 @@ namespace Pinetime { private: Pinetime::Controllers::FS& fs; - static constexpr uint32_t settingsVersion = 0x0002; + static constexpr uint32_t settingsVersion = 0x0003; struct SettingsData { uint32_t version = settingsVersion; uint32_t stepsGoal = 10000; -- cgit v1.2.3-70-g09d2 From 15c3807a761b00a6dcdcc3a516e67e584f0a55c9 Mon Sep 17 00:00:00 2001 From: SteveAmor Date: Tue, 4 Jan 2022 19:32:29 +0000 Subject: Adds enum class for chimes option --- src/components/settings/Settings.h | 13 +++++++------ src/displayapp/screens/settings/SettingChimes.cpp | 16 ++++++++++++---- src/systemtask/SystemTask.cpp | 4 ++-- 3 files changed, 21 insertions(+), 12 deletions(-) (limited to 'src/components') diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index f87b6938..006b8c74 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -11,6 +11,7 @@ namespace Pinetime { public: enum class ClockType : uint8_t { H24, H12 }; enum class Notification : uint8_t { ON, OFF }; + enum class ChimesOption : uint8_t { None, Hours, HalfHours }; enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, @@ -40,14 +41,14 @@ namespace Pinetime { return settings.clockFace; }; - void SetChimesState(uint8_t state) { - if (state != settings.chimesState) { + void SetChimeOption(ChimesOption chimeOption) { + if (chimeOption != settings.chimesOption) { settingsChanged = true; } - settings.chimesState = state; + settings.chimesOption = chimeOption; }; - uint8_t GetChimesState() const { - return settings.chimesState; + ChimesOption GetChimeOption() const { + return settings.chimesOption; }; void SetPTSColorTime(Colors colorTime) { @@ -182,7 +183,7 @@ namespace Pinetime { Notification notificationStatus = Notification::ON; uint8_t clockFace = 0; - uint8_t chimesState = 0; + ChimesOption chimesOption = ChimesOption::None; PineTimeStyle PTS; diff --git a/src/displayapp/screens/settings/SettingChimes.cpp b/src/displayapp/screens/settings/SettingChimes.cpp index 0f008802..3ee7537b 100644 --- a/src/displayapp/screens/settings/SettingChimes.cpp +++ b/src/displayapp/screens/settings/SettingChimes.cpp @@ -44,7 +44,7 @@ SettingChimes::SettingChimes(Pinetime::Applications::DisplayApp* app, Pinetime:: lv_checkbox_set_text_static(cbOption[optionsTotal], " Off"); cbOption[optionsTotal]->user_data = this; lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); - if (settingsController.GetChimesState() == 0) { + if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::None) { lv_checkbox_set_checked(cbOption[optionsTotal], true); } @@ -53,7 +53,7 @@ SettingChimes::SettingChimes(Pinetime::Applications::DisplayApp* app, Pinetime:: lv_checkbox_set_text_static(cbOption[optionsTotal], " Every hour"); cbOption[optionsTotal]->user_data = this; lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); - if (settingsController.GetChimesState() == 1) { + if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours) { lv_checkbox_set_checked(cbOption[optionsTotal], true); } @@ -62,7 +62,7 @@ SettingChimes::SettingChimes(Pinetime::Applications::DisplayApp* app, Pinetime:: lv_checkbox_set_text_static(cbOption[optionsTotal], " Every 30 mins"); cbOption[optionsTotal]->user_data = this; lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); - if (settingsController.GetChimesState() == 2) { + if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours) { lv_checkbox_set_checked(cbOption[optionsTotal], true); } @@ -79,7 +79,15 @@ void SettingChimes::UpdateSelected(lv_obj_t* object, lv_event_t event) { for (uint8_t i = 0; i < optionsTotal; i++) { if (object == cbOption[i]) { lv_checkbox_set_checked(cbOption[i], true); - settingsController.SetChimesState(i); + if (i == 0) { + settingsController.SetChimeOption(Controllers::Settings::ChimesOption::None); + } + if (i == 1) { + settingsController.SetChimeOption(Controllers::Settings::ChimesOption::Hours); + } + if (i == 2) { + settingsController.SetChimeOption(Controllers::Settings::ChimesOption::HalfHours); + } } else { lv_checkbox_set_checked(cbOption[i], false); } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index b2926936..7fc3ba8f 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -405,7 +405,7 @@ void SystemTask::Work() { break; case Messages::OnNewHour: using Pinetime::Controllers::AlarmController; - if (settingsController.GetChimesState() == 1 && alarmController.State() != AlarmController::AlarmState::Alerting) { + if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours && alarmController.State() != AlarmController::AlarmState::Alerting) { if (isSleeping && !isWakingUp) { GoToRunning(); displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock); @@ -415,7 +415,7 @@ void SystemTask::Work() { break; case Messages::OnNewHalfHour: using Pinetime::Controllers::AlarmController; - if (settingsController.GetChimesState() == 2 && alarmController.State() != AlarmController::AlarmState::Alerting) { + if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours && alarmController.State() != AlarmController::AlarmState::Alerting) { if (isSleeping && !isWakingUp) { GoToRunning(); displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock); -- cgit v1.2.3-70-g09d2