Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hdw-btn.c File Reference

Data Structures

struct  timedEvt_t
 A timestamped button event. More...
 

Macros

#define DEBOUNCE_HIST_LEN   5
 The number of samples kept in history to debounce buttons.
 
#define TOUCH_CENTER   2
 
#define NUM_TZ_RING   5
 

Functions

void initButtons (const gpio_num_t *pushButtons, uint8_t numPushButtons, const touch_pad_t *touchPads, uint8_t numTouchPads)
 Initialize both pushbuttons and touch buttons.
 
void deinitButtons (void)
 Free memory used by the buttons.
 
void powerDownButtons (void)
 Power down the touchpad and buttons.
 
void powerUpButtons (void)
 Power up the touchpad and buttons.
 
bool checkButtonQueue (buttonEvt_t *evt)
 Service the queue of button events that caused interrupts This only returns a single event, even if there are multiple in the queue This function may be called multiple times in a row to completely empty the queue.
 
int getTouchJoystick (int32_t *phi, int32_t *r, int32_t *intensity)
 Get high-level touch input, an analog input. NOTE: You must have touch callbacks enabled to use this.
 

Data Structure Documentation

◆ timedEvt_t

struct timedEvt_t
Data Fields
int32_t state
int32_t time The button state.

Macro Definition Documentation

◆ DEBOUNCE_HIST_LEN

#define DEBOUNCE_HIST_LEN   5

The number of samples kept in history to debounce buttons.

◆ TOUCH_CENTER

#define TOUCH_CENTER   2

◆ NUM_TZ_RING

#define NUM_TZ_RING   5

Function Documentation

◆ initButtons()

void initButtons ( const gpio_num_t * pushButtons,
uint8_t numPushButtons,
const touch_pad_t * touchPads,
uint8_t numTouchPads )

Initialize both pushbuttons and touch buttons.

Parameters
pushButtonsA list of GPIOs with pushbuttons to initialize. The list should be in the same order as buttonBit_t, starting at PB_UP
numPushButtonsThe number of pushbuttons to initialize
touchPadsA list of touch areas that make up a touchPad to initialize.
numTouchPadsThe number of touch buttons to initialize

◆ deinitButtons()

void deinitButtons ( void )

Free memory used by the buttons.

◆ powerDownButtons()

void powerDownButtons ( void )

Power down the touchpad and buttons.

◆ powerUpButtons()

void powerUpButtons ( void )

Power up the touchpad and buttons.

◆ checkButtonQueue()

bool checkButtonQueue ( buttonEvt_t * evt)

Service the queue of button events that caused interrupts This only returns a single event, even if there are multiple in the queue This function may be called multiple times in a row to completely empty the queue.

Parameters
evtIf an event occurred, return it through this argument
Returns
true if an event occurred, false if nothing happened

◆ getTouchJoystick()

int getTouchJoystick ( int32_t * phi,
int32_t * r,
int32_t * intensity )

Get high-level touch input, an analog input. NOTE: You must have touch callbacks enabled to use this.

Parameters
[out]phithe angle of the touch. Where 0 is right, 320 is up, 640 is left and 960 is down.
[out]ris how far from center you are. 511 is on the outside edge, 0 is on the inside.
[out]intensityis how hard the user is pressing.
Returns
true if touched (joystick), false if not touched (no centroid)