Skip to content

Commit

Permalink
chimes: Add chime option for every quarter hour
Browse files Browse the repository at this point in the history
  • Loading branch information
zischknall committed Jan 15, 2025
1 parent 3e23ee7 commit 66e4b16
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/components/datetime/DateTimeController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ void DateTime::UpdateTime(uint32_t systickCounter, bool forceUpdate) {
isHalfHourAlreadyNotified = false;
}

if ((minute == 0 || minute == 15 || minute == 30 || minute == 45) && !isQuarterHourAlreadyNotified) {
isQuarterHourAlreadyNotified = true;
if (systemTask != nullptr) {
systemTask->PushMessage(System::Messages::OnNewQuarterHour);
}
} else if (minute != 0 && minute != 15 && minute != 30 && minute != 45) {
isQuarterHourAlreadyNotified = false;
}

// Notify new day to SystemTask
if (hour == 0 and not isMidnightAlreadyNotified) {
isMidnightAlreadyNotified = true;
Expand Down
1 change: 1 addition & 0 deletions src/components/datetime/DateTimeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ namespace Pinetime {
bool isMidnightAlreadyNotified = false;
bool isHourAlreadyNotified = true;
bool isHalfHourAlreadyNotified = true;
bool isQuarterHourAlreadyNotified = true;
System::SystemTask* systemTask = nullptr;
Controllers::Settings& settingsController;
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Pinetime {
enum class ClockType : uint8_t { H24, H12 };
enum class WeatherFormat : uint8_t { Metric, Imperial };
enum class Notification : uint8_t { On, Off, Sleep };
enum class ChimesOption : uint8_t { None, Hours, HalfHours };
enum class ChimesOption : uint8_t { None, Hours, HalfHours, QuarterHours };
enum class WakeUpMode : uint8_t { SingleTap = 0, DoubleTap = 1, RaiseWrist = 2, Shake = 3, LowerWrist = 4 };
enum class Colors : uint8_t {
White,
Expand Down
3 changes: 2 additions & 1 deletion src/displayapp/screens/settings/SettingChimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ namespace {
const char* name;
};

constexpr std::array<Option, 3> options = {{
constexpr std::array<Option, 4> options = {{
{Pinetime::Controllers::Settings::ChimesOption::None, "Off"},
{Pinetime::Controllers::Settings::ChimesOption::Hours, "Every hour"},
{Pinetime::Controllers::Settings::ChimesOption::HalfHours, "Every 30 mins"},
{Pinetime::Controllers::Settings::ChimesOption::QuarterHours, "Every 15 mins"},
}};

std::array<CheckboxList::Item, CheckboxList::MaxItems> CreateOptionArray() {
Expand Down
1 change: 1 addition & 0 deletions src/systemtask/Messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace Pinetime {
OnNewDay,
OnNewHour,
OnNewHalfHour,
OnNewQuarterHour,
OnChargingEvent,
OnPairing,
SetOffAlarm,
Expand Down
8 changes: 8 additions & 0 deletions src/systemtask/SystemTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ void SystemTask::Work() {
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
}
break;
case Messages::OnNewQuarterHour:
using Pinetime::Controllers::AlarmController;
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::QuarterHours && !alarmController.IsAlerting()) {
GoToRunning();
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
}
break;
case Messages::OnChargingEvent:
batteryController.ReadPowerState();
GoToRunning();
Expand Down

0 comments on commit 66e4b16

Please sign in to comment.