Arduino Sim Racing Library v2.0.0
|
Abstract class for all peripherals. More...
#include <SimRacing.h>
Public Member Functions | |
virtual | ~Peripheral () |
Class destructor. | |
virtual void | begin () |
Initialize the hardware (if necessary) | |
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)=0 |
Perform an internal poll of the hardware to refresh the class state. | |
void | setDetectPtr (DeviceConnection *d) |
Sets the pointer to the detector object. | |
Abstract class for all peripherals.
Definition at line 251 of file SimRacing.h.
|
inlinevirtual |
Class destructor.
Definition at line 256 of file SimRacing.h.
|
inlinevirtual |
Initialize the hardware (if necessary)
Reimplemented in SimRacing::AnalogShifter, SimRacing::Handbrake, SimRacing::LogitechShifterG25, SimRacing::LogitechShifterG27, and SimRacing::Pedals.
Definition at line 261 of file SimRacing.h.
bool SimRacing::Peripheral::isConnected | ( | ) | const |
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.
|
protected |
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.
void SimRacing::Peripheral::setStablePeriod | ( | unsigned long | t | ) |
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.
bool SimRacing::Peripheral::update | ( | ) |
Perform a poll of the hardware to refresh the class state.
Definition at line 433 of file SimRacing.cpp.
|
protectedpure virtual |
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 |
Implemented in SimRacing::AnalogShifter, SimRacing::Handbrake, SimRacing::LogitechShifterG25, SimRacing::LogitechShifterG27, and SimRacing::Pedals.