====== FILO() ====== ''FILO()'' outputs the last stored 16-bit data first. {{:en-us_commands:reference:filo.svg?900|FILO command operation flow}} ''bool FILO(uint8_t filo_id, bool IN, bool OUT, uint16_t input, uint16_t &output, uint8_t size, bool reset = false)'' ===== Commands ===== ^ Command ^ Arguments ^ Return Value ^ Operation ^ | ''FILO(filo_id, IN, OUT, input, output, size, reset)'' | ''uint8_t filo_id''\\ ''bool IN'' — Store input on the rising edge\\ ''bool OUT'' — Output on the rising edge\\ ''uint16_t input'' — Word to store\\ ''uint16_t &output'' — Reference variable receiving the output\\ ''uint8_t size'' — Buffer size\\ ''bool reset = false'' — Reset the buffer | ''bool'' | Outputs the last stored 16-bit data first. | ===== Example ===== Send ''a'' in Serial Monitor to store the next number, ''p'' to retrieve the most recently stored number, or ''c'' to clear the buffer. Send one character at a time to observe the behavior. uint16_t nextNumber = 0; uint16_t lastNumber = 0; void setup() { Serial.begin(115200); } void loop() { if (!Serial.available()) return; const char action = Serial.read(); const bool store = action == 'a'; const bool retrieve = action == 'p'; const bool clearBuffer = action == 'c'; if (store) ++nextNumber; const bool ok = FILO(0, store, retrieve, nextNumber, lastNumber, 16, clearBuffer); // Store a number; on a pop signal, retrieve the last stored number. FILO(0, false, false, nextNumber, lastNumber, 16, false); // Return both inputs to LOW so the next character creates a new rising edge. if (retrieve && ok) Serial.println(lastNumber); if (retrieve && !ok) Serial.println(F("Buffer empty")); } ===== Precautions ===== ''IN'', ''OUT'', ''CU'' and ''CD'' act on rising edges. Use a unique ''id'' for each counter or buffer, and keep ''size'' to the required minimum. ===== Built-in Commands in the Same Category ===== * [[:en-us_commands:reference:fifo|FIFO() View detailed description]] [[:en-us_commands:builtin|← Built-in Command List]]