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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/accelerometer-test/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ void app_wake_from_backup(void) {
void app_setup(void) {
}

void app_write_to_backup(void) {
}

void app_prepare_for_standby(void) {
}

Expand Down
3 changes: 3 additions & 0 deletions apps/beats-time/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ void app_wake_from_backup(void) {
// This app does not support BACKUP mode.
}

void app_write_to_backup(void) {
}

void app_setup(void) {
watch_enable_external_interrupts();
watch_register_interrupt_callback(BTN_MODE, cb_mode_pressed, INTERRUPT_TRIGGER_RISING);
Expand Down
3 changes: 3 additions & 0 deletions apps/buzzer-test/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ void app_init(void) {
void app_wake_from_backup(void) {
}

void app_write_to_backup(void) {
}

void app_setup(void) {
watch_register_extwake_callback(BTN_ALARM, cb_alarm_pressed, true);

Expand Down
3 changes: 3 additions & 0 deletions apps/eeprom-emulation-upgrade/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ void app_init(void) {
void app_wake_from_backup(void) {
}

void app_write_to_backup(void) {
}

void app_setup(void) {
delay_ms(5000);
while (!(NVMCTRL->INTFLAG.reg & NVMCTRL_INTFLAG_READY));
Expand Down
3 changes: 3 additions & 0 deletions apps/flash-test/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ void app_init(void) {
void app_wake_from_backup(void) {
}

void app_write_to_backup(void) {
}

void app_setup(void) {
// mount the filesystem
int err = lfs_mount(&lfs, &cfg);
Expand Down
3 changes: 3 additions & 0 deletions apps/functional-test/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ void app_init(void) {
void app_wake_from_backup(void) {
}

void app_write_to_backup(void) {
}

void app_setup(void) {
watch_enable_display();

Expand Down
3 changes: 3 additions & 0 deletions apps/pro-rainbow-test/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ void app_init(void) {
void app_wake_from_backup(void) {
}

void app_write_to_backup(void) {
}

void app_setup(void) {
watch_enable_leds();
}
Expand Down
3 changes: 3 additions & 0 deletions apps/sensor-board-test/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ void app_init(void) {
void app_wake_from_backup(void) {
}

void app_write_to_backup(void) {
}

void app_setup(void) {
watch_enable_digital_output(RED);
watch_enable_digital_output(GREEN);
Expand Down
3 changes: 3 additions & 0 deletions apps/sensor-watch-lite-test/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ void app_init(void) {
void app_wake_from_backup(void) {
}

void app_write_to_backup(void) {
}

void app_setup(void) {
// Set up tick for RTC test
watch_rtc_register_periodic_callback(cb_tick, 8);
Expand Down
3 changes: 3 additions & 0 deletions apps/spi-test/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ void app_init(void) {
void app_wake_from_backup(void) {
}

void app_write_to_backup(void) {
}

void app_setup(void) {
spi_flash_init();
delay_ms(5000);
Expand Down
3 changes: 3 additions & 0 deletions apps/uart-display/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ void app_init(void) {
void app_wake_from_backup(void) {
}

void app_write_to_backup(void) {
}

void app_setup(void) {
}

Expand Down
4 changes: 3 additions & 1 deletion movement/movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,13 @@ void app_wake_from_backup(void) {
movement_state.birthdate.reg = watch_get_backup_data(2);
}

void app_setup(void) {
void app_write_to_backup(void) {
watch_store_backup_data(movement_state.settings.reg, 0);
watch_store_backup_data(movement_state.location.reg, 1);
watch_store_backup_data(movement_state.birthdate.reg, 2);
}

void app_setup(void) {
static bool is_first_launch = true;

if (is_first_launch) {
Expand Down
1 change: 1 addition & 0 deletions watch-library/hardware/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ int main(void) {

// Watch library code. Set initial parameters for the device and enable the RTC.
_watch_init();
app_write_to_backup();

// if date/time register is 0 (power on reset state), default year to 2023.
watch_date_time date_time = watch_rtc_get_date_time();
Expand Down
5 changes: 5 additions & 0 deletions watch-library/shared/watch/watch_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ void app_init(void);
*/
void app_wake_from_backup(void);

/** @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);

Comment on lines +66 to +70
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.

/** @brief A function you will implement to set up your application. The app_setup function is like setup() in Arduino.
* It is called once when the program begins. You should set pin modes and enable any peripherals you want to
* set up (real-time clock, I2C, etc.) Depending on your application, you may or may not want to configure
Expand Down
1 change: 1 addition & 0 deletions watch-library/simulator/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void delay_ms(const uint16_t ms) {
int main(void) {
app_init();
_watch_init();
app_write_to_backup();
app_setup();

resume_main_loop();
Expand Down
Loading