Skip to content

Commit dec6b41

Browse files
committed
implemented basic types
1 parent 2aaba47 commit dec6b41

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/EZButton.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void EZButton::Loop()
107107
delete[] buttonStates;
108108
}
109109

110-
void EZButton::Subscribe(int index, void (*event)(), EventTypes type)
110+
void EZButton::Subscribe(int index, Event event, EventTypes type)
111111
{
112112
_events[EventIndex(index, type)] = event;
113113

@@ -121,7 +121,7 @@ void EZButton::CallEvent(int index, EventTypes type)
121121
LogEvent("Call:",index, type);
122122

123123
if (_events[i] != nullptr)
124-
_events[i]();
124+
_events[i](index);
125125
}
126126

127127
int EZButton::EventIndex(int index, EventTypes type)

src/EZButton.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ enum EventTypes
1212
RELEASED
1313
};
1414

15+
typedef void (*Event)(int); // Type alias for function pointer
16+
1517
class EZButton
1618
{
1719
public:
@@ -29,7 +31,7 @@ class EZButton
2931

3032
void Blackout(unsigned long milis);
3133
void Loop();
32-
void Subscribe(int index, void (*event)(), EventTypes type);
34+
void Subscribe(int index, Event event, EventTypes type);
3335

3436
private:
3537
int _numButtons;
@@ -39,7 +41,6 @@ class EZButton
3941
bool *_buttonLastState;
4042
unsigned long _blackoutTime = 0;
4143

42-
typedef void (*Event)(); // Type alias for function pointer
4344
Event *_events;
4445
void (*_readButtons)(bool *, int);
4546

0 commit comments

Comments
 (0)