Swadge ESP32-S2
APIs to develop for the Magfest Swadge
Toggle main menu visibility
Loading...
Searching...
No Matches
hdw-btn.h
Go to the documentation of this file.
1
54
55
#ifndef _BTN_H_
56
#define _BTN_H_
57
58
#include <stdbool.h>
59
#include <stdint.h>
60
61
#include <driver/gpio.h>
62
66
typedef
enum
__attribute__((packed))
67
{
68
PB_UP
= 0x0001,
69
PB_DOWN
= 0x0002,
70
PB_LEFT
= 0x0004,
71
PB_RIGHT
= 0x0008,
72
PB_A
= 0x0010,
73
PB_B
= 0x0020,
74
PB_START
= 0x0040,
75
PB_SELECT
= 0x0080,
76
}
buttonBit_t
;
77
82
typedef
struct
83
{
84
uint16_t
state
;
85
buttonBit_t
button
;
86
bool
down
;
87
uint32_t
time
;
88
}
buttonEvt_t
;
89
90
void
initButtons
(
const
gpio_num_t* pushButtons, uint8_t numPushButtons);
91
void
deinitButtons
(
void
);
92
void
powerDownButtons
(
void
);
93
void
powerUpButtons
(
void
);
94
bool
checkButtonQueue
(
buttonEvt_t
*);
95
96
#endif
initButtons
void initButtons(const gpio_num_t *pushButtons, uint8_t numPushButtons)
Initialize GPIO pushbuttons.
Definition
hdw-btn.c:75
buttonEvt_t::button
buttonBit_t button
The button that caused this event.
Definition
hdw-btn.h:85
buttonBit_t
buttonBit_t
Bitmask values for all the different buttons.
Definition
hdw-btn.h:67
PB_UP
@ PB_UP
The up button's bit.
Definition
hdw-btn.h:68
PB_SELECT
@ PB_SELECT
The select button's bit.
Definition
hdw-btn.h:75
PB_DOWN
@ PB_DOWN
The down button's bit.
Definition
hdw-btn.h:69
PB_START
@ PB_START
The start button's bit.
Definition
hdw-btn.h:74
PB_B
@ PB_B
The B button's bit.
Definition
hdw-btn.h:73
PB_LEFT
@ PB_LEFT
The left button's bit.
Definition
hdw-btn.h:70
PB_RIGHT
@ PB_RIGHT
The right button's bit.
Definition
hdw-btn.h:71
PB_A
@ PB_A
The A button's bit.
Definition
hdw-btn.h:72
checkButtonQueue
bool checkButtonQueue(buttonEvt_t *)
Service the queue of button events that caused interrupts This only returns a single event,...
Definition
hdw-btn.c:192
deinitButtons
void deinitButtons(void)
Free memory used by the buttons.
Definition
hdw-btn.c:117
powerDownButtons
void powerDownButtons(void)
Power down the GPIO pushbuttons.
Definition
hdw-btn.c:127
buttonEvt_t::down
bool down
True if the button was pressed, false if it was released.
Definition
hdw-btn.h:86
powerUpButtons
void powerUpButtons(void)
Power up the GPIO pushbuttons.
Definition
hdw-btn.c:139
buttonEvt_t::time
uint32_t time
Definition
hdw-btn.h:87
buttonEvt_t::state
uint16_t state
A bitmask for the state of all buttons.
Definition
hdw-btn.h:84
buttonEvt_t
A button event containing the button that triggered the event, whether it was pressed or released,...
Definition
hdw-btn.h:83
components
hdw-btn
include
hdw-btn.h
Generated by
1.17.0