Ensure that spurious presses are ignored

This commit is contained in:
Jeremy Soller 2019-11-07 15:53:48 -07:00
parent 89fb9dca12
commit c4047eabdb
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1

View File

@ -100,9 +100,16 @@ void power_button() {
static bool power = false;
// Check if the power switch goes low
static bool last = false;
static bool last = true;
bool new = gpio_get(&PWR_SW_N);
if (!new && last) {
// Ensure press is not spurious
delay_ms(100);
if (gpio_get(&PWR_SW_N) != new) {
printf("Spurious press\n");
return;
}
printf("Power switch press\n");
power = !power;