Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
hdw-btn.c File Reference

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 (gpio_num_t *pushButtons, uint8_t numPushButtons, touch_pad_t *touchPads, uint8_t numTouchPads)
 Initialize both pushbuttons and touch buttons.
 
void deinitButtons (void)
 Free memory used by the 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.
 

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 ( gpio_num_t * pushButtons,
uint8_t numPushButtons,
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.

◆ 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)