File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class EZButton
2727
2828 ~EZButton ();
2929
30- void Reset ( );
30+ void Blackout ( unsigned long milis );
3131 void CheckButtons ();
3232 void Subscribe (int index, void (*event)(), EventTypes type);
3333
@@ -37,6 +37,7 @@ class EZButton
3737 unsigned long *_buttonDownMillis;
3838 unsigned int *_lastHoldInterval;
3939 bool *_buttonLastState;
40+ unsigned long _blackoutTime = 0 ;
4041
4142 typedef void (*Event)(); // Type alias for function pointer
4243 Event *_events;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ EZButton::EZButton(int buttonCount,
1717 for (int i = 0 ; i < _numButtons * EVENT_COUNT; i++)
1818 _events[i] = nullptr ;
1919
20- Reset ( );
20+ Blackout ( 0 );
2121}
2222
2323EZButton::~EZButton ()
@@ -28,18 +28,22 @@ EZButton::~EZButton()
2828 delete[] _events;
2929}
3030
31- void EZButton::Reset ( )
31+ void EZButton::Blackout ( unsigned long milis )
3232{
3333 for (int i = 0 ; i < _numButtons; i++)
3434 {
3535 _buttonDownMillis[i] = 0 ;
3636 _buttonLastState[i] = false ;
3737 _lastHoldInterval[i] = 0 ;
3838 }
39+ _blackoutTime = millis () + milis;
3940}
4041
4142void EZButton::CheckButtons ()
4243{
44+ if (_blackoutTime > millis ())
45+ return ;
46+
4347 bool *buttonStates = new bool [_numButtons];
4448 _readButtons (buttonStates, _numButtons);
4549
@@ -103,7 +107,8 @@ void EZButton::CallEvent(int index, EventTypes type)
103107 _events[i]();
104108}
105109
106- int EZButton::EventIndex (int index, EventTypes type){
110+ int EZButton::EventIndex (int index, EventTypes type)
111+ {
107112 return index + type * _numButtons;
108113}
109114
You can’t perform that action at this time.
0 commit comments