From 1fb5757655c1cdf0e93f03ad27869e8c043d69f0 Mon Sep 17 00:00:00 2001 From: Mark Russell Date: Fri, 10 Sep 2021 18:40:13 -0400 Subject: Created basic alarm app --- src/components/alarm/AlarmController.h | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/components/alarm/AlarmController.h (limited to 'src/components/alarm/AlarmController.h') diff --git a/src/components/alarm/AlarmController.h b/src/components/alarm/AlarmController.h new file mode 100644 index 00000000..22259da8 --- /dev/null +++ b/src/components/alarm/AlarmController.h @@ -0,0 +1,50 @@ +#pragma once + +#include +#include "app_timer.h" +#include "components/datetime/DateTimeController.h" + +namespace Pinetime { + namespace System { + class SystemTask; + } + namespace Controllers { + class AlarmController { + public: + AlarmController(Controllers::DateTime& dateTimeController); + + void Init(); + void SetAlarm(uint8_t alarmHr, uint8_t alarmMin); + void DisableAlarm(); + void SetOffAlarmNow(); + uint32_t SecondsToAlarm(); + void StopAlerting(); + void Register(System::SystemTask* systemTask); + enum class AlarmState { Not_Set, Set, Alerting }; + enum class RecurType { None, Daily, Weekdays }; + void ToggleRecurrence(); + uint8_t Hours() const { + return hours; + } + uint8_t Minutes() const { + return minutes; + } + AlarmState State() const { + return state; + } + RecurType Recurrence() const { + return recurrence; + } + + private: + Controllers::DateTime& dateTimeController; + System::SystemTask* systemTask = nullptr; + uint8_t hours; + uint8_t minutes; + std::chrono::time_point alarmTime; + AlarmState state = AlarmState::Not_Set; + RecurType recurrence = RecurType::None; + void scheduleAlarm(); + }; + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2