Commanders
Arduino buttons/bus library
EventStack.hpp
1 //-------------------------------------------------------------------
2 #ifndef __EventStack_Hpp__
3 #define __EventStack_Hpp__
4 //-------------------------------------------------------------------
5 
6 #include <Commanders.h>
7 
8 // Commanders don't have need for more events at this moment : more events, more memory consumed !
9 // A debug message will be shown if an event is lost because of this tiny size !
10 #define EVENT_MAXNUMBER 3
11 
20 {
21 private:
22  unsigned long id[EVENT_MAXNUMBER];
23  COMMANDERS_EVENT_TYPE type[EVENT_MAXNUMBER];
24  int data[EVENT_MAXNUMBER];
25 
26  EventStack()
27  {
28  for (byte i = 0; i < EVENT_MAXNUMBER; i++)
29  FreeEvent(i);
30  }
31 
32  void FreeEvent(byte inEvent);
33 
34 public:
37 
43  void PushEvent(unsigned long inId, COMMANDERS_EVENT_TYPE inType, int inData);
51  void GetEvent(byte inIndex, unsigned long *inpId, COMMANDERS_EVENT_TYPE *inpType, int *inpData);
55  byte GetPendingEventIndex();
56 };
57 
58 
59 #endif
byte GetPendingEventIndex()
Definition: EventStack.cpp:28
void PushEvent(unsigned long inId, COMMANDERS_EVENT_TYPE inType, int inData)
Definition: EventStack.cpp:12
static EventStack EventsStack
Definition: EventStack.hpp:36
void GetEvent(byte inIndex, unsigned long *inpId, COMMANDERS_EVENT_TYPE *inpType, int *inpData)
Definition: EventStack.cpp:37
COMMANDERS_EVENT_TYPE
Definition: Events.h:25