Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alarm persist to flash #1367

Merged
merged 2 commits into from
Sep 28, 2024
Merged

Alarm persist to flash #1367

merged 2 commits into from
Sep 28, 2024

Conversation

NeroBurner
Copy link
Contributor

@NeroBurner NeroBurner commented Oct 12, 2022

rebase of #1333 with additional SaveAlarm() function as described below


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
or a firmware update

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

Also mark the SaveAlarmToFile() Save() SaveSettingsToFile function const, as it doesn't change
anything in the AlarmController object.


This PR needs InfiniTimeOrg/InfiniSim#67 to work on InfiniSim


Fixes: #1330

@NeroBurner NeroBurner added this to the 1.11.0 milestone Oct 12, 2022
@NeroBurner NeroBurner changed the title Alarm persist to flash neroburner Alarm persist to flash Oct 12, 2022
@NeroBurner NeroBurner modified the milestones: 1.11.0, 1.12.0 Oct 16, 2022
src/components/alarm/AlarmController.h Show resolved Hide resolved
src/components/alarm/AlarmController.h Outdated Show resolved Hide resolved
@NeroBurner NeroBurner force-pushed the alarm-persist-to-flash-neroburner branch from ac410fa to 3969a4a Compare October 27, 2022 22:01
@JF002 JF002 removed this from the 1.12.0 milestone Apr 2, 2023
NeroBurner added a commit to InfiniTimeOrg/InfiniSim that referenced this pull request Sep 19, 2024
… to file

Support for InfiniTimeOrg/InfiniTime#1367 which is a rebase/improvement
of InfiniTimeOrg/InfiniTime#1333 by @ght

The PR adds saving and restoring alarm state to the SPI NOR flash. So
the AlarmController needs the FileSystem-controller to work.

To support both the current `main` branch and the "save-alarm-to-file"
PR pass the Filesystem controller conditionally, only if
`Controller::FS` is mentioned in the `AlarmController.h` file
NeroBurner added a commit to InfiniTimeOrg/InfiniSim that referenced this pull request Sep 19, 2024
… to file

Support for InfiniTimeOrg/InfiniTime#1367 which is a rebase/improvement
of InfiniTimeOrg/InfiniTime#1333 by @ght

The PR adds saving and restoring alarm state to the SPI NOR flash. So
the AlarmController needs the FileSystem-controller to work.

To support both the current `main` branch and the "save-alarm-to-file"
PR pass the Filesystem controller conditionally, only if
`Controller::FS` is mentioned in the `AlarmController.h` file
@NeroBurner NeroBurner force-pushed the alarm-persist-to-flash-neroburner branch from 3969a4a to 9694ccd Compare September 19, 2024 19:32
Copy link

github-actions bot commented Sep 19, 2024

Build size and comparison to main:

Section Size Difference
text 374528B 296B
data 948B 0B
bss 63488B 8B

@NeroBurner NeroBurner added this to the 1.16.0 milestone Sep 19, 2024
@NeroBurner NeroBurner force-pushed the alarm-persist-to-flash-neroburner branch from 9694ccd to 89f0664 Compare September 19, 2024 19:59
@NeroBurner
Copy link
Contributor Author

rebased and squashed on current main

Copy link
Member

@mark9064 mark9064 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tested but looks sensible to me

src/components/alarm/AlarmController.cpp Outdated Show resolved Hide resolved
src/systemtask/SystemTask.cpp Outdated Show resolved Hide resolved
@NeroBurner NeroBurner force-pushed the alarm-persist-to-flash-neroburner branch from 89f0664 to 299d19f Compare September 21, 2024 19:26
Copy link
Member

@mark9064 mark9064 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untested but all LGTM

@NeroBurner NeroBurner force-pushed the alarm-persist-to-flash-neroburner branch from 579be33 to 0d41924 Compare September 21, 2024 20:22
@NeroBurner NeroBurner modified the milestones: 1.16.0, 1.15.0 Sep 21, 2024
@mark9064
Copy link
Member

I considered opening a comment on that text you just changed but decided it was too minor LOL

@NeroBurner NeroBurner force-pushed the alarm-persist-to-flash-neroburner branch from 0d41924 to ae860cc Compare September 21, 2024 20:47
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
or reflashing of a new version of InfiniTime.

Just like the `Settings.h` `LoadSettingsFromFile()` the previous alarm
at boot (if available) and `SaveSettingsToFile()` the current alarm when
the `Alarm.h` screen is closed (only if the settings have changed).

The alarm-settings file is stored in `.system/alarm.dat`. The `.system`
folder is created if it doesn't yet exist.

Fixes: #1330
@NeroBurner
Copy link
Contributor Author

There is a segfault or freeze leading to a reboot on the second time when changing the alarm setting and exit the Alarm setting screen. Need to investigate

Close the `lfs_dir` object for the `.system` dir after usage. Otherwise
on the second changed alarm the system will lockup because the `.system`
dir is already open and was never closed.
@NeroBurner NeroBurner force-pushed the alarm-persist-to-flash-neroburner branch from ae860cc to b0ab1c4 Compare September 23, 2024 17:34
@NeroBurner
Copy link
Contributor Author

found it, need to close the lfs_dir after checking if the .system dir already exists or if we need to create it ourselfs

@mark9064
Copy link
Member

Did I miss that or did you only just add .system?

@NeroBurner
Copy link
Contributor Author

NeroBurner commented Sep 24, 2024

Second. I did add it recently, based in an old Diskussion about where to put pinetime system files and that they shouldn't be in the root for the user to be directly available. JF and Riksu9000 agreed that a subfolder .system is a goog place to put our configs. And the user can put their files at the root

#1367 (comment)

@NeroBurner NeroBurner merged commit a0cd439 into main Sep 28, 2024
7 checks passed
@NeroBurner NeroBurner deleted the alarm-persist-to-flash-neroburner branch September 28, 2024 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alarm doesn't persist through resets
5 participants