Arduino Sim Racing Library v1.1.4
Loading...
Searching...
No Matches
SimRacing::Handbrake Class Reference

Interface with analog handbrakes that use hall effect sensors. More...

#include <SimRacing.h>

Inheritance diagram for SimRacing::Handbrake:
SimRacing::Peripheral

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.
 

Detailed Description

Interface with analog handbrakes that use hall effect sensors.

Examples
HandbrakeJoystick.ino, and HandbrakePrint.ino.

Definition at line 676 of file SimRacing.h.

Constructor & Destructor Documentation

◆ Handbrake()

SimRacing::Handbrake::Handbrake ( uint8_t  pinAx,
uint8_t  detectPin = NOT_A_PIN 
)

Class constructor.

Parameters
pinAxanalog pin number for the handbrake axis
detectPinthe digital pin for device detection (high is detected)

Definition at line 990 of file SimRacing.cpp.

Member Function Documentation

◆ begin()

void SimRacing::Handbrake::begin ( )
virtual

Initializes the pin for reading from the handbrake.

Reimplemented from SimRacing::Peripheral.

Examples
HandbrakeJoystick.ino, and HandbrakePrint.ino.

Definition at line 997 of file SimRacing.cpp.

◆ getPosition()

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)

Parameters
rMinthe minimum output value
rMaxthe maximum output value
Returns
the handbrake position, buffered and rescaled
Examples
HandbrakeJoystick.ino, and HandbrakePrint.ino.

Definition at line 1016 of file SimRacing.cpp.

◆ getPositionRaw()

int SimRacing::Handbrake::getPositionRaw ( ) const

Retrieves the buffered position for the handbrake, ignoring the calibration data.

Returns
the handbrake position, buffered

Definition at line 1020 of file SimRacing.cpp.

◆ isConnected()

bool SimRacing::Handbrake::isConnected ( ) const
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'.

Returns
'true' if the device is connected, 'false' otherwise

Reimplemented from SimRacing::Peripheral.

Definition at line 733 of file SimRacing.h.

◆ positionChanged()

bool SimRacing::Handbrake::positionChanged ( ) const
inline

Checks whether the handbrake's position has changed since the last update.

Returns
'true' if the position has changed, 'false' otherwise
Examples
HandbrakeJoystick.ino.

Definition at line 724 of file SimRacing.h.

◆ serialCalibration()

void SimRacing::Handbrake::serialCalibration ( Stream &  iface = Serial)

Runs an interactive calibration tool using the serial interface.

Parameters
ifacethe serial interface to send and receive prompts. Defaults to Serial (CDC USB on most boards).
Examples
HandbrakePrint.ino.

Definition at line 1029 of file SimRacing.cpp.

◆ setCalibration()

void SimRacing::Handbrake::setCalibration ( AnalogInput::Calibration  newCal)

Calibrate the axis' min/max values for rescaling.

Parameters
newCalthe calibration data struct to pass

Definition at line 1024 of file SimRacing.cpp.

◆ update()

bool SimRacing::Handbrake::update ( )
virtual

Polls the handbrake to update its position.

Returns
'true' if the gear has changed, 'false' otherwise

Implements SimRacing::Peripheral.

Examples
HandbrakeJoystick.ino, and HandbrakePrint.ino.

Definition at line 1001 of file SimRacing.cpp.


The documentation for this class was generated from the following files: