ropg / M5Core2

M5Core2 Arduino Library
MIT License
7 stars 1 forks source link

M5Core2: pressedFor() is very erratic #68

Open felmue opened 4 years ago

felmue commented 4 years ago

Hi Rop

I used to be able to do this on an M5Core2:

void loop() {
  M5.update();
  if(M5.BtnA.pressedFor(2000) == true) {
    Serial.println("A: pressed for 2s");
  }
}

but now pressedFor(2000) is true immediately the first time, then the button doesn't react until I wait 2 seconds before touching it again. I can fix it by inserting a manual read M5.BtnA.read().

void loop() {
  M5.update();
  M5.BtnA.read();
  if(M5.BtnA.pressedFor(2000) == true) {
    Serial.println("A: pressed for 2s");
  }
}

Is that to be expected or am I missing something.

BTW: From what I can tell with only the M5.update() the buttons _lastChange doesn't get updated properly.

Thanks Felix