-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.h
42 lines (34 loc) · 1.1 KB
/
Button.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
#include "Control.h"
#define SAMPLES 3
class Button: public Control {
private:
enum States { UP, DOWN };
int _state;
uint8_t _pin;
int _pressed = 0;
int _count = 0;
Action* _onPress;
Action* _onRelease;
public:
Button() :
Control { "Button", CTL_DIGITAL, DEFAULT_SAMPLE_RATE }
{ };
Button(String name, int pin, Action* onPress, Action* onRelease) :
Control { name, CTL_DIGITAL, DEFAULT_SAMPLE_RATE },
_pin ( pin ),
_onPress ( onPress ),
_onRelease ( onRelease )
{
pinMode(_pin, INPUT);
};
Button(String name, int pin) :
Control { name, CTL_DIGITAL, DEFAULT_SAMPLE_RATE },
_pin ( pin )
{
pinMode(_pin, INPUT);
};
int getState();
void update();
void setPress(Action* onPress);
void setRelease(Action* onRelease);
};