Arduino Sim Racing Library v1.1.4
|
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 (uint8_t pin, bool invert=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) |
Allows the user to change the stable period of the detector. | |
Used for tracking whether a device is connected to a specific pin and stable.
Definition at line 47 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 56 of file SimRacing.h.
SimRacing::DeviceConnection::DeviceConnection | ( | uint8_t | pin, |
bool | invert = false , |
||
unsigned long | detectTime = 250 |
||
) |
Class constructor.
pin | the pin number being read. Can be 'NOT_A_PIN' to disable. |
invert | whether the input is inverted, so 'LOW' is detected instead of 'HIGH' |
detectTime | the amount of time, in ms, the input must be stable for before it's interpreted as 'detected' |
Definition at line 164 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 228 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 232 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 192 of file SimRacing.cpp.
void SimRacing::DeviceConnection::setStablePeriod | ( | unsigned long | t | ) |
Allows the user to change the stable period of the detector.
t | the amount of time, in ms, the input must be stable for (no changes) before it's interpreted as 'detected' |
Definition at line 236 of file SimRacing.cpp.