code cleanup
This commit is contained in:
+7
-9
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "hyperx_elite2.h"
|
||||
|
||||
static bool sending = false;
|
||||
static absolute_time_t lastSend;
|
||||
static absolute_time_t lastRead;
|
||||
static bool backlight = false;
|
||||
@@ -42,10 +41,10 @@ void rgb_task(uint8_t dev_addr) {
|
||||
// the RGB protocol used by HyperX sends individual key RGB data in
|
||||
// multiple packets
|
||||
// the code here will determine if we are in the middle of sending
|
||||
// updated color info (sending==true) and continue to send the next
|
||||
// updated color info (packets_sent>0) and continue to send the next
|
||||
// packet if so at a rate of one packet every 20ms
|
||||
// otherwise, wait 1s before sending the next set of color packets
|
||||
if (sending) {
|
||||
// otherwise, wait 0.5s before sending the next set of color packets
|
||||
if (packets_sent>0) {
|
||||
if ( absolute_time_diff_us(lastSend, get_absolute_time()) >= 20000) {
|
||||
if( backlight) {
|
||||
send_color(dev_addr, 0x20, 0x20, 0x20);
|
||||
@@ -140,8 +139,8 @@ static void send_color(uint8_t dev_addr, uint8_t red, uint8_t green, uint8_t blu
|
||||
packets_sent++;
|
||||
}
|
||||
} else {
|
||||
// mark that sending of a full round of color packets completed
|
||||
sending=false;
|
||||
// a full round of color packets completed, reset packets to 0
|
||||
packets_sent=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,9 +160,8 @@ static void send_initial(uint8_t dev_addr) {
|
||||
|
||||
if (tuh_hid_set_report(dev_addr, 0, 0, HID_REPORT_TYPE_FEATURE, buf, BUF_SIZE))
|
||||
{
|
||||
// we have begun sending packets, so set flag to continue sending
|
||||
// packets at regular intervals
|
||||
sending = true;
|
||||
// we have begun sending packets, so indicate first packet was sent
|
||||
// remaining packets will be sent at regular intervals
|
||||
packets_sent=1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user