Arduino Sim Racing Library v2.0.0
|
Interface with analog handbrakes that use hall effect sensors. More...
#include <SimRacing.h>
Public Member Functions | |
Handbrake (PinNum pinAx) | |
Class constructor. | |
virtual void | begin () |
Initializes the pin for reading from the handbrake. | |
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 | update () |
Perform a poll of the hardware to refresh the class state. | |
bool | isConnected () const |
Check if the device is physically connected to the board. | |
void | setStablePeriod (unsigned long t) |
Set how long the detection pin must be stable for before the device is considered to be 'connected'. | |
Protected Member Functions | |
virtual bool | updateState (bool connected) |
Perform an internal poll of the hardware to refresh the class state. | |
void | setDetectPtr (DeviceConnection *d) |
Sets the pointer to the detector object. | |
Interface with analog handbrakes that use hall effect sensors.
Definition at line 771 of file SimRacing.h.
SimRacing::Handbrake::Handbrake | ( | PinNum | pinAx | ) |
Class constructor.
pinAx | analog pin number for the handbrake axis |
Definition at line 1669 of file SimRacing.cpp.
|
virtual |
Initializes the pin for reading from the handbrake.
Reimplemented from SimRacing::Peripheral.
Definition at line 1675 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 1701 of file SimRacing.cpp.
int SimRacing::Handbrake::getPositionRaw | ( | ) | const |
Retrieves the buffered position for the handbrake, ignoring the calibration data.
Definition at line 1705 of file SimRacing.cpp.
|
inherited |
Check if the device is physically connected to the board.
That means it is both present and detected long enough to be considered 'stable'.
Definition at line 446 of file SimRacing.cpp.
|
inline |
Checks whether the handbrake's position has changed since the last update.
Definition at line 811 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 1714 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 1709 of file SimRacing.cpp.
|
protectedinherited |
Sets the pointer to the detector object.
The detector object is used to check if the peripheral is connected to the microcontroller. The object is polled on every update.
Although the detector instance is accessed via the Peripheral class, it is the responsibility of the dervied class to store the DeviceConnection object and manage its lifetime.
d | pointer to the detector object |
Definition at line 456 of file SimRacing.cpp.
|
inherited |
Set how long the detection pin must be stable for before the device is considered to be 'connected'.
t | the amount of time, in ms, the input must be stable for (no changes) before it's interpreted as 'detected' |
Definition at line 460 of file SimRacing.cpp.
|
inherited |
Perform a poll of the hardware to refresh the class state.
Definition at line 433 of file SimRacing.cpp.
|
protectedvirtual |
Perform an internal poll of the hardware to refresh the class state.
This function is called from within the public update() in order to refresh the cached state of the peripheral. It needs to be defined in every derived class. This function is the only place where the cached device state should be changed.
connected | the state of the device connection |
Implements SimRacing::Peripheral.
Definition at line 1679 of file SimRacing.cpp.