mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Implemented switching A and B buttons, closing #2034
getButtonState() now have an option int/bool argument to swap the result via XOR
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include <Buttons.hpp>
|
||||
TickType_t lastButtonTime = 0;
|
||||
|
||||
ButtonState getButtonState() {
|
||||
ButtonState getButtonState(bool revert) {
|
||||
/*
|
||||
* Read in the buttons and then determine if a state change needs to occur
|
||||
*/
|
||||
@@ -28,8 +28,8 @@ ButtonState getButtonState() {
|
||||
static TickType_t previousStateChange = 0;
|
||||
const TickType_t timeout = TICKS_100MS * 4;
|
||||
uint8_t currentState;
|
||||
currentState = (getButtonA()) << 0;
|
||||
currentState |= (getButtonB()) << 1;
|
||||
currentState = (getButtonA()) << (0 xor revert);
|
||||
currentState |= (getButtonB()) << (1 xor revert);
|
||||
|
||||
if (currentState) {
|
||||
lastButtonTime = xTaskGetTickCount();
|
||||
|
||||
@@ -27,7 +27,7 @@ enum ButtonState {
|
||||
};
|
||||
|
||||
// Returns what buttons are pressed (if any)
|
||||
ButtonState getButtonState();
|
||||
ButtonState getButtonState(bool revert=0);
|
||||
// Helpers
|
||||
void waitForButtonPressOrTimeout(TickType_t timeout);
|
||||
void waitForButtonPress();
|
||||
|
||||
Reference in New Issue
Block a user