OpenSourceSimWheelESP32
Open-source wireless steering wheel/button box for ESP32 boards
Loading...
Searching...
No Matches
AnalogJoystickInput Class Reference

Analog joystick as directional input. More...

#include <InputHardware.hpp>

Public Member Functions

 AnalogJoystickInput (ADC_GPIO xAxisPin, ADC_GPIO yAxisPin, InputNumber up, InputNumber down, InputNumber left, InputNumber right, uint8_t xCenter=127, uint8_t yCenter=127, uint8_t xDeadZone=63, uint8_t yDeadZone=63, bool xAxisReverse=false, bool yAxisReverse=false)
 Construct a new Analog Joystick Input object.
 
virtual void read (uint128_t &state) override
 Read the current state of the inputs (pressed or released)
 
- Public Member Functions inherited from DigitalInput

Protected Attributes

ADC_GPIO xAxisPin
 
ADC_GPIO yAxisPin
 
uint8_t up
 
uint8_t down
 
uint8_t left
 
uint8_t right
 
int upAdcReading
 
int downAdcReading
 
int leftAdcReading
 
int rightAdcReading
 
bool xAxisReverse
 
bool AxisReverse
 

Detailed Description

Analog joystick as directional input.

Note
Despite using an analog device, input is reported as digital

Definition at line 495 of file InputHardware.hpp.

Constructor & Destructor Documentation

◆ AnalogJoystickInput()

AnalogJoystickInput::AnalogJoystickInput ( ADC_GPIO xAxisPin,
ADC_GPIO yAxisPin,
InputNumber up,
InputNumber down,
InputNumber left,
InputNumber right,
uint8_t xCenter = 127,
uint8_t yCenter = 127,
uint8_t xDeadZone = 63,
uint8_t yDeadZone = 63,
bool xAxisReverse = false,
bool yAxisReverse = false )

Construct a new Analog Joystick Input object.

Parameters
xAxisPinADC-capable pin for the horizontal axis
yAxisPinADC-capable pin for the vertical axis
upInput number assigned to the "up" direction
downInput number assigned to the "down" direction
leftInput number assigned to the "left" direction
rightInput number assigned to the "right" direction
xCenterCenter position of the horizontal axis in the [0,255] range
yCenterCenter position of the vertical axis in the [0,255] range
xDeadZoneA dead zone in the range [0,127] for the horizontal axis. Extreme values will not work properly. Out of range values will be trimmed to 127.
yDeadZoneA dead zone in the range [0,127] for the vertical axis. Extreme values will not work properly. Out of range values will be trimmed to 127.
xAxisReverseIf true, the lower reading means pushed right If false, the lower reading means pushed left
yAxisReverseIf true, the lower reading means pushed down If false, the lower reading means pushed up

Member Function Documentation

◆ read()

virtual void AnalogJoystickInput::read ( uint128_t & state)
overridevirtual

Read the current state of the inputs (pressed or released)

Warning
This function must not set or clear any bit outside of the input bitmask in the return value.
Parameters
[in,out]stateAt call, state of all inputs as recorded in the previous iteration. Whether the current state is unknown, state must be kept untouched. At return, new state of the inputs.

Implements DigitalInput.

Member Data Documentation

◆ AxisReverse

bool AnalogJoystickInput::AxisReverse
protected

Definition at line 509 of file InputHardware.hpp.

◆ down

uint8_t AnalogJoystickInput::down
protected

Definition at line 501 of file InputHardware.hpp.

◆ downAdcReading

int AnalogJoystickInput::downAdcReading
protected

Definition at line 505 of file InputHardware.hpp.

◆ left

uint8_t AnalogJoystickInput::left
protected

Definition at line 502 of file InputHardware.hpp.

◆ leftAdcReading

int AnalogJoystickInput::leftAdcReading
protected

Definition at line 506 of file InputHardware.hpp.

◆ right

uint8_t AnalogJoystickInput::right
protected

Definition at line 503 of file InputHardware.hpp.

◆ rightAdcReading

int AnalogJoystickInput::rightAdcReading
protected

Definition at line 507 of file InputHardware.hpp.

◆ up

uint8_t AnalogJoystickInput::up
protected

Definition at line 500 of file InputHardware.hpp.

◆ upAdcReading

int AnalogJoystickInput::upAdcReading
protected

Definition at line 504 of file InputHardware.hpp.

◆ xAxisPin

ADC_GPIO AnalogJoystickInput::xAxisPin
protected

Definition at line 498 of file InputHardware.hpp.

◆ xAxisReverse

bool AnalogJoystickInput::xAxisReverse
protected

Definition at line 508 of file InputHardware.hpp.

◆ yAxisPin

ADC_GPIO AnalogJoystickInput::yAxisPin
protected

Definition at line 499 of file InputHardware.hpp.


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