@@ -1157,6 +1157,7 @@ LogitechShifterG27::LogitechShifterG27(
11571157 pinLed (sanitizePin(pinLed))
11581158{
11591159 this ->pinModesSet = false ;
1160+ this ->setPowerLED (1 ); // power LED on by default
11601161 this ->buttonStates = this ->previousButtons = 0x0000 ; // zero all button data
11611162
11621163 // using the calibration values from my own G27 shifter
@@ -1197,10 +1198,10 @@ void LogitechShifterG27::setPinModes(bool enabled) {
11971198 digitalWrite (this ->pinClock , LOW);
11981199 pinMode (this ->pinClock , OUTPUT);
11991200
1200- // if we have an LED pin, set it to output and turn
1201- // the LED on ( active low)
1201+ // if we have an LED pin, set it to output and write the
1202+ // commanded state (inverted, as the LED is active- low)
12021203 if (this ->pinLed != UnusedPin) {
1203- digitalWrite (this ->pinLed , LOW );
1204+ digitalWrite (this ->pinLed , !( this -> ledState ) );
12041205 pinMode (this ->pinLed , OUTPUT);
12051206 }
12061207 }
@@ -1229,6 +1230,10 @@ void LogitechShifterG27::setPinModes(bool enabled) {
12291230 this ->pinModesSet = enabled;
12301231}
12311232
1233+ void LogitechShifterG27::setPowerLED (bool state) {
1234+ this ->ledState = state;
1235+ }
1236+
12321237uint16_t LogitechShifterG27::readShiftRegisters () {
12331238 // if the pin outputs are not set, quit (none pressed)
12341239 if (!this ->pinModesSet ) return 0x0000 ;
@@ -1293,6 +1298,10 @@ bool LogitechShifterG27::updateState(bool connected) {
12931298 this ->setPinModes (1 );
12941299 }
12951300
1301+ if (this ->pinLed != UnusedPin) {
1302+ digitalWrite (this ->pinLed , !(this ->ledState )); // active low
1303+ }
1304+
12961305 const uint16_t data = this ->readShiftRegisters ();
12971306 this ->cacheButtons (data);
12981307 changed |= this ->buttonsChanged ();
0 commit comments