Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M5.BtnA.wasReleased() never true if M5.update() is intermediately called again #290

Open
klues opened this issue May 9, 2022 · 0 comments

Comments

@klues
Copy link

klues commented May 9, 2022

I've the following scenario:

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;
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant