PiPower  ac0ff3c (Mon Feb 11 21:44:30 2019 -0500)
/home/travis/build/larsks/pipower/button.h
Go to the documentation of this file.
1 
8 #ifndef _button_h
9 #define _button_h
10 
11 #include <stdint.h>
12 #include "bool.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 typedef struct Button {
19  uint8_t pin,
20  history,
21  poll_freq,
22  last_poll;
23 } Button;
24 
25 void button_new(Button *button, uint8_t pin, uint8_t poll_freq);
26 extern void button_destroy(Button *);
27 extern void button_update(Button *);
28 extern bool button_is_pressed(Button *);
29 extern bool button_is_released(Button *);
30 extern bool button_is_up(Button *);
31 extern bool button_is_down(Button *);
32 
33 #ifdef __cplusplus
34 }
35 #endif
36 
37 #endif // _button_h
bool button_is_released(Button *)
Return true if button has been released.
Definition: button.c:60
bool button_is_up(Button *)
Return true if button is up.
Definition: button.c:72
uint8_t history
Button state history.
Definition: button.h:19
uint8_t pin
Pin to which button is attached.
Definition: button.h:19
bool button_is_down(Button *)
Return true if button is down.
Definition: button.c:77
uint8_t last_poll
Time at which we last checked button state.
Definition: button.h:19
void button_update(Button *)
Push current button state onto history.
Definition: button.c:37
uint8_t poll_freq
How often (in ms) to check button state.
Definition: button.h:19
bool button_is_pressed(Button *)
Return true if button has been pressed.
Definition: button.c:48
void button_new(Button *button, uint8_t pin, uint8_t poll_freq)
Create a new Button object.
Definition: button.c:23
a simple replacement for stdbool.h.
Definition: button.h:18