From 023025852ca1d1bbcd588be1659c5bdd5b7a63e1 Mon Sep 17 00:00:00 2001 From: Mike C Date: Sun, 10 Mar 2013 14:48:13 -0400 Subject: [PATCH] Tweak up/dn/select/enter to be more natural with the lcd buttons --- .../Universal_Serial_Adapter.ino | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Universal_Serial_Adapter/Universal_Serial_Adapter.ino b/Universal_Serial_Adapter/Universal_Serial_Adapter.ino index 60fbc25..fe4cc0b 100644 --- a/Universal_Serial_Adapter/Universal_Serial_Adapter.ino +++ b/Universal_Serial_Adapter/Universal_Serial_Adapter.ino @@ -51,6 +51,24 @@ void setup() { } void loop() { + // Up + if (!digitalRead(buttonPins[2])) { + serialmode newMode = (serialmode)(selectedMode - 1); + if (newMode >= 0) { + setSelection(newMode); + } + // Wait for release before going on + while(!digitalRead(buttonPins[2])); + } + + // Select / Enter + if (!digitalRead(buttonPins[1])) { + setMode(selectedMode); + // Wait for release before going on + while(!digitalRead(buttonPins[1])); + } + + // Down if (!digitalRead(buttonPins[0])) { serialmode newMode = (serialmode)(selectedMode + 1); if (newMode <= cisco) { @@ -59,21 +77,6 @@ void loop() { // Wait for release before going on while(!digitalRead(buttonPins[0])); } - - if (!digitalRead(buttonPins[1])) { - serialmode newMode = (serialmode)(selectedMode - 1); - if (newMode >= 0) { - setSelection(newMode); - } - // Wait for release before going on - while(!digitalRead(buttonPins[1])); - } - - if (!digitalRead(buttonPins[2])) { - setMode(selectedMode); - // Wait for release before going on - while(!digitalRead(buttonPins[2])); - } } void setMode(serialmode aMode) {