32const int Pin_ShifterX = A0;
33const int Pin_ShifterY = A2;
35const int Pin_ShifterLatch = 5;
36const int Pin_ShifterClock = 6;
37const int Pin_ShifterData = 7;
52 Pin_ShifterX, Pin_ShifterY,
53 Pin_ShifterLatch, Pin_ShifterClock, Pin_ShifterData,
54 Pin_ShifterLED, Pin_ShifterDetect
62void printConditional(
bool state,
char pressed);
63void printButton(ShifterButton button,
char pressed);
66const unsigned long PrintSpeed = 1500;
67unsigned long lastPrint = 0;
78 Serial.println(
"Logitech G25 Starting...");
83 if (Serial.read() != -1) {
85 shifter.serialCalibrationSequential();
89 bool dataChanged = shifter.
update();
98 if (millis() - lastPrint >= PrintSpeed) {
104void printConditional(
bool state,
char pressed) {
106 Serial.print(pressed);
113void printButton(ShifterButton button,
char pressed) {
114 bool state = shifter.getButton(button);
115 printConditional(state, pressed);
120 if (shifter.inSequentialMode()) {
122 printConditional(shifter.getShiftUp(),
'+');
123 printConditional(shifter.getShiftDown(),
'-');
128 Serial.print(
"H: [");
134 Serial.print(
" - XY: (");
141 printButton(ShifterButton::DPAD_LEFT,
'<');
142 printButton(ShifterButton::DPAD_UP,
'^');
143 printButton(ShifterButton::DPAD_DOWN,
'v');
144 printButton(ShifterButton::DPAD_RIGHT,
'>');
148 printButton(ShifterButton::BUTTON_NORTH,
'N');
149 printButton(ShifterButton::BUTTON_SOUTH,
'S');
150 printButton(ShifterButton::BUTTON_EAST,
'E');
151 printButton(ShifterButton::BUTTON_WEST,
'W');
155 printButton(ShifterButton::BUTTON_1,
'1');
156 printButton(ShifterButton::BUTTON_2,
'2');
157 printButton(ShifterButton::BUTTON_3,
'3');
158 printButton(ShifterButton::BUTTON_4,
'4');
162 lastPrint = millis();
Header file for the Sim Racing Library.
const PinNum UnusedPin
Dummy pin number signaling that a pin is unused and can be safely ignored.
void serialCalibration(Stream &iface=Serial)
Runs an interactive calibration tool using the serial interface.
int getPositionRaw(Axis ax) const
Retrieves the buffered position for the analog axis.
virtual void begin()
Initializes the hardware pins for reading the gear states.
Interface with the Logitech G25 shifter.
Button
Enumeration of button values.
bool update()
Perform a poll of the hardware to refresh the class state.
static char getGearChar(int gear)
Returns a character that represents the given gear.