Arduino Sim Racing Library v1.1.4
|
Interface with analog handbrakes that use hall effect sensors. More...
#include <SimRacing.h>
Public Member Functions | |
Handbrake (uint8_t pinAx, uint8_t detectPin=NOT_A_PIN) | |
Class constructor. | |
virtual void | begin () |
Initializes the pin for reading from the handbrake. | |
virtual bool | update () |
Polls the handbrake to update its position. | |
long | getPosition (long rMin=0, long rMax=100) const |
Retrieves the buffered position for the handbrake axis, rescaled to a nominal range using the calibration values. | |
int | getPositionRaw () const |
Retrieves the buffered position for the handbrake, ignoring the calibration data. | |
bool | positionChanged () const |
Checks whether the handbrake's position has changed since the last update. | |
void | setCalibration (AnalogInput::Calibration newCal) |
Calibrate the axis' min/max values for rescaling. | |
void | serialCalibration (Stream &iface=Serial) |
Runs an interactive calibration tool using the serial interface. | |
bool | isConnected () const |
Check if the device is physically connected to the board. | |
Interface with analog handbrakes that use hall effect sensors.
Definition at line 676 of file SimRacing.h.
SimRacing::Handbrake::Handbrake | ( | uint8_t | pinAx, |
uint8_t | detectPin = NOT_A_PIN |
||
) |
Class constructor.
pinAx | analog pin number for the handbrake axis |
detectPin | the digital pin for device detection (high is detected) |
Definition at line 990 of file SimRacing.cpp.
|
virtual |
Initializes the pin for reading from the handbrake.
Reimplemented from SimRacing::Peripheral.
Definition at line 997 of file SimRacing.cpp.
long SimRacing::Handbrake::getPosition | ( | long | rMin = 0 , |
long | rMax = 100 |
||
) | const |
Retrieves the buffered position for the handbrake axis, rescaled to a nominal range using the calibration values.
By default this is rescaled to an integer percentage (0 - 100)
rMin | the minimum output value |
rMax | the maximum output value |
Definition at line 1016 of file SimRacing.cpp.
int SimRacing::Handbrake::getPositionRaw | ( | ) | const |
Retrieves the buffered position for the handbrake, ignoring the calibration data.
Definition at line 1020 of file SimRacing.cpp.
|
inlinevirtual |
Check if the device is physically connected to the board.
That means it is both present and detected long enough to be considered 'stable'.
Reimplemented from SimRacing::Peripheral.
Definition at line 733 of file SimRacing.h.
|
inline |
Checks whether the handbrake's position has changed since the last update.
Definition at line 724 of file SimRacing.h.
void SimRacing::Handbrake::serialCalibration | ( | Stream & | iface = Serial | ) |
Runs an interactive calibration tool using the serial interface.
iface | the serial interface to send and receive prompts. Defaults to Serial (CDC USB on most boards). |
Definition at line 1029 of file SimRacing.cpp.
void SimRacing::Handbrake::setCalibration | ( | AnalogInput::Calibration | newCal | ) |
Calibrate the axis' min/max values for rescaling.
newCal | the calibration data struct to pass |
Definition at line 1024 of file SimRacing.cpp.
|
virtual |
Polls the handbrake to update its position.
Implements SimRacing::Peripheral.
Definition at line 1001 of file SimRacing.cpp.