diff options
author | JF <JF002@users.noreply.github.com> | 2022-01-04 21:44:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 21:44:36 +0100 |
commit | b8b54f47a2a09e32186bf7d8dddc658fae2c6e5f (patch) | |
tree | 2b0d3f4873b54c388aa27d897e710665c857d321 /src/components | |
parent | e0013e730448f4dc142e3610f970f22c807ac41e (diff) | |
parent | 15c3807a761b00a6dcdcc3a516e67e584f0a55c9 (diff) |
Merge pull request #813 from SteveAmor/chimes
Chimes option
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/datetime/DateTimeController.cpp | 19 | ||||
-rw-r--r-- | src/components/datetime/DateTimeController.h | 2 | ||||
-rw-r--r-- | src/components/settings/Settings.h | 14 |
3 files changed, 33 insertions, 2 deletions
diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index 4ac9e1f1..673903cb 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -75,6 +75,24 @@ void DateTime::UpdateTime(uint32_t systickCounter) { minute = time.minutes().count(); second = time.seconds().count(); + if (minute == 0 && !isHourAlreadyNotified) { + isHourAlreadyNotified = true; + if (systemTask != nullptr) { + systemTask->PushMessage(System::Messages::OnNewHour); + } + } else if (minute != 0) { + isHourAlreadyNotified = false; + } + + if ((minute == 0 || minute == 30) && !isHalfHourAlreadyNotified) { + isHalfHourAlreadyNotified = true; + if (systemTask != nullptr) { + systemTask->PushMessage(System::Messages::OnNewHalfHour); + } + } else if (minute != 0 && minute != 30) { + isHalfHourAlreadyNotified = false; + } + // Notify new day to SystemTask if (hour == 0 and not isMidnightAlreadyNotified) { isMidnightAlreadyNotified = true; @@ -100,4 +118,3 @@ const char* DateTime::MonthShortToStringLow(Months month) { void DateTime::Register(Pinetime::System::SystemTask* systemTask) { this->systemTask = systemTask; } - 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 2d7973d8..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,6 +41,16 @@ namespace Pinetime { return settings.clockFace; }; + void SetChimeOption(ChimesOption chimeOption) { + if (chimeOption != settings.chimesOption) { + settingsChanged = true; + } + settings.chimesOption = chimeOption; + }; + ChimesOption GetChimeOption() const { + return settings.chimesOption; + }; + void SetPTSColorTime(Colors colorTime) { if (colorTime != settings.PTS.ColorTime) settingsChanged = true; @@ -162,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; @@ -172,6 +183,7 @@ namespace Pinetime { Notification notificationStatus = Notification::ON; uint8_t clockFace = 0; + ChimesOption chimesOption = ChimesOption::None; PineTimeStyle PTS; |