I’m trying to get the Qwiic button working with the RedBoard Turbo and have setup all the libraries and am able to talk to the button.
Stuff like button.isPressed() works exactly as expected. However, the queue stuff isn’t quite working properly.
I thought I’d use the pressed queue to make sure I got an accurate count of how many times the button was pressed. I’m using button.isPressedQueueEmpty() to check if the queue is empty before calling button.popPressedQueue() to remove a press. However, popPressedQueue() doesn’t seem to remove an element from the queue as expected.
After clicking the button once, isPressedQueueEmpty() returns false regardless of how many times popPressedQueue() is called. Also isPressedQueueFull() always returns true once I press the button 15 times.
Here’s the code I’m using.
#include <SparkFun_Qwiic_Button.h>
const int BLUE_LED = 13;
const int RX_LED = PIN_LED_RXL; // RX LED on pin 25, we use the predefined PIN_LED_RXL to make sure
const int TX_LED = PIN_LED_TXL; // TX LED on pin 26, we use the predefined PIN_LED_TXL to make sure
QwiicButton hourUpButton;
QwiicButton hourDownButton;
QwiicButton minuteUpButton;
QwiicButton minuteDownButton;
void setup() {
pinMode(BLUE_LED, OUTPUT);
pinMode(RX_LED, OUTPUT);
pinMode(TX_LED, OUTPUT);
digitalWrite(RX_LED, LOW); // TX LED on
SerialUSB.begin(9600);
Wire.begin(); //Join I2C bus
if (minuteDownButton.begin(0x67) == false)
errorLoop();
digitalWrite(RX_LED, HIGH); // TX LED off
while (!SerialUSB);
digitalWrite(BLUE_LED, HIGH); // Blue LED on
SerialUSB.println("Starting");
}
void loop() {
if (minuteDownButton.isPressedQueueEmpty() == false) {
SerialUSB.println("Minute Down");
minuteDownButton.popPressedQueue();
}
delay(100);
}
void errorLoop() {
while (1) {
digitalWrite(RX_LED, LOW); // RX LED on
delay(333);
digitalWrite(RX_LED, HIGH); // RX LED off
digitalWrite(TX_LED, LOW); // TX LED on
delay(333);
digitalWrite(TX_LED, HIGH); // TX LED off
digitalWrite(BLUE_LED, HIGH); // Blue LED on
delay(333);
digitalWrite(BLUE_LED, LOW); // Blue LED off
}
}
I’ve checked the firmware of the button and it matches the latest in the GitHub (258, 0x01 major, 0x02 minor)
I’ve also tried writing 0x01 to pressedQueueStatus register directly and reading it back. It reads 0 so the popRequest bit is either never set or cleared when the request is supposedly processed.