You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
long lastCheck = 0;
void loop() {
M5.update();
if (millis() - lastCheck > 200) {
lastCheck = millis();
if (M5.BtnA.wasReleased()) {
//do something - never reached!
}
// check other inputs via I2C
}
}
So I'm checking for various inputs, the M5 buttons and other ones via I2C. I limit the rate of checking to 200ms. However in this code M5.BtnA.wasReleased() is never 1 or true, it seems like M5.update() internally resets the state, which shouldn't be the case IMO.
I'm doing this workaround, which works, but is not so clean:
long lastCheck = 0;
int btnAPressed = 0;
void loop() {
M5.update();
btnAPressed = btnAPressed || M5.BtnA.wasReleased();
if (millis() - lastCheck > 200) {
lastCheck = millis();
if (btnAPressed) {
//do something - works!
}
// check other inputs via I2C
btnAPressed = 0;
}
}