-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmultiButton.h
47 lines (31 loc) · 1.14 KB
/
multiButton.h
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
#ifndef MultiButton_h
#define MultiButton_h
#include "Arduino.h"
#include "ButtonAction.h"
class MultiButton {
public:
MultiButton(int pin);
// This value gets set as part of the constructor execution.
static int _pin;
// Holds the current button state.
static volatile int _state;
// Holds the last time debounce was evaluated (in millis).
static volatile long _lastDebounceTime;
// The delay threshold for debounce checking.
static const int _debounceDelay;
static const long _continualDownDelay;
// The last time the button was in a down state.
static volatile long _lastButtonDownTime;
// Holds the millis of when the button was pressed down.
static volatile long _buttonDownTime;
// Defines the duration in which is held to be interpreted as a long press.
static const long _longPressDelay;
static ButtonAction action;
void check();
static void setOnClick(void (*handleClick)());
static void setOnDoubleClick(void (*handleDoubleClick)());
static void setOnLongClick(void (*handleLongClick)());
private:
static void onChange();
};
#endif