mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Toggle LED behaviour using the select button
This commit is contained in:
parent
92e24534e5
commit
400f9c0dcf
1 changed files with 25 additions and 27 deletions
|
@ -28,7 +28,10 @@ void loop() {
|
|||
Usb.Task();
|
||||
|
||||
if (srw1.connected()) {
|
||||
#if 0 // Set to 1 in order to show a crazy strobe light effect
|
||||
if (printTilt) { // Show tilt angle using the LEDs
|
||||
srw1.setLeds(1 << map(srw1.srws1Data.tilt, -1800, 1800, 0, 14)); // Turn on a LED according to tilt value
|
||||
Serial.println(srw1.srws1Data.tilt);
|
||||
} else { // Show strobe light effect
|
||||
static uint32_t timer;
|
||||
if (millis() - timer > 12) {
|
||||
timer = millis(); // Reset timer
|
||||
|
@ -52,9 +55,7 @@ void loop() {
|
|||
leds |= 1 << 15; // Set top bit
|
||||
}
|
||||
}
|
||||
#else
|
||||
srw1.setLeds(1 << map(srw1.srws1Data.tilt, -1800, 1800, 0, 14)); // Turn on a LED according to tilt value
|
||||
#endif
|
||||
}
|
||||
|
||||
if (srw1.srws1Data.leftTrigger) {
|
||||
Serial.print(F("L2: "));
|
||||
|
@ -68,7 +69,7 @@ void loop() {
|
|||
if (srw1.buttonClickState.select) {
|
||||
srw1.buttonClickState.select = 0; // Clear event
|
||||
Serial.println(F("Select"));
|
||||
printTilt = !printTilt; // Print tilt value
|
||||
printTilt = !printTilt; // Print tilt value & show it using the LEDs as well
|
||||
}
|
||||
|
||||
if (srw1.buttonClickState.back) {
|
||||
|
@ -174,9 +175,6 @@ void loop() {
|
|||
Serial.println();
|
||||
break;
|
||||
}
|
||||
|
||||
if (printTilt)
|
||||
Serial.println(srw1.srws1Data.tilt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue