summaryrefslogtreecommitdiff
path: root/src/components/alarm
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/alarm')
-rw-r--r--src/components/alarm/AlarmController.cpp19
-rw-r--r--src/components/alarm/AlarmController.h6
2 files changed, 24 insertions, 1 deletions
diff --git a/src/components/alarm/AlarmController.cpp b/src/components/alarm/AlarmController.cpp
index 9f4e910..596bcaf 100644
--- a/src/components/alarm/AlarmController.cpp
+++ b/src/components/alarm/AlarmController.cpp
@@ -43,6 +43,25 @@ void AlarmController::SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin) {
minutes = alarmMin;
}
+void AlarmController::OnAdjustTime() {
+
+ if (state != AlarmState::Set) {
+ return;
+ }
+
+ xTimerStop(alarmAppTimer, 0);
+ auto now = dateTimeController.CurrentDateTime();
+
+ if (now > alarmTime) {
+ xTimerChangePeriod(alarmAppTimer, 1, 0);
+ } else {
+ auto mSecToAlarm = std::chrono::duration_cast<std::chrono::milliseconds>(alarmTime - now).count();
+ xTimerChangePeriod(alarmAppTimer, APP_TIMER_TICKS(mSecToAlarm), 0);
+ }
+
+ xTimerStart(alarmAppTimer, 0);
+}
+
void AlarmController::ScheduleAlarm() {
// Determine the next time the alarm needs to go off and set the timer
xTimerStop(alarmTimer, 0);
diff --git a/src/components/alarm/AlarmController.h b/src/components/alarm/AlarmController.h
index d630a12..c3a9fec 100644
--- a/src/components/alarm/AlarmController.h
+++ b/src/components/alarm/AlarmController.h
@@ -31,9 +31,9 @@ namespace Pinetime {
public:
AlarmController(Controllers::DateTime& dateTimeController);
- void Init(System::SystemTask* systemTask);
void SetAlarmTime(uint8_t alarmHr, uint8_t alarmMin);
void ScheduleAlarm();
+ void OnAdjustTime();
void DisableAlarm();
void SetOffAlarmNow();
uint32_t SecondsToAlarm();
@@ -56,6 +56,10 @@ namespace Pinetime {
recurrence = recurType;
}
+ protected:
+ friend class Pinetime::System::SystemTask;
+ void Init(System::SystemTask* systemTask);
+
private:
Controllers::DateTime& dateTimeController;
System::SystemTask* systemTask = nullptr;