From 5a968f5ae624af74896c1d41f78da2ea08d0dfca Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Thu, 1 Jul 2021 22:04:58 -0500 Subject: [PATCH] Fix leds_per_update issue in QMK controller --- .../QMKOpenRGBController/QMKOpenRGBController.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Controllers/QMKOpenRGBController/QMKOpenRGBController.cpp b/Controllers/QMKOpenRGBController/QMKOpenRGBController.cpp index 00d76452..879629af 100644 --- a/Controllers/QMKOpenRGBController/QMKOpenRGBController.cpp +++ b/Controllers/QMKOpenRGBController/QMKOpenRGBController.cpp @@ -415,13 +415,14 @@ void QMKOpenRGBController::DirectModeSetSingleLED(unsigned int led, unsigned cha void QMKOpenRGBController::DirectModeSetLEDs(std::vector colors, unsigned int leds_count) { - unsigned int leds_sent = 0; + unsigned int leds_sent = 0; + unsigned int tmp_leds_per_update = leds_per_update; while (leds_sent < leds_count) { - if ((leds_count - leds_sent) < leds_per_update) + if ((leds_count - leds_sent) < tmp_leds_per_update) { - leds_per_update = leds_count - leds_sent; + tmp_leds_per_update = leds_count - leds_sent; } unsigned char usb_buf[QMK_OPENRGB_PACKET_SIZE]; @@ -437,9 +438,9 @@ void QMKOpenRGBController::DirectModeSetLEDs(std::vector colors, unsig usb_buf[0x00] = 0x00; usb_buf[0x01] = QMK_OPENRGB_DIRECT_MODE_SET_LEDS; usb_buf[0x02] = leds_sent; - usb_buf[0x03] = leds_per_update; + usb_buf[0x03] = tmp_leds_per_update; - for (unsigned int led_idx = 0; led_idx < leds_per_update; led_idx++) + for (unsigned int led_idx = 0; led_idx < tmp_leds_per_update; led_idx++) { usb_buf[(led_idx * 3) + 4] = RGBGetRValue(colors[led_idx + leds_sent]); usb_buf[(led_idx * 3) + 5] = RGBGetGValue(colors[led_idx + leds_sent]); @@ -448,6 +449,6 @@ void QMKOpenRGBController::DirectModeSetLEDs(std::vector colors, unsig hid_write(dev, usb_buf, 65); - leds_sent += leds_per_update; + leds_sent += tmp_leds_per_update; } }