-
Notifications
You must be signed in to change notification settings - Fork 0
/
pushbutton.h
37 lines (34 loc) · 884 Bytes
/
pushbutton.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
#ifndef PUSH_BUTTON_H
#define PUSH_BUTTON_H
#include <Arduino.h>
#include "phmeter.h"
#include "CTimer.h"
//#include "config.h"
class PushButton {
private:
static const int DEBOUNCE_DELAY = 50;
int _pin[4];
unsigned long _lastDebounceTime[4];
bool _lastButtonState[4];
bool _buttonState[4];
bool _pullup;
bool readButton(int index);
void (*_onSSPressedCallback)();
void (*_onMPPressedCallback)();
void (*_onMMPressedCallback)();
void (*_onRTPressedCallback)();
public:
PushButton();
PushButton(int pinSS, int pinMP, int pinMM, int pinRT, bool pullup = true);
void init();
bool isPressedSS();
bool isPressedMP();
bool isPressedMM();
bool isPressedRT();
void checkButtons();
void onSSPressed(void (*callback)());
void onMPPressed(void (*callback)());
void onMMPressed(void (*callback)());
void onRTPressed(void (*callback)());
};
#endif