en-us_commands:reference:fifo
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| en-us_commands:reference:fifo [2026/09/07 21:52] – 만듦 - 바깥 편집 127.0.0.1 | en-us_commands:reference:fifo [2026/09/12 23:27] (current) – 바깥 편집 127.0.0.1 | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| ===== Example ===== | ===== Example ===== | ||
| + | |||
| + | Send '' | ||
| <code cpp> | <code cpp> | ||
| - | uint16_t | + | uint16_t |
| - | FIFO(0, | + | uint16_t removedValue = 0; |
| + | |||
| + | void setup() { | ||
| + | Serial.begin(115200); | ||
| + | Serial.println(F(" | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | if (!Serial.available()) return; | ||
| + | const char key = Serial.read(); | ||
| + | const bool store = key == ' | ||
| + | const bool take = key == ' | ||
| + | const bool reset = key == ' | ||
| + | if (!store && !take && !reset) return; | ||
| + | |||
| + | const bool ok = FIFO(0, | ||
| + | FIFO(0, false, false, 0, removedValue, 4); // Return IN and OUT to OFF so the next key creates a new rising edge. | ||
| + | |||
| + | if (reset) { | ||
| + | nextValue = 10; | ||
| + | Serial.println(F(" | ||
| + | } else if (!ok) { | ||
| + | Serial.println(F(" | ||
| + | } else if (store) { | ||
| + | Serial.print(F(" | ||
| + | Serial.println(nextValue); | ||
| + | nextValue += 10; | ||
| + | } else { | ||
| + | Serial.print(F(" | ||
| + | Serial.println(removedValue); | ||
| + | } | ||
| + | } | ||
| </ | </ | ||
| + | |||
| + | Pushing to a full buffer or popping from an empty one fails. | ||
| ===== Precautions ===== | ===== Precautions ===== | ||
| '' | '' | ||
| + | |||
| + | ===== Built-in Commands in the Same Category ===== | ||
| + | |||
| + | * [[: | ||
| [[: | [[: | ||
en-us_commands/reference/fifo.1788785565.txt.gz · Last modified: by 127.0.0.1
