Skip to content

Commit b81e317

Browse files
committed
Make API-Demo LED conditional on built-in macro
Should've listened to my hunch earlier: boards without a built-in LED lack the LED_BUILTIN pin macro, which causes compilation tests for those boards to fail. Putting the LED output into a preprocessor guard should fix it.
1 parent 6aa71ad commit b81e317

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

extras/API-Demo/API-Demo.ino

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ uint8_t txData[20] = { 0x00, 0x14, 0x00 };
4949
boolean buttonState = false;
5050

5151
void setup() {
52-
pinMode(LED_BUILTIN, OUTPUT);
53-
digitalWrite(LED_BUILTIN, LOW);
52+
#ifdef LED_BUILTIN
53+
pinMode(LED_BUILTIN, OUTPUT);
54+
digitalWrite(LED_BUILTIN, LOW);
55+
#endif
5456

5557
while (!XInputUSB::connected()) {} // wait for connection
5658
XInputUSB::setRecvCallback(receiveCallback);
@@ -82,8 +84,10 @@ void receiveCallback() {
8284
const int success = XInputUSB::recv(rxData, sizeof(rxData));
8385

8486
if (success > 5 && rxData[0] == 0x00) { // rumble packet
85-
boolean rumbling = (rxData[3] > 0 || rxData[4] > 0 );
86-
digitalWrite(LED_BUILTIN, rumbling);
87+
#ifdef LED_BUILTIN
88+
boolean rumbling = (rxData[3] > 0 || rxData[4] > 0 );
89+
digitalWrite(LED_BUILTIN, rumbling);
90+
#endif
8791
}
8892
}
8993
}

0 commit comments

Comments
 (0)