-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFifo.cpp
More file actions
47 lines (40 loc) · 1.54 KB
/
Fifo.cpp
File metadata and controls
47 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
////---------------------------------------------------------------------------------------------------------
// Include Libraries
#include <Arduino.h>
#include "LTTO.h"
void LTTO::PushToFifo(char type, uint16_t message) // Push latest message onto FIFO
{
if (_incomingIRmessageFIFO[_fifoPushPointer].type != ' ')
{
_messageOverwrittenCount++;
#ifdef DEBUG
Serial.print(F("Missed Pointer: "));
Serial.print(_fifoPushPointer);
#endif // DEBUG
return;
}
_incomingIRmessageFIFO[_fifoPushPointer].type = type;
_incomingIRmessageFIFO[_fifoPushPointer].rawDataPacket = message;
_incomingIRmessageFIFO[_fifoPushPointer].processed = false;
#ifdef DEBUG
Serial.print(F("\nPush:"));
Serial.print(_fifoPushPointer);
#endif
_fifoPushPointer++;
if (_fifoPushPointer == FIFO_SIZE) _fifoPushPointer = 0;
}
void LTTO::PopFromFifo() // Pop latest message from the FIFO
{
// Is there a new message to collect?
if (_incomingIRmessageFIFO[_fifoPopPointer].type == ' ') return;
decodedIRmessage.type = _incomingIRmessageFIFO[_fifoPopPointer].type;
decodedIRmessage.rawDataPacket = _incomingIRmessageFIFO[_fifoPopPointer].rawDataPacket;
decodedIRmessage.newMessage = true;
_incomingIRmessageFIFO[_fifoPopPointer].type = ' '; // Sets the message as empty/processed
#ifdef DEBUG
Serial.print(F("\tPop:"));
Serial.print(_fifoPopPointer);
#endif
_fifoPopPointer++;
if (_fifoPopPointer == FIFO_SIZE) _fifoPopPointer = 0;
}