Smart Camera ESP32
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
Joystick Class Reference

High-level interface for 12-bit analog joystick input. More...

#include <joystick.h>

Public Member Functions

Initialization
 Joystick (uint8_t pin_x, uint8_t pin_y, uint8_t pin_z, int deadzone=JOYSTICK_DEADZONE)
 Construct a new Joystick object.
 
void begin ()
 Configures hardware and performs auto-calibration.
 
Positional Data
int get_x () const
 
int get_y () const
 
bool is_active () const
 Checks if the joystick is currently deflected beyond the deadzone.
 
Button Input
bool is_z_pressed ()
 Detects a button press (Falling Edge).
 
bool is_z_held () const
 Check the current physical state of the button.
 
Motor Control Mapping
int get_speed_x (int min_out=-255, int max_out=255)
 Maps X deflection to a motor speed range.
 
int get_speed_y (int min_out=-255, int max_out=255)
 Maps Y deflection to a motor speed range.
 

Detailed Description

High-level interface for 12-bit analog joystick input.

Manages the translation of raw ADC voltage into meaningful movement vectors. Includes auto-calibration routines to compensate for mechanical center-point drift.

Constructor & Destructor Documentation

◆ Joystick()

Joystick::Joystick ( uint8_t pin_x,
uint8_t pin_y,
uint8_t pin_z,
int deadzone = JOYSTICK_DEADZONE )
inline

Construct a new Joystick object.

Parameters
pin_xAnalog Pin (VRX).
pin_yAnalog Pin (VRY).
pin_zDigital Pin (SW).
deadzoneThe sensitivity threshold (Defaults to JOYSTICK_DEADZONE).

Member Function Documentation

◆ begin()

void Joystick::begin ( )

Configures hardware and performs auto-calibration.

Warning
Important: The joystick must be at the neutral (resting) position during this call. It averages 10 samples to establish the baseline center.

◆ get_speed_x()

int Joystick::get_speed_x ( int min_out = -255,
int max_out = 255 )
inline

Maps X deflection to a motor speed range.

*

Parameters
min_outMinimum speed (default -255).
max_outMaximum speed (default 255).

◆ get_speed_y()

int Joystick::get_speed_y ( int min_out = -255,
int max_out = 255 )
inline

Maps Y deflection to a motor speed range.

*

Parameters
min_outMinimum speed (default -255).
max_outMaximum speed (default 255).

◆ get_x()

int Joystick::get_x ( ) const
inline
Returns
Relative horizontal deflection (-2048 to 2048).

◆ get_y()

int Joystick::get_y ( ) const
inline
Returns
Relative vertical deflection (-2048 to 2048).

◆ is_active()

bool Joystick::is_active ( ) const

Checks if the joystick is currently deflected beyond the deadzone.

Returns
true if either axis is active.

◆ is_z_held()

bool Joystick::is_z_held ( ) const
inline

Check the current physical state of the button.

*

Returns
true if the button is currently held down.

◆ is_z_pressed()

bool Joystick::is_z_pressed ( )

Detects a button press (Falling Edge).

*

Returns
true only on the frame the button is first depressed.

The documentation for this class was generated from the following files: