add safety: ensure button is pressed before erasing

This commit is contained in:
King Kévin 2014-08-04 10:47:32 -07:00
parent 5162c29607
commit bcf548583f
1 changed files with 4 additions and 2 deletions

View File

@ -362,10 +362,12 @@ static void interrupt(void) __interrupt 0
} else {
led_on();
}
/* pressed for 5s, clear memory */
/* button pressed for 5s, clear memory */
if (hold==20) {
led_on();
clear_memory();
if (!(PORTB&SWITCH1)) { /* ensure the button is pressed */
clear_memory();
}
led_off();
TMR4ON = 0;
}