Skip to content

Commit

Permalink
Add check if the button is held for the whole 5 seconds
Browse files Browse the repository at this point in the history
If the button is held down to reboot the watch and not released after the reboot, the device can enter recovery mode unintentionally. This check aims to ignore the button if it is held for the entirety of the 5 second delay, implying it was held before the device started to boot and should be ignored.
  • Loading branch information
kieranc authored Mar 10, 2021
1 parent 2e1a66e commit de0f514
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libs/pinetime_boot/src/pinetime_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ void pinetime_boot_init(void) {
console_printf("Waited 5 seconds (%d)\n", (int)button_samples); console_flush();

// Check whether button is pressed and held. Sample count must high enough to avoid accidental rollbacks.
if(button_samples == (3000 * 64 * 5)) {
console_printf("Button held for 5 seconds - ignoring\n"); console_flush();
}

if(button_samples > (3000 * 64 * 4)) {
console_printf("Restoring factory firmware\n"); console_flush();
restore_factory();
Expand Down

0 comments on commit de0f514

Please sign in to comment.