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

Backup dont overwrite on wake #474

Closed

Conversation

voloved
Copy link
Contributor

@voloved voloved commented Sep 10, 2024

This issue was first noticed due to #387. This PR introduced reading and writing to the backup register in order to store birthdate and location. Its implementation is correct, but it did uncover a small bug.
On startup, we call app_setup, which writes the data in movement_state to the backup registers. This is good and at this point, those registers contain the defaults. However, app_setup also gets called when we wake from sleep. This means that the values in movement_state overwrite the backups. This is okay for the settings, as settings pass their pointer and get modified in every watch face, so movement_state.settings is always up-to-date.; birthdate and location don't have that luxury.

This PR moves the function that writes to the backup out of app_setup and into the line right above where app_setup gets called in main. There are 3 places where app_setup gets called on the watch: main, sleep, and deep_sleep, so only including this function in main seems appropriate.

The first commit in this PR also does this, but by reading the backup register before rewriting it on wake. This is a smaller change as no new functions are added, but a worse implementation. This is due to the watch reading the backup on wake, and then just writing what it just read back to the register.

This has been tested on hardware by:

  1. Going to sunrise face
  2. Verifying that the long and lat on it matches the DEFAULT in the code (which confirms we're writing to the backup on startup correctly)
  3. Changing the long and lat to something else.
  4. Waiting for LE time out.
  5. Waking from sleep
  6. confirming the default didn't overwrite it like the issue that started this investigation

Comment on lines +66 to +70
/** @brief This function writes the values in movement_state to the backup registers.
* It is used on start-up to write the defaults to each of the registers.
*/
void app_write_to_backup(void);

Copy link
Owner

Choose a reason for hiding this comment

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

We should not be adding Movement specific stuff to the watch library.

@joeycastillo
Copy link
Owner

This goes too deep to try to address this problem. We shouldn't be hacking around in the core watch library loop to fix an issue in Movement. I will dig into this and try to fix the issue without going too deep. Do we have a sense for when this was introduced? I'd much rather revert whatever change caused this than try to work around it.

matheusmoreira added a commit that referenced this pull request Sep 10, 2024
This commit caused state restored from backup registers
to be overwritten. It is thereby reverted until a better
solution is found or movement is refactored.

This reverts commit 524098b.

Reviewed-by: Matheus Afonso Martins Moreira <[email protected]>
References: #474
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