Analog joystick as directional input.
More...
#include <InputHardware.hpp>
|
| | 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)
|
| |
Analog joystick as directional input.
- Note
- Despite using an analog device, input is reported as digital
Definition at line 495 of file InputHardware.hpp.
◆ 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
-
| xAxisPin | ADC-capable pin for the horizontal axis |
| yAxisPin | ADC-capable pin for the vertical axis |
| up | Input number assigned to the "up" direction |
| down | Input number assigned to the "down" direction |
| left | Input number assigned to the "left" direction |
| right | Input number assigned to the "right" direction |
| xCenter | Center position of the horizontal axis in the [0,255] range |
| yCenter | Center position of the vertical axis in the [0,255] range |
| xDeadZone | A 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. |
| yDeadZone | A 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. |
| xAxisReverse | If true, the lower reading means pushed right If false, the lower reading means pushed left |
| yAxisReverse | If true, the lower reading means pushed down If false, the lower reading means pushed up |
◆ 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] | state | At 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.
◆ AxisReverse
| bool AnalogJoystickInput::AxisReverse |
|
protected |
◆ down
| uint8_t AnalogJoystickInput::down |
|
protected |
◆ downAdcReading
| int AnalogJoystickInput::downAdcReading |
|
protected |
◆ left
| uint8_t AnalogJoystickInput::left |
|
protected |
◆ leftAdcReading
| int AnalogJoystickInput::leftAdcReading |
|
protected |
◆ right
| uint8_t AnalogJoystickInput::right |
|
protected |
◆ rightAdcReading
| int AnalogJoystickInput::rightAdcReading |
|
protected |
◆ up
| uint8_t AnalogJoystickInput::up |
|
protected |
◆ upAdcReading
| int AnalogJoystickInput::upAdcReading |
|
protected |
◆ xAxisPin
◆ xAxisReverse
| bool AnalogJoystickInput::xAxisReverse |
|
protected |
◆ yAxisPin
The documentation for this class was generated from the following file: