-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonDebounce.h
More file actions
56 lines (48 loc) · 1.37 KB
/
Copy pathButtonDebounce.h
File metadata and controls
56 lines (48 loc) · 1.37 KB
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
48
49
50
51
52
53
54
55
56
//
// ButtonsDebounce Library
//
// Created by Matteo Formentin
// GitHub: https://www.github.com/matt-formentin
// WebSite: https://www.ecuboost.it
//
#ifndef ButtonDebounce_h
#define ButtonDebounce_h
#include "Arduino.h"
class Button
{
public:
Button();
void begin(int _pin);
void begin(int _pin, int _press_time);
bool setShortPressCallback(void (*_short_callback)());
[[deprecated("Use setShortPressCallback instead")]];
bool addShortPressCallback(void (*_short_callback)());
bool removeShortPressCallback();
void enableShortPressCallback();
void disableShortPressCallback();
bool getShortPressCallbackStatus();
bool setLongPressCallback(void (*_long_callback)(), int _long_press_time);
[[deprecated("Use setLongPressCallback instead")]];
bool addLongPressCallback(void (*_long_callback)(), int _long_press_time);
bool removeLongPressCallback();
void enableLongPressCallback();
void disableLongPressCallback();
bool getLongPressCallbackStatus();
void buttonLoop();
static void empty(){};
private:
const int DEBOUNCE_TIME = 50;
int pin;
bool pull_wiring;
int previous_millis;
int current_millis;
bool previous_read;
bool current_read;
void (*short_callback)();
void (*long_callback)();
bool long_pressed;
int long_press_time;
bool short_press_function_on;
bool long_press_function_on;
};
#endif /* ButtonsDebounce_h */