Skip to content

Alarm persist to flash neroburner#1345

Closed
NeroBurner wants to merge 6 commits intodevelopfrom
alarm-persist-to-flash-neroburner
Closed

Alarm persist to flash neroburner#1345
NeroBurner wants to merge 6 commits intodevelopfrom
alarm-persist-to-flash-neroburner

Conversation

@NeroBurner
Copy link
Copy Markdown
Contributor

implementation for review for PR #1333

ght and others added 6 commits September 15, 2022 01:29
Save the set alarm time to the SPI NOR flash, so it does not reset to
the default value when the watch resets, e.g. due to watchdog timeout.

Size impact: +204 (400332 -> 400536)
Also reverts the attempt at deferring saving the alarm data for reduced
flash writes, in order to reduce complexity.

Split `AlarmController.State()` into `.IsAlerting()` and `.IsEnabled()`,
since the two properties are conceptually independent and it makes code
much cleaner:
```diff
-  if (alarmController.State() == Controllers::AlarmController::AlarmState::Alerting) { ...
+  if (alarmController.IsAlerting()) { ...
-  if (alarmController.State() == AlarmController::AlarmState::Set) { ...
+  if (alarmController.IsEnabled()) { ...
```
See the removed `switch` for another example.

Size impact: +44 (400536 -> 400580)
This avoids writing the time to flash for every single change.

Size impact: +16 (400580 -> 400596)
Introduce `SaveAlarm()` member function which saves to file only if the
alarm setting is changed.
The `alarmChanged` boolean flag mimics the behavior of `settingsChanged`
flag from `Settings.h`

Additionally save the alarm status when the enabled flag is toggled
immediately. To be sure a disabled Alarm stays disabled on a crash.

Also mark the `SaveAlarmToFile()` function const, as it doesn't change
anything in the `AlarmController` object.
@NeroBurner NeroBurner closed this Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants