Swadge ESP32-S2
APIs to develop for the Magfest Swadge
Loading...
Searching...
No Matches
hdw-touch.c File Reference

Macros

#define NUM_TZ_RING   5

Enumerations

enum  touchInitMode_t { TI_NONE , TI_JOYSTICK , TI_LINEAR }

Functions

void initTouchPads (const touch_pad_t *touchPads, uint8_t numTouchPads, float touchPadSensitivity, bool denoiseEnable)
 Initialize touchPad sensors.
void deinitTouchPads (void)
 Deinitialize the touch pads.
void powerUpTouchPads (void)
 Power up the touchpad.
void powerDownTouchPads (void)
 Power down the touchpad.
void initTouchJoystick (uint8_t centerPadIdx, const uint8_t *ringPadIdxs)
 Initialize the touch pads as a virtual joystick. The arguments are indices into the array touchPads[] which should have been previously passed into initTouchPads().
bool getTouchJoystick (int32_t *phi, int32_t *r, int32_t *intensity)
 Get high-level touch input, an analog input.
void initTouchLinear (const touchLinearCfg_t *touchLinearCfgs, uint8_t numTouchLinearCfgs)
 Initialize the touch pads as a set of linear arrays.
uint8_t getTouchLinear (linearTouch_t *touches, uint8_t numLinearTouches)
 Get a high level touch input from each configured linear array.

Variables

touchInitMode_t _touchInitMode = TI_NONE
 The initialization mode for the touch pads.
uint8_t _centerZone = 0
 The index of the touch pad in _touchPads[] used as the center zone for the joystick.
uint8_t _ringZones [NUM_TZ_RING] = {0}
 The indices of the touch pads in _touchPads[] used as the ring for the joystick.
uint8_t _numTouchLinearCfgs = 0
 The number of linear configurations of touch pads.
const touchLinearCfg_t_touchLinearCfgs = NULL
 The linear configurations of touch pads, including indices into _touchPads[].

Macro Definition Documentation

◆ NUM_TZ_RING

#define NUM_TZ_RING   5

Enumeration Type Documentation

◆ touchInitMode_t

Enumerator
TI_NONE 

Not configured for high level output.

TI_JOYSTICK 

Configured to report as a 2D joystick.

TI_LINEAR 

Configured to report as a set of linear 1D arrays.

Function Documentation

◆ initTouchPads()

void initTouchPads ( const touch_pad_t * touchPads,
uint8_t numTouchPads,
float touchPadSensitivity,
bool denoiseEnable )

Initialize touchPad sensors.

Parameters
touchPadsA list of touchPads to initialize
numTouchPadsThe number of touchPads to initialize
touchPadSensitivityThe sensitivity to set for these touchPads
denoiseEnabletrue to denoise the input, false to use it raw

◆ deinitTouchPads()

void deinitTouchPads ( void )

Deinitialize the touch pads.

◆ powerUpTouchPads()

void powerUpTouchPads ( void )

Power up the touchpad.

◆ powerDownTouchPads()

void powerDownTouchPads ( void )

Power down the touchpad.

◆ initTouchJoystick()

void initTouchJoystick ( uint8_t centerPadIdx,
const uint8_t * ringPadIdxs )

Initialize the touch pads as a virtual joystick. The arguments are indices into the array touchPads[] which should have been previously passed into initTouchPads().

Parameters
centerPadIdxThe touch pad index to use as the center of the joystick
ringPadIdxsA list of touch pad indices to use as the ring of the joystick. Must be at least NUM_TZ_RING long.

◆ getTouchJoystick()

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

Get high-level touch input, an analog input.

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)

◆ initTouchLinear()

void initTouchLinear ( const touchLinearCfg_t * touchLinearCfgs,
uint8_t numTouchLinearCfgs )

Initialize the touch pads as a set of linear arrays.

Parameters
touchLinearCfgsA list of configurations for each linear touch pad array
numTouchLinearCfgsThe number of configurations of linear touch pad arrays. This memory is not copied, so it must be valid for the lifetime of the firmware.

◆ getTouchLinear()

uint8_t getTouchLinear ( linearTouch_t * touches,
uint8_t numLinearTouches )

Get a high level touch input from each configured linear array.

Parameters
[out]touchesThe results of the touch, including if a touch was detected, intensity, and position
[in]numLinearTouchesThe number of linear arrays to try to read
Returns
The number of linear arrays successfully read

Variable Documentation

◆ _touchInitMode

touchInitMode_t _touchInitMode = TI_NONE

The initialization mode for the touch pads.

◆ _centerZone

uint8_t _centerZone = 0

The index of the touch pad in _touchPads[] used as the center zone for the joystick.

◆ _ringZones

uint8_t _ringZones[NUM_TZ_RING] = {0}

The indices of the touch pads in _touchPads[] used as the ring for the joystick.

◆ _numTouchLinearCfgs

uint8_t _numTouchLinearCfgs = 0

The number of linear configurations of touch pads.

◆ _touchLinearCfgs

const touchLinearCfg_t* _touchLinearCfgs = NULL

The linear configurations of touch pads, including indices into _touchPads[].