Arduino Sim Racing Library v1.1.5
|
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 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 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 | invert = false, | ||
unsigned long | detectTime = 250 ) |
Class constructor.
pin | the pin number being read. Can be 'UnusedPin' 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 179 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 245 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 249 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 209 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 253 of file SimRacing.cpp.