File syn_joystick.c¶
FileList > input > syn_joystick.c
Go to the source code of this file
Generic Analog Joystick & Multi-Axis Potentiometer Driver.
#include "syn_joystick.h"#include "../util/syn_assert.h"#include <math.h>#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| void | syn_joystick_feed_adc (SYN_Joystick * joy, uint16_t raw_x, uint16_t raw_y, bool btn) Feed raw ADC readings for X and Y axes. |
| SYN_JoystickDir | syn_joystick_get_dir (const SYN_Joystick * joy) Get 8-way directional state. |
| int16_t | syn_joystick_get_x_pct (const SYN_Joystick * joy) Get X axis position percentage (-100% to +100%). |
| int16_t | syn_joystick_get_y_pct (const SYN_Joystick * joy) Get Y axis position percentage (-100% to +100%). |
| SYN_Status | syn_joystick_init (SYN_Joystick * joy, uint16_t center_x, uint16_t center_y, uint16_t adc_max, uint16_t deadband) Initialize Analog Joystick instance. |
Public Functions Documentation¶
function syn_joystick_feed_adc¶
Feed raw ADC readings for X and Y axes.
Parameters:
joyJoystick context.raw_xRaw X axis ADC sample.raw_yRaw Y axis ADC sample.btnPushbutton logical state.
function syn_joystick_get_dir¶
Get 8-way directional state.
Parameters:
joyJoystick context.
Returns:
Directional state enum.
function syn_joystick_get_x_pct¶
Get X axis position percentage (-100% to +100%).
Parameters:
joyJoystick context.
Returns:
X percentage.
function syn_joystick_get_y_pct¶
Get Y axis position percentage (-100% to +100%).
Parameters:
joyJoystick context.
Returns:
Y percentage.
function syn_joystick_init¶
Initialize Analog Joystick instance.
SYN_Status syn_joystick_init (
SYN_Joystick * joy,
uint16_t center_x,
uint16_t center_y,
uint16_t adc_max,
uint16_t deadband
)
Parameters:
joyJoystick context.center_xExpected center X raw ADC reading.center_yExpected center Y raw ADC reading.adc_maxMax ADC full-scale value (e.g. 4095 for 12-bit ADC).deadbandDeadband threshold radius (e.g. 100).
Returns:
SYN_OK on success.
The documentation for this class was generated from the following file src/syntropic/input/syn_joystick.c