Skip to content

Commit 8e3c429

Browse files
committed
changed readbutton interface
1 parent 45c80a5 commit 8e3c429

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

include/EZButton.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class EZButton
1818
unsigned long HoldInterval;
1919

2020
EZButton(const String buttonNames[],
21-
bool *(*readButtons)(String *, int),
21+
void (*readButtons)(String *, bool *, int),
2222
unsigned long holdTreshold = 500,
2323
unsigned long holdInterval = 500);
2424

@@ -41,7 +41,7 @@ class EZButton
4141
Event *_onReleaseEvents;
4242
Event *_onHoldReleaseEvents;
4343
Event *_onHoldEvents;
44-
bool *(*_readButtons)(String *, int);
44+
void (*_readButtons)(String *, bool *, int);
4545
};
4646

4747
#endif // EZButton_H

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "EZButton",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "A Library for managing different button events. Events include: OnPressed, OnReleased, OnHold, OnHoldReleased.",
55
"keywords": "button, key, event, hold, press, release",
66
"repository":

src/EZButton.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "EZButton.h"
22

33
EZButton::EZButton(const String buttonNames[],
4-
bool *(*readButtons)(String *, int),
4+
void (*readButtons)(String *, bool *, int),
55
unsigned long holdTreshold,
66
unsigned long holdInterval)
77
{
@@ -43,7 +43,8 @@ EZButton::~EZButton()
4343
delete[] _onHoldReleaseEvents;
4444
}
4545

46-
void EZButton::Reset(){
46+
void EZButton::Reset()
47+
{
4748
for (int i = 0; i < _numButtons; i++)
4849
{
4950
_buttonDownMillis[i] = 0;
@@ -54,7 +55,8 @@ void EZButton::Reset(){
5455

5556
void EZButton::CheckButtons()
5657
{
57-
bool *buttonStates = _readButtons(_buttons, _numButtons);
58+
bool *buttonStates = new bool[_numButtons];
59+
_readButtons(_buttons, buttonStates, _numButtons);
5860

5961
for (int i = 0; i < _numButtons; i++)
6062
{

0 commit comments

Comments
 (0)