Skip to content

Commit 7af76bb

Browse files
committed
Update Example4_QueueUsage.ino
Update example to print popped value and wait
1 parent e776466 commit 7af76bb

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

examples/Example4_QueueUsage/Example4_QueueUsage.ino

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ void loop(){
3939
Serial.print(button.timeSinceFirstPress()/1000.0);
4040
Serial.print("s since the button was first pressed ");
4141
}
42-
4342
//if the queue of pressed events is empty, just print that the queue is empty!
44-
if(button.isPressedQueueEmpty() == true) {
43+
else {
4544
Serial.print("ButtonPressed Queue is empty! ");
4645
}
4746

@@ -53,7 +52,7 @@ void loop(){
5352
Serial.print("s since the button was first clicked");
5453
}
5554
//if the queue of clicked events is empty, just print that the queue is empty!
56-
if(button.isPressedQueueEmpty() == true) {
55+
else {
5756
Serial.print(" ButtonClicked Queue is empty!");
5857
}
5958

@@ -63,13 +62,19 @@ void loop(){
6362

6463
uint8_t data = Serial.read();
6564
if(data == 'p' || data == 'P') { //if the character is p or P, then pop a value off of the pressed Queue
66-
button.popPressedQueue();
67-
Serial.println("Popped PressedQueue!");
65+
long pressedPopped = button.popPressedQueue();
66+
Serial.print("Popped from PressedQueue: ");
67+
Serial.println(pressedPopped/1000.0);
68+
// Wait before continuing on
69+
delay(3000);
6870
}
6971

7072
if(data == 'c' || data == 'C') { //if the character is c or C, then pop a value off of the pressed Queue
71-
button.popClickedQueue();
72-
Serial.println("Popped ClickedQueue!");
73+
long clickedPopped = button.popClickedQueue();
74+
Serial.print("Popped from Clicked Queue: ");
75+
Serial.println(clickedPopped/1000.0);
76+
// Wait before continuing on
77+
delay(3000);
7378
}
7479
}
7580
delay(20); //let's not hammer too hard on the I2C bus

0 commit comments

Comments
 (0)