Arduino Sim Racing Library v2.0.0
|
Used for tracking whether a device is connected to a specific pin and stable. More...
#include <SimRacing.h>
Public Types | |
enum | ConnectionState { Disconnected , PlugIn , Connected , Unplug } |
The state of the connection, whether it is connected, disconnected, and everywhere in-between. More... | |
Public Member Functions | |
DeviceConnection (PinNum pin, bool activeLow=false, unsigned long detectTime=250) | |
Class constructor. | |
void | poll () |
Checks if the pin detects a connection. | |
ConnectionState | getState () const |
Retrieves the current ConnectionState from the instance. | |
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'. | |
Used for tracking whether a device is connected to a specific pin and stable.
Definition at line 59 of file SimRacing.h.
The state of the connection, whether it is connected, disconnected, and everywhere in-between.
This is the type returned by the main 'getState()' method.
Definition at line 68 of file SimRacing.h.
SimRacing::DeviceConnection::DeviceConnection | ( | PinNum | pin, |
bool | activeLow = false, | ||
unsigned long | detectTime = 250 ) |
Class constructor.
pin | the pin number being read. Can be 'UnusedPin' to disable. |
activeLow | whether the device is detected on a high signal (false, default) or a low signal (true) |
detectTime | the amount of time, in ms, the input must be stable for before it's interpreted as 'detected' |
Definition at line 260 of file SimRacing.cpp.
DeviceConnection::ConnectionState SimRacing::DeviceConnection::getState | ( | ) | const |
Retrieves the current ConnectionState from the instance.
This allows functions to check the same connection state multiple times without having to re-poll.
Definition at line 326 of file SimRacing.cpp.
bool SimRacing::DeviceConnection::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 330 of file SimRacing.cpp.
void SimRacing::DeviceConnection::poll | ( | ) |
Checks if the pin detects a connection.
This polls the input and checks for whether it has been connected sufficiently long enough to be deemed "stable".
Definition at line 290 of file SimRacing.cpp.
void SimRacing::DeviceConnection::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 334 of file SimRacing.cpp.