diff options
| author | Erovia <Erovia@users.noreply.github.com> | 2019-02-15 15:52:04 +0100 |
|---|---|---|
| committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-02-15 06:52:04 -0800 |
| commit | 642f6cf14f2bcc91af61b0d64b4ad0632622dc7a (patch) | |
| tree | 61722ebd3669dd26b8e87d72be7cc33b348e41ea /quantum/rgblight.c | |
| parent | f3bdd436a3e8e37e274fcd1147eb13e05b24fe98 (diff) | |
| download | qmk_firmware-642f6cf14f2bcc91af61b0d64b4ad0632622dc7a.tar.gz qmk_firmware-642f6cf14f2bcc91af61b0d64b4ad0632622dc7a.zip | |
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.c | 36 |
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) { | |||
| 611 | rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); | 611 | rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end) { | ||
| 615 | if (!rgblight_config.enable || start < 0 || start >= end || end > RGBLED_NUM) { return; } | ||
| 616 | |||
| 617 | for (uint8_t i = start; i < end; i++) { | ||
| 618 | led[i].r = r; | ||
| 619 | led[i].g = g; | ||
| 620 | led[i].b = b; | ||
| 621 | } | ||
| 622 | rgblight_set(); | ||
| 623 | wait_ms(1); | ||
| 624 | } | ||
| 625 | |||
| 626 | void rgblight_sethsv_range(uint16_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) { | ||
| 627 | if (!rgblight_config.enable) { return; } | ||
| 628 | |||
| 629 | LED_TYPE tmp_led; | ||
| 630 | sethsv(hue, sat, val, &tmp_led); | ||
| 631 | rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end); | ||
| 632 | } | ||
| 633 | |||
| 634 | void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) { | ||
| 635 | rgblight_setrgb_range(r, g, b, 0 , (uint8_t) RGBLED_NUM/2); | ||
| 636 | } | ||
| 637 | |||
| 638 | void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b) { | ||
| 639 | rgblight_setrgb_range(r, g, b, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM); | ||
| 640 | } | ||
| 641 | |||
| 642 | void rgblight_sethsv_master(uint16_t hue, uint8_t sat, uint8_t val) { | ||
| 643 | rgblight_sethsv_range(hue, sat, val, 0, (uint8_t) RGBLED_NUM/2); | ||
| 644 | } | ||
| 645 | |||
| 646 | void rgblight_sethsv_slave(uint16_t hue, uint8_t sat, uint8_t val) { | ||
| 647 | rgblight_sethsv_range(hue, sat, val, (uint8_t) RGBLED_NUM/2, (uint8_t) RGBLED_NUM); | ||
| 648 | } | ||
| 649 | |||
| 614 | #ifndef RGBLIGHT_CUSTOM_DRIVER | 650 | #ifndef RGBLIGHT_CUSTOM_DRIVER |
| 615 | void rgblight_set(void) { | 651 | void rgblight_set(void) { |
| 616 | if (rgblight_config.enable) { | 652 | if (rgblight_config.enable) { |
