Arduino Sim Racing Library v1.1.4
|
Base class for all pedals instances. More...
#include <SimRacing.h>
Public Types | |
using | PedalID = SimRacing::Pedal |
Public Member Functions | |
Pedals (AnalogInput *dataPtr, uint8_t nPedals, uint8_t detectPin) | |
virtual void | begin () |
virtual bool | update () |
long | getPosition (PedalID pedal, long rMin=0, long rMax=100) const |
int | getPositionRaw (PedalID pedal) const |
bool | hasPedal (PedalID pedal) const |
int | getNumPedals () const |
bool | positionChanged () const |
void | setCalibration (PedalID pedal, AnalogInput::Calibration cal) |
void | serialCalibration (Stream &iface=Serial) |
bool | isConnected () const |
Static Public Member Functions | |
static String | getPedalName (PedalID pedal) |
Base class for all pedals instances.
Definition at line 276 of file SimRacing.h.
Scoped alias for SimRacing::Pedal
Definition at line 279 of file SimRacing.h.
SimRacing::Pedals::Pedals | ( | AnalogInput * | dataPtr, |
uint8_t | nPedals, | ||
uint8_t | detectPin | ||
) |
Class constructor
dataPtr | pointer to the analog input data managed by the class, stored elsewhere |
nPedals | the number of pedals stored in said data pointer |
detectPin | the digital pin for device detection (high is detected) |
Definition at line 336 of file SimRacing.cpp.
|
virtual |
Initialize the hardware (if necessary)
Reimplemented from SimRacing::Peripheral.
Definition at line 344 of file SimRacing.cpp.
|
inline |
Retrieves the number of pedals handled by the class.
Definition at line 332 of file SimRacing.h.
|
static |
Utility function to get the string name for each pedal.
pedal | the pedal to get the name of |
Definition at line 390 of file SimRacing.cpp.
long SimRacing::Pedals::getPosition | ( | PedalID | pedal, |
long | rMin = 0 , |
||
long | rMax = 100 |
||
) | const |
Retrieves the buffered position for the pedal, rescaled to a nominal range using the calibration values.
By default this is rescaled to an integer percentage.
pedal | the pedal to retrieve position for |
rMin | the minimum output value for the rescaling function |
rMax | the maximum output value for the rescaling function |
Definition at line 370 of file SimRacing.cpp.
int SimRacing::Pedals::getPositionRaw | ( | PedalID | pedal | ) | const |
Retrieves the buffered position for the pedal, ignoring the calibration data.
pedal | the pedal to retrieve position for |
Definition at line 375 of file SimRacing.cpp.
bool SimRacing::Pedals::hasPedal | ( | PedalID | pedal | ) | const |
Checks if a given pedal is present in the class.
pedal | the pedal to check |
Definition at line 380 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 358 of file SimRacing.h.
|
inline |
Checks whether the current pedal positions have changed since the last update.
Definition at line 339 of file SimRacing.h.
void SimRacing::Pedals::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 410 of file SimRacing.cpp.
void SimRacing::Pedals::setCalibration | ( | PedalID | pedal, |
AnalogInput::Calibration | cal | ||
) |
Calibrate a pedal's min/max values for rescaling.
pedal | the pedal to set the calibration of |
cal | the calibration data to set |
Definition at line 384 of file SimRacing.cpp.
|
virtual |
Perform a poll of the hardware to refresh the class state
Implements SimRacing::Peripheral.
Definition at line 348 of file SimRacing.cpp.