Skip to content

Commit 7040555

Browse files
committed
* SimpleQueueStatic.ino example added
1 parent beb59aa commit 7040555

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ In this particular case, dropping decision must be made before re-enabling inter
5656
## Examples included
5757

5858
- [SimpleQueue.ino](examples/SimpleQueue/SimpleQueue.ino): Simple queue example (both LIFO FIFO implementations can be tested)
59+
- [SimpleQueueStatic.ino](examples/SimpleQueueStatic/SimpleQueueStatic.ino): Simple queue example using static queue data array (both LIFO FIFO implementations can be tested)
5960
- [PointersQueue.ino](examples/PointersQueue/PointersQueue.ino): Queue of string pointers for string processing
6061
- [SerialQueue.ino](examples/SerialQueue/SerialQueue.ino): Print characters received from Serial to Serial after reception of EOT char
6162
- [QueueDuplicates.ino](examples/QueueDuplicates/QueueDuplicates.ino): Simple test to test queue duplicates before pushing to queue

ReleaseNotes.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Feel free to share your thoughts @ xgarmanboziax@gmail.com about:
1010

1111
** Actual:
1212

13-
v1.10: 6 Nov 2022:
13+
v1.10: 15 Nov 2022:
14+
- SimpleQueueStatic.ino example added
1415
- Constructor parameters added to setup a queue from statically allocated data area
1516
- Constructor refactoring for consistency and robustness (when using queue functions regardless init performed with success)
1617
- Doxyfiles update
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
Simple Queue Static
3+
Simple queue demonstration using static queue data array
4+
5+
LIFO / FIFO implementations can be tested by changing IMPLEMENTATION
6+
7+
This example code is in the public domain.
8+
9+
created 15 November 2022
10+
by SMFSW
11+
*/
12+
13+
#include <cppQueue.h>
14+
15+
#define IMPLEMENTATION LIFO
16+
17+
18+
typedef struct strRec {
19+
uint16_t entry1;
20+
uint16_t entry2;
21+
} Rec;
22+
23+
Rec tab[6] = {
24+
{ 0x1234, 0x3456 },
25+
{ 0x5678, 0x7890 },
26+
{ 0x90AB, 0xABCD },
27+
{ 0xCDEF, 0xEFDC },
28+
{ 0xDCBA, 0xBA09 },
29+
{ 0x0987, 0x8765 }
30+
};
31+
32+
#define NB_ITEMS 10
33+
34+
Rec q_dat[NB_ITEMS];
35+
cppQueue q(sizeof(Rec), NB_ITEMS, IMPLEMENTATION, false, q_dat, sizeof(q_dat)); // Instantiate queue with static queue data arguments
36+
37+
// the setup function runs once when you press reset or power the board
38+
void setup() {
39+
Serial.begin(115200);
40+
}
41+
42+
// the loop function runs over and over again forever
43+
void loop() {
44+
unsigned int i;
45+
46+
for (i = 0 ; i < sizeof(tab)/sizeof(Rec) ; i++)
47+
{
48+
Rec rec = tab[i];
49+
q.push(&rec);
50+
}
51+
52+
for (i = 0 ; i < sizeof(tab)/sizeof(Rec) ; i++)
53+
{
54+
Rec rec;
55+
q.pop(&rec);
56+
Serial.print(rec.entry1, HEX);
57+
Serial.print(" ");
58+
Serial.println(rec.entry2, HEX);
59+
}
60+
61+
while(1);
62+
}

0 commit comments

Comments
 (0)