You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.4 KiB
69 lines
1.4 KiB
9 years ago
|
#include "keyswitch_state.h"
|
||
10 years ago
|
// switch debouncing and status
|
||
|
|
||
|
|
||
9 years ago
|
boolean key_was_pressed (byte keyState) {
|
||
10 years ago
|
if ( keyState & B00001000 || keyState & B00000100) {
|
||
9 years ago
|
return true;
|
||
9 years ago
|
} else {
|
||
|
return false;
|
||
9 years ago
|
}
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
boolean key_was_pressed (uint8_t currentState, uint8_t previousState) {
|
||
|
if (previousState) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
boolean key_is_pressed (byte keyState) {
|
||
|
if ( keyState & B00000001 && keyState & B00000010 ) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
10 years ago
|
}
|
||
9 years ago
|
|
||
9 years ago
|
boolean key_is_pressed (uint8_t currentState, uint8_t previousState) {
|
||
|
if (currentState) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
boolean key_toggled_on(byte keyState) {
|
||
9 years ago
|
if (key_is_pressed(keyState) && ! key_was_pressed(keyState)) {
|
||
9 years ago
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
boolean key_toggled_on (uint8_t currentState, uint8_t previousState) {
|
||
|
if (currentState && ! previousState ) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
10 years ago
|
|
||
9 years ago
|
boolean key_toggled_off(byte keyState) {
|
||
9 years ago
|
if (key_was_pressed(keyState) && ! key_is_pressed(keyState)) {
|
||
9 years ago
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
10 years ago
|
}
|
||
9 years ago
|
|
||
|
boolean key_toggled_off (uint8_t currentState, uint8_t previousState) {
|
||
|
if (previousState && ! currentState ) {
|
||
|
return true;
|
||
|
} else {
|
||
|
return false;
|
||
|
}
|
||
|
}
|