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/51/head
parent
8425071a76
commit
1dc9cc47de
@ -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