m5stack / M5StickC

M5StickC Arduino Library
MIT License
477 stars 222 forks source link

Fix BtnIrq.ino example #111

Closed fustilio closed 4 years ago

fustilio commented 4 years ago

In the original, I got the following the serial output, but the readings on the LCD screen was fine (they change as expected)

16:46:30.071 -> pin 35 status: 1
16:46:30.071 -> axp192 btn status: 0
16:46:31.092 -> pin 35 status: 1
16:46:31.092 -> axp192 btn status: 0
  M5.Lcd.printf("pin 35 status: %d\r\n", digitalRead(35));
  // Read IRQStatus, also clears the status bits
  M5.Lcd.printf("axp192 btn status: %d\r\n", axp192_getBtnIRQStatus());
  // IRQStatus has been cleared, so pin 35 is always 1
  Serial.printf("pin 35 status: %d\r\n", digitalRead(35));
  // Read IRQStatus again but since it's been cleared, it's always 0
  Serial.printf("axp192 btn status: %d\r\n", axp192_getBtnIRQStatus());

The updates in this PR should fix this and both Serial and LCD will reflect the changing values.