FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
featherlib/include/feather/button.h at master · kisom/featherlib · GitHub
kisom
/
featherlib
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
3
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
featherlib
/
include
/
feather
/
button.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (30 loc) · 863 Bytes
Breadcrumbs
featherlib
/
include
/
feather
/
button.h
Copy path
File metadata and controls
39 lines (30 loc) · 863 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
ifndef
__FEATHER_BUTTONS_H
#
define
__FEATHER_BUTTONS_H
#
include
<
Arduino.h
>
#
include
<
stdint.h
>
namespace
featherlib
{
typedef
void
(*button_callback)();
class
Button
{
public:
Button
(
uint8_t
pin) : pin(pin),
lastValue
(
0
),
value(
0
),
lastSample(
0
),
cb(
nullptr
)
{
if
(pin) {
pinMode
(pin,
INPUT_PULLUP
);
}
};
uint8_t
read
();
//
Return the button's current value.
bool
sample
();
//
Take another reading of the button.
void
registerCallback
(button_callback);
private:
uint8_t
pin;
//
Which pin is the button on?
uint8_t
lastValue;
//
What was the last sampled value?
uint8_t
value;
//
What is the last known value?
unsigned
long
lastSample;
//
When was the last sample taken?
button_callback cb;
//
What happens when the state changes?
};
}
//
namespace featherlib
#endif
//
__FEATHER_BUTTONS_H
Back
|
FazBrowse Home
|
New Git URL