Swadge ESP32-S2
APIs to develop for the Magfest Swadge
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
66typedef 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,
77
82typedef struct
83{
84 uint16_t state;
86 bool down;
87 uint32_t time;
89
90void initButtons(const gpio_num_t* pushButtons, uint8_t numPushButtons);
91void deinitButtons(void);
92void powerDownButtons(void);
93void powerUpButtons(void);
95
96#endif
void initButtons(const gpio_num_t *pushButtons, uint8_t numPushButtons)
Initialize GPIO pushbuttons.
Definition hdw-btn.c:75
buttonBit_t button
The button that caused this event.
Definition hdw-btn.h:85
buttonBit_t
Bitmask values for all the different buttons.
Definition hdw-btn.h:67
@ PB_UP
The up button's bit.
Definition hdw-btn.h:68
@ PB_SELECT
The select button's bit.
Definition hdw-btn.h:75
@ PB_DOWN
The down button's bit.
Definition hdw-btn.h:69
@ PB_START
The start button's bit.
Definition hdw-btn.h:74
@ PB_B
The B button's bit.
Definition hdw-btn.h:73
@ PB_LEFT
The left button's bit.
Definition hdw-btn.h:70
@ PB_RIGHT
The right button's bit.
Definition hdw-btn.h:71
@ PB_A
The A button's bit.
Definition hdw-btn.h:72
bool checkButtonQueue(buttonEvt_t *)
Service the queue of button events that caused interrupts This only returns a single event,...
Definition hdw-btn.c:192
void deinitButtons(void)
Free memory used by the buttons.
Definition hdw-btn.c:117
void powerDownButtons(void)
Power down the GPIO pushbuttons.
Definition hdw-btn.c:127
bool down
True if the button was pressed, false if it was released.
Definition hdw-btn.h:86
void powerUpButtons(void)
Power up the GPIO pushbuttons.
Definition hdw-btn.c:139
uint32_t time
Definition hdw-btn.h:87
uint16_t state
A bitmask for the state of all buttons.
Definition hdw-btn.h:84
A button event containing the button that triggered the event, whether it was pressed or released,...
Definition hdw-btn.h:83