From c4047eabdbd636ec09779b484f09204aa3bb19d3 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 7 Nov 2019 15:53:48 -0700 Subject: [PATCH] Ensure that spurious presses are ignored --- src/board/system76/galp3-c/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/board/system76/galp3-c/main.c b/src/board/system76/galp3-c/main.c index 4630381..7bfb51f 100644 --- a/src/board/system76/galp3-c/main.c +++ b/src/board/system76/galp3-c/main.c @@ -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;