Reads from the Logitech Driving Force shifter (included with the G923 / G920 / G29 wheels) and prints the data over serial.
const int Pin_ShifterX = A0;
const int Pin_ShifterY = A2;
const int Pin_ShifterRev = 2;
const int Pin_ShifterDetect =
SimRacing::UnusedPin;
Pin_ShifterX, Pin_ShifterY,
Pin_ShifterRev,
Pin_ShifterDetect
);
const unsigned long PrintSpeed = 1500;
unsigned long lastPrint = 0;
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("Starting...");
}
void loop() {
if (Serial.read() != -1) {
delay(2000);
}
Serial.print("Shifted into ");
Serial.print(" [");
Serial.print("]");
Serial.print(" - XY: (");
Serial.print(", ");
Serial.print(")");
Serial.println();
lastPrint = millis();
}
else {
if(millis() - lastPrint >= PrintSpeed) {
Serial.print("Currently in ");
Serial.println();
lastPrint = millis();
}
}
}
Header file for the Sim Racing Library.
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 Driving Force shifter.
bool update()
Perform a poll of the hardware to refresh the class state.
static String getGearString(int gear)
Returns a String that represents the given gear.
Gear getGear() const
Returns the currently selected gear.
bool gearChanged() const
Checks whether the current gear has changed since the last update.