From 826681214931cd53b607320a620428fb6e9d6bf1 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 5 Jun 2012 18:11:29 -0400 Subject: : Add BOARD_BUTTON_PRESSED_LEVEL. This allows boards to override the logic level of a pressed button. All Maple boards have a pressed button read HIGH, but if the opposite convention is used, isButtonPressed() will infinite loop. Make isButtonPressed() respect this setting. Signed-off-by: Marti Bolivar --- wirish/wirish_digital.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'wirish/wirish_digital.cpp') diff --git a/wirish/wirish_digital.cpp b/wirish/wirish_digital.cpp index a7f10cd..05ce756 100644 --- a/wirish/wirish_digital.cpp +++ b/wirish/wirish_digital.cpp @@ -65,9 +65,9 @@ void togglePin(uint8 pin) { #define BUTTON_DEBOUNCE_DELAY 1 uint8 isButtonPressed() { - if (digitalRead(BOARD_BUTTON_PIN)) { + if (digitalRead(BOARD_BUTTON_PIN) == BOARD_BUTTON_PRESSED_LEVEL) { delay(BUTTON_DEBOUNCE_DELAY); - while (digitalRead(BOARD_BUTTON_PIN)) + while (digitalRead(BOARD_BUTTON_PIN) == BOARD_BUTTON_PRESSED_LEVEL) ; return true; } -- cgit v1.2.3