Skip to content

Commit 5e14a0a

Browse files
committed
Fix G27 shifter pinout
The G27 shifter, although it looks similar to the G25, does *not* have the same pinout (pins 1 and 7 are swapped). This fixes all G27 pinout references throughout the library.
1 parent 4b9b8eb commit 5e14a0a

File tree

4 files changed

+41
-28
lines changed

4 files changed

+41
-28
lines changed

examples/Shifter/LogitechShifterG27/LogitechShifterG27_Joystick/LogitechShifterG27_Joystick.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ const int Pin_ShifterX = A0; // DE-9 pin 4
3737
const int Pin_ShifterY = A2; // DE-9 pin 8
3838

3939
const int Pin_ShifterLatch = 5; // DE-9 pin 3
40-
const int Pin_ShifterClock = 6; // DE-9 pin 7
40+
const int Pin_ShifterClock = 6; // DE-9 pin 1
4141
const int Pin_ShifterData = 7; // DE-9 pin 2
4242

4343
// These pins require extra resistors! If you have made the proper
4444
// connections, change the pin numbers to the ones you're using
45-
const int Pin_ShifterDetect = SimRacing::UnusedPin; // DE-9 pin 1, requires pull-down resistor
45+
const int Pin_ShifterDetect = SimRacing::UnusedPin; // DE-9 pin 7, requires pull-down resistor
4646
const int Pin_ShifterLED = SimRacing::UnusedPin; // DE-9 pin 5, requires 100-120 Ohm series resistor
4747

