mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Show tilt using LEDs by default
This commit is contained in:
parent
c0f0ae4cb9
commit
f05f791841
2 changed files with 7 additions and 5 deletions
|
@ -67,6 +67,7 @@ public:
|
||||||
return HIDUniversal::isReady() && HIDUniversal::VID == STEELSERIES_VID && HIDUniversal::PID == STEELSERIES_SRWS1_PID;
|
return HIDUniversal::isReady() && HIDUniversal::VID == STEELSERIES_VID && HIDUniversal::PID == STEELSERIES_SRWS1_PID;
|
||||||
};
|
};
|
||||||
void setLeds(uint16_t leds);
|
void setLeds(uint16_t leds);
|
||||||
|
SRWS1Data srws1Data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); // Called by the HIDUniversal library
|
void ParseHIDData(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); // Called by the HIDUniversal library
|
||||||
|
@ -76,7 +77,6 @@ private:
|
||||||
setLeds(0);
|
setLeds(0);
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
SRWS1Data srws1Data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,12 +26,12 @@ void loop() {
|
||||||
Usb.Task();
|
Usb.Task();
|
||||||
|
|
||||||
if (srw1.connected()) {
|
if (srw1.connected()) {
|
||||||
#if 1 // Set to 1 in order to show a crazy strobe light effect
|
#if 0 // Set to 1 in order to show a crazy strobe light effect
|
||||||
static uint32_t timer;
|
static uint32_t timer;
|
||||||
if (millis() - timer > 12) {
|
if (millis() - timer > 12) {
|
||||||
timer = millis(); // Reset timer
|
timer = millis(); // Reset timer
|
||||||
static uint16_t leds = 0;
|
|
||||||
|
|
||||||
|
static uint16_t leds = 0;
|
||||||
/*D_PrintHex<uint16_t > (leds, 0x80);
|
/*D_PrintHex<uint16_t > (leds, 0x80);
|
||||||
Serial.println();*/
|
Serial.println();*/
|
||||||
srw1.setLeds(leds); // Update LEDs
|
srw1.setLeds(leds); // Update LEDs
|
||||||
|
@ -41,16 +41,18 @@ void loop() {
|
||||||
leds <<= 1;
|
leds <<= 1;
|
||||||
if (leds == 0x8000) // All are actually turned off, as there is only 15 LEDs
|
if (leds == 0x8000) // All are actually turned off, as there is only 15 LEDs
|
||||||
dirUp = false; // If we have reached the end i.e. all LEDs are off, then change direction
|
dirUp = false; // If we have reached the end i.e. all LEDs are off, then change direction
|
||||||
if (!(leds & 0x8000)) // If last bit is not set set the lowest bit
|
else if (!(leds & 0x8000)) // If last bit is not set set the lowest bit
|
||||||
leds |= 1; // Set lowest bit
|
leds |= 1; // Set lowest bit
|
||||||
} else {
|
} else {
|
||||||
leds >>= 1;
|
leds >>= 1;
|
||||||
if (leds == 0) // Check if all LEDs are off
|
if (leds == 0) // Check if all LEDs are off
|
||||||
dirUp = true; // If all LEDs are off, then repeat the sequence
|
dirUp = true; // If all LEDs are off, then repeat the sequence
|
||||||
if (!(leds & 0x1)) // If last bit is not set set the lowest bit
|
else if (!(leds & 0x1)) // If last bit is not set set the lowest bit
|
||||||
leds |= 1 << 15; // Set top bit
|
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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue