Interface with the Logitech pedals (Gas, Brake, and Clutch)
More...
#include <SimRacing.h>
|
| LogitechPedals (PinNum pinGas, PinNum pinBrake, PinNum pinClutch, PinNum pinDetect=UnusedPin) |
| Class constructor.
|
|
void | setCalibration (AnalogInput::Calibration gasCal, AnalogInput::Calibration brakeCal, AnalogInput::Calibration clutchCal) |
| Sets the calibration data (min/max) for the pedals.
|
|
void | setCalibration (PedalID pedal, AnalogInput::Calibration cal) |
| Calibrate a pedal's min/max values for rescaling.
|
|
virtual void | begin () |
| Initialize the hardware (if necessary)
|
|
virtual bool | update () |
| Perform a poll of the hardware to refresh the class state.
|
|
long | 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.
|
|
int | getPositionRaw (PedalID pedal) const |
| Retrieves the buffered position for the pedal, ignoring the calibration data.
|
|
bool | hasPedal (PedalID pedal) const |
| Checks if a given pedal is present in the class.
|
|
int | getNumPedals () const |
| Retrieves the number of pedals handled by the class.
|
|
bool | positionChanged () const |
| Checks whether the current pedal positions have changed since the last update.
|
|
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.
|
|
|
static String | getPedalName (PedalID pedal) |
| Utility function to get the string name for each pedal.
|
|
◆ PedalID
◆ LogitechPedals()
Class constructor.
- Parameters
-
pinGas | the analog pin for the gas pedal potentiometer |
pinBrake | the analog pin for the brake pedal potentiometer |
pinClutch | the analog pin for the clutch pedal potentiometer |
pinDetect | the digital pin for device detection (high is detected) |
Definition at line 582 of file SimRacing.cpp.
◆ begin()
void SimRacing::Pedals::begin |
( |
| ) |
|
|
virtualinherited |
◆ getNumPedals()
int SimRacing::Pedals::getNumPedals |
( |
| ) |
const |
|
inlineinherited |
Retrieves the number of pedals handled by the class.
- Returns
- the number of pedals handled by the class
Definition at line 344 of file SimRacing.h.
◆ getPedalName()
String SimRacing::Pedals::getPedalName |
( |
PedalID | pedal | ) |
|
|
staticinherited |
Utility function to get the string name for each pedal.
- Parameters
-
pedal | the pedal to get the name of |
- Returns
- the name of the pedal, as a String
Definition at line 407 of file SimRacing.cpp.
◆ getPosition()
long SimRacing::Pedals::getPosition |
( |
PedalID | pedal, |
|
|
long | rMin = 0, |
|
|
long | rMax = 100 ) const |
|
inherited |
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.
- Parameters
-
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 |
- Returns
- the pedal position, buffered and rescaled
- Examples
- PedalsJoystick.ino, and PedalsPrint.ino.
Definition at line 387 of file SimRacing.cpp.
◆ getPositionRaw()
int SimRacing::Pedals::getPositionRaw |
( |
PedalID | pedal | ) |
const |
|
inherited |
Retrieves the buffered position for the pedal, ignoring the calibration data.
- Parameters
-
pedal | the pedal to retrieve position for |
- Returns
- the axis position, buffered
Definition at line 392 of file SimRacing.cpp.
◆ hasPedal()
bool SimRacing::Pedals::hasPedal |
( |
PedalID | pedal | ) |
const |
|
inherited |
◆ isConnected()
bool SimRacing::Pedals::isConnected |
( |
| ) |
const |
|
inlinevirtualinherited |
Check if the device is physically connected to the board.
That means it is both present and detected long enough to be considered 'stable'.
- Returns
- 'true' if the device is connected, 'false' otherwise
Reimplemented from SimRacing::Peripheral.
Definition at line 370 of file SimRacing.h.
◆ positionChanged()
bool SimRacing::Pedals::positionChanged |
( |
| ) |
const |
|
inlineinherited |
Checks whether the current pedal positions have changed since the last update.
- Returns
- 'true' if position has changed, 'false' otherwise
- Examples
- PedalsJoystick.ino.
Definition at line 351 of file SimRacing.h.
◆ serialCalibration()
void SimRacing::Pedals::serialCalibration |
( |
Stream & | iface = Serial | ) |
|
|
inherited |
Runs an interactive calibration tool using the serial interface.
- Parameters
-
iface | the serial interface to send and receive prompts. Defaults to Serial (CDC USB on most boards). |
- Examples
- PedalsPrint.ino.
Definition at line 427 of file SimRacing.cpp.
◆ setCalibration() [1/2]
Calibrate a pedal's min/max values for rescaling.
- Parameters
-
pedal | the pedal to set the calibration of |
cal | the calibration data to set |
Definition at line 401 of file SimRacing.cpp.
◆ setCalibration() [2/2]
Sets the calibration data (min/max) for the pedals.
- Parameters
-
gasCal | the calibration data for the gas pedal |
brakeCal | the calibration data for the brake pedal |
clutchCal | the calibration data for the clutch pedal |
Definition at line 574 of file SimRacing.cpp.
◆ update()
bool SimRacing::Pedals::update |
( |
| ) |
|
|
virtualinherited |
The documentation for this class was generated from the following files: