Skip to content

Commit

Permalink
chimes: Different vibration patterns for each time of hour
Browse files Browse the repository at this point in the history
  • Loading branch information
zischknall committed Jan 15, 2025
1 parent 66e4b16 commit 5621869
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 18 deletions.
23 changes: 16 additions & 7 deletions src/components/datetime/DateTimeController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,31 @@ void DateTime::UpdateTime(uint32_t systickCounter, bool forceUpdate) {
isHourAlreadyNotified = false;
}

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

if (minute == 30 && !isHalfHourAlreadyNotified) {
isHalfHourAlreadyNotified = true;
if (systemTask != nullptr) {
systemTask->PushMessage(System::Messages::OnNewHalfHour);
}
} else if (minute != 0 && minute != 30) {
} else if (minute != 30) {
isHalfHourAlreadyNotified = false;
}

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

// Notify new day to SystemTask
Expand Down
3 changes: 2 additions & 1 deletion src/components/datetime/DateTimeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ namespace Pinetime {

bool isMidnightAlreadyNotified = false;
bool isHourAlreadyNotified = true;
bool isHalfHourAlreadyNotified = true;
bool isQuarterHourAlreadyNotified = true;
bool isHalfHourAlreadyNotified = true;
bool isThreeQuarterHourAlreadyNotified = true;
System::SystemTask* systemTask = nullptr;
Controllers::Settings& settingsController;
};
Expand Down
28 changes: 26 additions & 2 deletions src/displayapp/DisplayApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,33 @@ void DisplayApp::Refresh() {
case Messages::BleRadioEnableToggle:
PushMessageToSystemTask(System::Messages::BleRadioEnableToggle);
break;
case Messages::Chime:
case Messages::FullHourChime:
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
motorController.RunForDuration(35);
motorController.RunForDuration(100);
vTaskDelay(pdMS_TO_TICKS(500));
motorController.RunForDuration(100);
vTaskDelay(pdMS_TO_TICKS(500));
motorController.RunForDuration(100);
vTaskDelay(pdMS_TO_TICKS(500));
motorController.RunForDuration(100);
break;
case Messages::QuarterHourChime:
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
motorController.RunForDuration(100);
break;
case Messages::HalfHourChime:
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
motorController.RunForDuration(100);
vTaskDelay(pdMS_TO_TICKS(500));
motorController.RunForDuration(100);
break;
case Messages::ThreeQuarterHourChime:
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
motorController.RunForDuration(100);
vTaskDelay(pdMS_TO_TICKS(500));
motorController.RunForDuration(100);
vTaskDelay(pdMS_TO_TICKS(500));
motorController.RunForDuration(100);
break;
case Messages::OnChargingEvent:
motorController.RunForDuration(15);
Expand Down
5 changes: 4 additions & 1 deletion src/displayapp/Messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ namespace Pinetime {
NotifyDeviceActivity,
ShowPairingKey,
AlarmTriggered,
Chime,
FullHourChime,
QuarterHourChime,
HalfHourChime,
ThreeQuarterHourChime,
BleRadioEnableToggle,
OnChargingEvent,
};
Expand Down
3 changes: 2 additions & 1 deletion src/systemtask/Messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ namespace Pinetime {
DisableSleeping,
OnNewDay,
OnNewHour,
OnNewHalfHour,
OnNewQuarterHour,
OnNewHalfHour,
OnNewThreeQuarterHour,
OnChargingEvent,
OnPairing,
SetOffAlarm,
Expand Down
22 changes: 16 additions & 6 deletions src/systemtask/SystemTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,25 +323,35 @@ void SystemTask::Work() {
case Messages::OnNewHour:
using Pinetime::Controllers::AlarmController;
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours && !alarmController.IsAlerting()) {
settingsController.GetChimeOption() != Controllers::Settings::ChimesOption::None && !alarmController.IsAlerting()) {
GoToRunning();
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
displayApp.PushMessage(Pinetime::Applications::Display::Messages::FullHourChime);
}
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::QuarterHourChime);
}
break;
case Messages::OnNewHalfHour:
using Pinetime::Controllers::AlarmController;
if (settingsController.GetNotificationStatus() != Controllers::Settings::Notification::Sleep &&
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours && !alarmController.IsAlerting()) {
(settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours ||
settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::QuarterHours) &&
!alarmController.IsAlerting()) {
GoToRunning();
displayApp.PushMessage(Pinetime::Applications::Display::Messages::Chime);
displayApp.PushMessage(Pinetime::Applications::Display::Messages::HalfHourChime);
}
break;
case Messages::OnNewQuarterHour:
case Messages::OnNewThreeQuarterHour:
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);
displayApp.PushMessage(Pinetime::Applications::Display::Messages::ThreeQuarterHourChime);
}
break;
case Messages::OnChargingEvent:
Expand Down

0 comments on commit 5621869

Please sign in to comment.