Arduino Sim Racing Library v1.1.5
|
Base class for all shifter instances. More...
#include <SimRacing.h>
Public Member Functions | |
Shifter (int8_t min, int8_t max) | |
Class constructor. | |
int8_t | getGear () const |
Returns the currently selected gear. | |
char | getGearChar () const |
Returns a character that represents the current gear. | |
String | getGearString () const |
Returns a String that represents the current gear. | |
bool | gearChanged () const |
Checks whether the current gear has changed since the last update. | |
int8_t | getGearMin () |
Retrieves the minimum possible gear index. | |
int8_t | getGearMax () |
Retrieves the maximum possible gear index. | |
virtual void | begin () |
Initialize the hardware (if necessary) | |
virtual bool | update ()=0 |
Perform a poll of the hardware to refresh the class state. | |
virtual bool | isConnected () const |
Check if the device is physically connected to the board. | |
Static Public Member Functions | |
static char | getGearChar (int gear) |
Returns a character that represents the given gear. | |
static String | getGearString (int gear) |
Returns a String that represents the given gear. | |
Protected Attributes | |
const int8_t | MinGear |
the lowest selectable gear | |
const int8_t | MaxGear |
the highest selectable gear | |
int8_t | currentGear |
index of the current gear | |
bool | changed |
whether the gear has changed since the previous update | |
Base class for all shifter instances.
Definition at line 457 of file SimRacing.h.
SimRacing::Shifter::Shifter | ( | int8_t | min, |
int8_t | max ) |
Class constructor.
min | the lowest gear possible |
max | the highest gear possible |
Definition at line 602 of file SimRacing.cpp.
|
inlinevirtualinherited |
Initialize the hardware (if necessary)
Reimplemented in SimRacing::AnalogShifter, SimRacing::Handbrake, and SimRacing::Pedals.
Definition at line 254 of file SimRacing.h.
|
inline |
Checks whether the current gear has changed since the last update.
Definition at line 519 of file SimRacing.h.
|
inline |
Returns the currently selected gear.
Will either be reverse (-1), neutral (0), or the current gear indexed at 1 (1st gear is 1, 2nd gear is 2, etc.).
Definition at line 475 of file SimRacing.h.
char SimRacing::Shifter::getGearChar | ( | ) | const |
Returns a character that represents the current gear.
Definition at line 624 of file SimRacing.cpp.
|
static |
Returns a character that represents the given gear.
'r' for reverse, 'n' for neutral, or the number of the current gear.
gear | the gear index to get the representation for |
Definition at line 606 of file SimRacing.cpp.
|
inline |
Retrieves the maximum possible gear index.
Definition at line 533 of file SimRacing.h.
|
inline |
Retrieves the minimum possible gear index.
Definition at line 526 of file SimRacing.h.
String SimRacing::Shifter::getGearString | ( | ) | const |
Returns a String that represents the current gear.
Definition at line 665 of file SimRacing.cpp.
|
static |
Returns a String that represents the given gear.
"reverse" for reverse, "neutral" for neutral, and then "1st", "2nd", "3rd", and so on.
gear | the gear index to get the representation for |
Definition at line 628 of file SimRacing.cpp.
|
inlinevirtualinherited |
Check if the device is physically connected to the board.
That means it is both present and detected long enough to be considered 'stable'.
Reimplemented in SimRacing::AnalogShifter, SimRacing::Handbrake, and SimRacing::Pedals.
Definition at line 264 of file SimRacing.h.
|
pure virtualinherited |
Perform a poll of the hardware to refresh the class state.
Implemented in SimRacing::AnalogShifter, SimRacing::Handbrake, and SimRacing::Pedals.
|
protected |
whether the gear has changed since the previous update
Definition at line 540 of file SimRacing.h.
|
protected |
index of the current gear
Definition at line 539 of file SimRacing.h.
|
protected |
the highest selectable gear
Definition at line 537 of file SimRacing.h.
|
protected |
the lowest selectable gear
Definition at line 536 of file SimRacing.h.