SNAKE_STM32F3
Loading...
Searching...
No Matches
joystick.h File Reference

Joystick handling module based on ADC (STM32 HAL). More...

#include "2dspace.h"
#include "main.h"
#include <stdbool.h>
Include dependency graph for joystick.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void joystick_init (ADC_HandleTypeDef *adc_handler)
 Initializes joystick handling by passing given ADC handler and starting ADC.
vec2_t joystick_read (void)
 Reads current joystick position from ADC.
bool joystick_check_tilt (void)
 Checks if joystick is tilted past the defined dead zone.
direction_t joystick_get_direction (void)
 interprets current joystick state as one of 4 directions or NONE.

Detailed Description

Joystick handling module based on ADC (STM32 HAL).

Author
bslrd
Date
2026

SPDX-License-Identifier: MIT

Function Documentation

◆ joystick_check_tilt()

bool joystick_check_tilt ( void )

Checks if joystick is tilted past the defined dead zone.

Returns
returns true if joystick is outside the deadzone and false otherwise
Here is the call graph for this function:

◆ joystick_get_direction()

direction_t joystick_get_direction ( void )

interprets current joystick state as one of 4 directions or NONE.

Returns
direction type value.
Here is the call graph for this function:

◆ joystick_init()

void joystick_init ( ADC_HandleTypeDef * adc_handler)

Initializes joystick handling by passing given ADC handler and starting ADC.

Parameters
adc_handlerpointer to ADC handler of choice.
Note
Should be called from main() before use of other joystick functions

◆ joystick_read()

vec2_t joystick_read ( void )

Reads current joystick position from ADC.

Parameters
adc_handlerpointer to ADC handler of choice.
Returns
vec2_t type vector with vec.x and vec.y values of joystick position.