summaryrefslogtreecommitdiffstats
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
authorErovia <Erovia@users.noreply.github.com>2019-02-15 15:52:04 +0100
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-02-15 15:52:04 +0100
commit642f6cf14f2bcc91af61b0d64b4ad0632622dc7a (patch)
tree61722ebd3669dd26b8e87d72be7cc33b348e41ea /quantum/rgblight.c
parentf3bdd436a3e8e37e274fcd1147eb13e05b24fe98 (diff)
downloadqmk_firmware-642f6cf14f2bcc91af61b0d64b4ad0632622dc7a.tar.gz
qmk_firmware-642f6cf14f2bcc91af61b0d64b4ad0632622dc7a.tar.xz
Add support for using ranges for RGB (#4981)
* Add support for using ranges for RGB This patch adds support for controlling continuous ranges of RGB LEDs. Helper functions for split boards are also available. * RGB Range: Use hardware-platform agnostic wait
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 30f7d7528..d42a1d2e5 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -611,6 +611,42 @@ void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) {
rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index);
}
+void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end) {
+ if (!rgblight_config.enable || start < 0 || start >= end || end > RGBLED_NUM) { return; }
+
+ for (uint8_t i = start; i < end; i++) {
+ led[i].r = r;
+ led[i].g = g;
+ led[i].b = b;
+ }
+ rgblight_set();
+ wait_ms(1);
+}
+
+void rgblight_sethsv_range(uint16_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) {
+ if (!rgblight_config.enable) { return; }
+
+ LED_TYPE tmp_led;
+ sethsv(hue, sat, val, &tmp_led);
+ rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end);
+}
+
+void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) {
+ rgblight_setrgb_range(r, g, b, 0 , (uint8_t) RGBLED_NUM/2);
+}
+
+void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b) {
+ rgblight_setrgb_range(r, g, b, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM);
+}
+
+void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val) {
+ rgblight_sethsv_range(hue, sat, val, 0, (uint8_t) RGBLED_NUM/2);
+}
+
+void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val) {
+ rgblight_sethsv_range(hue, sat, val, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM);
+}
+
#ifndef RGBLIGHT_CUSTOM_DRIVER
void rgblight_set(void) {
if (rgblight_config.enable) {