simplify the debouncing API.

pull/18/head
Jesse Vincent 9 years ago
parent f8afa6819f
commit 30d55a84fe

@ -5,14 +5,10 @@
boolean key_was_pressed (byte keyState) { boolean key_was_pressed (byte keyState) {
return (! key_was_not_pressed(keyState));
}
boolean key_was_not_pressed (byte keyState) {
if ( keyState & B00001000 || keyState & B00000100) { if ( keyState & B00001000 || keyState & B00000100) {
return false;
} else {
return true; return true;
} else {
return false;
} }
} }
@ -24,12 +20,8 @@ boolean key_is_pressed (byte keyState) {
} }
} }
boolean key_is_not_pressed (byte keyState) {
return !key_is_pressed(keyState);
}
boolean key_toggled_on(byte keyState) { boolean key_toggled_on(byte keyState) {
if (key_is_pressed(keyState) && key_was_not_pressed(keyState)) { if (key_is_pressed(keyState) && ! key_was_pressed(keyState)) {
return true; return true;
} else { } else {
return false; return false;
@ -38,7 +30,7 @@ boolean key_toggled_on(byte keyState) {
boolean key_toggled_off(byte keyState) { boolean key_toggled_off(byte keyState) {
if (key_was_pressed(keyState) && key_is_not_pressed(keyState)) { if (key_was_pressed(keyState) && ! key_is_pressed(keyState)) {
return true; return true;
} else { } else {
return false; return false;

@ -3,8 +3,6 @@
boolean key_was_pressed (byte keyState); boolean key_was_pressed (byte keyState);
boolean key_was_not_pressed (byte keyState);
boolean key_is_pressed (byte keyState); boolean key_is_pressed (byte keyState);
boolean key_is_not_pressed (byte keyState);
boolean key_toggled_on(byte keyState); boolean key_toggled_on(byte keyState);
boolean key_toggled_off(byte keyState); boolean key_toggled_off(byte keyState);

Loading…
Cancel
Save