Instead of having a previousState and a currentState, of which at most two bits are used, use a single byte. This saves us a lot of code space, and makes a number of things easier, too. The helpers were redone as macros, since they are just bit checks now. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>pull/56/head
parent
6a02fa8380
commit
0de09ffc97
@ -1,36 +0,0 @@
|
|||||||
#include "keyswitch_state.h"
|
|
||||||
// switch debouncing and status
|
|
||||||
|
|
||||||
#define PRESSED B00000001
|
|
||||||
|
|
||||||
boolean key_was_pressed (uint8_t currentState, uint8_t previousState) {
|
|
||||||
if (previousState & PRESSED) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean key_is_pressed (uint8_t currentState, uint8_t previousState) {
|
|
||||||
if (currentState & PRESSED) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean key_toggled_on (uint8_t currentState, uint8_t previousState) {
|
|
||||||
if ((currentState & PRESSED) && ! (previousState & PRESSED) ) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean key_toggled_off (uint8_t currentState, uint8_t previousState) {
|
|
||||||
if ((previousState & PRESSED) && ! (currentState & PRESSED) ) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in new issue