summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Bini <michele.bini@gmail.com>2022-04-16 11:31:57 (GMT)
committerMichele Bini <michele.bini@gmail.com>2022-04-16 11:31:57 (GMT)
commitc9808e29f1bbfbd1396d7b83212f6d223d52f99d (patch)
tree74ad0edeb29269460833ce6c7863fa1fc6ca2069
parent1d48a97f09104e6b26159622d1631c781498e6f3 (diff)
Run ScheduleAlarm from System task events only.
-rw-r--r--src/components/alarm/AlarmController.cpp6
-rw-r--r--src/components/alarm/AlarmController.h1
-rw-r--r--src/systemtask/SystemTask.cpp1
3 files changed, 8 insertions, 0 deletions
diff --git a/src/components/alarm/AlarmController.cpp b/src/components/alarm/AlarmController.cpp
index cea679f..a08bfbd 100644
--- a/src/components/alarm/AlarmController.cpp
+++ b/src/components/alarm/AlarmController.cpp
@@ -99,6 +99,12 @@ void AlarmController::SetOffAlarmNow() {
void AlarmController::StopAlerting() {
systemTask->PushMessage(System::Messages::StopRinging);
+}
+
+void AlarmController::OnStopRinging() {
+ if (state != AlarmState::Alerting) {
+ return;
+ }
// Alarm state is off unless this is a recurring alarm
if (recurrence == RecurType::None) {
diff --git a/src/components/alarm/AlarmController.h b/src/components/alarm/AlarmController.h
index fb33edb..3c66775 100644
--- a/src/components/alarm/AlarmController.h
+++ b/src/components/alarm/AlarmController.h
@@ -38,6 +38,7 @@ namespace Pinetime {
void SetOffAlarmNow();
uint32_t SecondsToAlarm();
void StopAlerting();
+ void OnStopRinging();
enum class AlarmState { Not_Set, Set, Alerting };
enum class RecurType { None, Daily, Weekdays };
uint8_t Hours() const {
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index 38c728f..c7e0f38 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -319,6 +319,7 @@ void SystemTask::Work() {
break;
case Messages::StopRinging:
motorController.StopRinging();
+ alarmController.OnStopRinging();
break;
case Messages::BleConnected:
ReloadIdleTimer();