Cleanup getButtonState()
This commit is contained in:
@@ -50,14 +50,10 @@ ButtonState getButtonState() {
|
|||||||
ButtonState retVal = BUTTON_NONE;
|
ButtonState retVal = BUTTON_NONE;
|
||||||
if (currentState) {
|
if (currentState) {
|
||||||
// User has pressed a button down (nothing done on down)
|
// User has pressed a button down (nothing done on down)
|
||||||
if (currentState != previousState) {
|
// If there is a rising edge on one of the buttons from double press we
|
||||||
// There has been a change in the button states
|
// want to mask that out As users are having issues with not release
|
||||||
// If there is a rising edge on one of the buttons from double press we
|
// both at once
|
||||||
// want to mask that out As users are having issues with not release
|
previousState |= currentState;
|
||||||
// both at once
|
|
||||||
if (previousState == 0x03)
|
|
||||||
currentState = 0x03;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// User has released buttons
|
// User has released buttons
|
||||||
// If they previously had the buttons down we want to check if they were <
|
// If they previously had the buttons down we want to check if they were <
|
||||||
@@ -73,8 +69,8 @@ ButtonState getButtonState() {
|
|||||||
else
|
else
|
||||||
retVal = BUTTON_BOTH; // Both being held case
|
retVal = BUTTON_BOTH; // Both being held case
|
||||||
}
|
}
|
||||||
|
previousState = 0;
|
||||||
}
|
}
|
||||||
previousState = currentState;
|
|
||||||
previousStateChange = xTaskGetTickCount();
|
previousStateChange = xTaskGetTickCount();
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user