4848
SimRacing::LogitechShifterG27 shifter(

examples/Shifter/LogitechShifterG27/LogitechShifterG27_Print/LogitechShifterG27_Print.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ const int Pin_ShifterX = A0; // DE-9 pin 4
3333
const int Pin_ShifterY = A2; // DE-9 pin 8
3434

3535
const int Pin_ShifterLatch = 5; // DE-9 pin 3
36-
const int Pin_ShifterClock = 6; // DE-9 pin 7
36+
const int Pin_ShifterClock = 6; // DE-9 pin 1
3737
const int Pin_ShifterData = 7; // DE-9 pin 2
3838

3939
// These pins require extra resistors! If you have made the proper
4040
// connections, change the pin numbers to the ones you're using
41-
const int Pin_ShifterDetect = SimRacing::UnusedPin; // DE-9 pin 1, requires pull-down resistor
41+
const int Pin_ShifterDetect = SimRacing::UnusedPin; // DE-9 pin 7, requires pull-down resistor
4242
const int Pin_ShifterLED = SimRacing::UnusedPin; // DE-9 pin 5, requires 100-120 Ohm series resistor
4343

4444
SimRacing::LogitechShifterG27 shifter(

src/SimRacing.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,40 @@ LogitechShifter CreateShieldObject<LogitechShifter, 2>() {
7272
return CreateShieldObject<LogitechShifter, 1>();
7373
}
7474

75-
/**
76-
* Helper function to create either a LogitechShifterG27 or LogitechShifterG25
77-
* object using the v2 shifter shield pinout, as both use the same pins.
78-
*/
79-
template<class T>
80-
static T CreateShieldShifter() {
81-
// Power (VCC): DE-9 pin 9, bridged to DE-9 pin 1
75+
template<>
76+
LogitechShifterG27 CreateShieldObject<LogitechShifterG27, 2>() {
77+
// Power (VCC): DE-9 pin 9, bridged to DE-9 pin 7
8278
// Ground (GND): DE-9 pin 6
8379

8480
const PinNum Pin_X_Wiper = A1; // DE-9 pin 4
8581
const PinNum Pin_Y_Wiper = A0; // DE-9 pin 8
8682
const PinNum Pin_DataOut = 14; // DE-9 pin 2
8783

8884
const PinNum Pin_Latch = 10; // DE-9 pin 3, aka chip select, requires 10k Ohm pull-up
89-
const PinNum Pin_Clock = A2; // DE-9 pin 7, should have 470 Ohm resistor to prevent shorts
85+
const PinNum Pin_Clock = 15; // DE-9 pin 1, should have 470 Ohm resistor to prevent shorts
9086

91-
const PinNum Pin_Detect = 15; // DE-9 pin 1, requires 10k Ohm pull-down
87+
const PinNum Pin_Detect = A2; // DE-9 pin 7, requires 10k Ohm pull-down
9288
const PinNum Pin_LED = 16; // DE-9 pin 5, requires 100-120 Ohm series resistor
9389

94-
return T(Pin_X_Wiper, Pin_Y_Wiper, Pin_Latch, Pin_Clock, Pin_DataOut, Pin_Detect, Pin_LED);
95-
}
96-
97-
template<>
98-
LogitechShifterG27 CreateShieldObject<LogitechShifterG27, 2>() {
99-
return CreateShieldShifter<LogitechShifterG27>();
90+
return LogitechShifterG27(Pin_X_Wiper, Pin_Y_Wiper, Pin_Latch, Pin_Clock, Pin_DataOut, Pin_Detect, Pin_LED);
10091
}
10192

10293
template<>
10394
LogitechShifterG25 CreateShieldObject<LogitechShifterG25, 2>() {
104-
return CreateShieldShifter<LogitechShifterG25>();
95+
// Power (VCC): DE-9 pin 9, bridged to DE-9 pin 1
96+
// Ground (GND): DE-9 pin 6
97+
98+
const PinNum Pin_X_Wiper = A1; // DE-9 pin 4
99+
const PinNum Pin_Y_Wiper = A0; // DE-9 pin 8
100+
const PinNum Pin_DataOut = 14; // DE-9 pin 2
101+
102+
const PinNum Pin_Latch = 10; // DE-9 pin 3, aka chip select, requires 10k Ohm pull-up
103+
const PinNum Pin_Clock = A2; // DE-9 pin 7, should have 470 Ohm resistor to prevent shorts
104+
105+
const PinNum Pin_Detect = 15; // DE-9 pin 1, requires 10k Ohm pull-down
106+
const PinNum Pin_LED = 16; // DE-9 pin 5, requires 100-120 Ohm series resistor
107+
108+
return LogitechShifterG25(Pin_X_Wiper, Pin_Y_Wiper, Pin_Latch, Pin_Clock, Pin_DataOut, Pin_Detect, Pin_LED);
105109
}
106110
#endif // ATmega32U4 for shield functions
107111

src/SimRacing.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -986,9 +986,9 @@ namespace SimRacing {
986986
* @param pinX analog input pin for the X axis, DE-9 pin 4
987987
* @param pinY analog input pin for the Y axis, DE-9 pin 8
988988
* @param pinLatch digital output pin to pulse to latch data, DE-9 pin 3
989-
* @param pinClock digital output pin to pulse as a clock, DE-9 pin 7
989+
* @param pinClock digital output pin to pulse as a clock, DE-9 pin 1
990990
* @param pinData digital input pin to use for reading data, DE-9 pin 2
991-
* @param pinDetect the digital input pin for device detection, DE-9 pin 1.
991+
* @param pinDetect the digital input pin for device detection, DE-9 pin 7.
992992
* Requires a pull-down resistor.
993993
* @param pinLed digital output pin to light the power LED on connection,
994994
* DE-9 pin 5. Requires a 100 Ohm series resistor.
@@ -997,7 +997,7 @@ namespace SimRacing {
997997
PinNum pinX, PinNum pinY,
998998
PinNum pinLatch, PinNum pinClock, PinNum pinData,
999999
PinNum pinDetect = UnusedPin,
1000-
PinNum pinLed = UnusedPin
1000+
PinNum pinLed = UnusedPin
10011001
);
10021002

10031003
/**
@@ -1086,7 +1086,7 @@ namespace SimRacing {
10861086

10871087
// Pins for the shift register interface
10881088
PinNum pinLatch; ///< Pin to pulse to latch data, DE-9 pin 3
1089-
PinNum pinClock; ///< Pin to pulse as a clock, DE-9 pin 7
1089+
PinNum pinClock; ///< Pin to pulse as a clock, DE-9 pin 1
10901090
PinNum pinData; ///< Pin to use for reading data, DE-9 pin 2
10911091

10921092
// Generic I/O pins
@@ -1114,14 +1114,23 @@ namespace SimRacing {
11141114
class LogitechShifterG25 : public LogitechShifterG27 {
11151115
public:
11161116
/**
1117-
* @copydoc LogitechShifterG27::LogitechShifterG27(PinNum, PinNum,
1118-
* PinNum, PinNum, PinNum, PinNum, PinNum)
1119-
*/
1117+
* Class constructor
1118+
*
1119+
* @param pinX analog input pin for the X axis, DE-9 pin 4
1120+
* @param pinY analog input pin for the Y axis, DE-9 pin 8
1121+
* @param pinLatch digital output pin to pulse to latch data, DE-9 pin 3
1122+
* @param pinClock digital output pin to pulse as a clock, DE-9 pin 7
1123+
* @param pinData digital input pin to use for reading data, DE-9 pin 2
1124+
* @param pinDetect the digital input pin for device detection, DE-9 pin 1.
1125+
* Requires a pull-down resistor.
1126+
* @param pinLed digital output pin to light the power LED on connection,
1127+
* DE-9 pin 5. Requires a 100 Ohm series resistor.
1128+
*/
11201129
LogitechShifterG25(
11211130
PinNum pinX, PinNum pinY,
11221131
PinNum pinLatch, PinNum pinClock, PinNum pinData,
11231132
PinNum pinDetect = UnusedPin,
1124-
PinNum pinLed = UnusedPin
1133+
PinNum pinLed = UnusedPin
11251134
);
11261135

11271136
/** @copydoc LogitechShifterG27::begin() */

0 commit comments

Comments
 (0)