aboutsummaryrefslogtreecommitdiff
path: root/quantum/rgblight.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-11-09 07:51:39 -0800
committerJoel Challis <git@zvecr.com>2019-11-09 15:51:39 +0000
commit60e4921378d879eed110f801328e9642f35fa1e9 (patch)
tree9bb36017ba58e7aedbcfee9db0bba1a3bc466359 /quantum/rgblight.c
parent78205e64a7053746b1491c0d39dbb300a55f3248 (diff)
downloadqmk_firmware-60e4921378d879eed110f801328e9642f35fa1e9.tar.gz
qmk_firmware-60e4921378d879eed110f801328e9642f35fa1e9.zip
Unify RGB and RGBW commands (#7297)
* Fix unicode in comments Co-Authored-By: fauxpark <fauxpark@gmail.com> * Remove separate RGBW implementation for a unified function * Set White to 0 in RGBW LEDs This is just to get this working, later, proper brightness can be handled elsewhere. * Use us instead of nanoseconds(?) since it renders correctly on web * Remove RGBW function from arm/ws2812.h * Remove RGBW function from arm/ws2812.c * Formatting changes * Add doc info
Diffstat (limited to 'quantum/rgblight.c')
-rw-r--r--quantum/rgblight.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index 1c197827f..a4cbe513e 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -126,6 +126,9 @@ void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
126 (*led1).r = r; 126 (*led1).r = r;
127 (*led1).g = g; 127 (*led1).g = g;
128 (*led1).b = b; 128 (*led1).b = b;
129#ifdef RGBW
130 (*led1).w = 0;
131#endif
129} 132}
130 133
131void rgblight_check_config(void) { 134void rgblight_check_config(void) {
@@ -514,6 +517,9 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) {
514 led[i].r = r; 517 led[i].r = r;
515 led[i].g = g; 518 led[i].g = g;
516 led[i].b = b; 519 led[i].b = b;
520#ifdef RGBW
521 led[i].w = 0;
522#endif
517 } 523 }
518 rgblight_set(); 524 rgblight_set();
519} 525}
@@ -526,6 +532,9 @@ void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) {
526 led[index].r = r; 532 led[index].r = r;
527 led[index].g = g; 533 led[index].g = g;
528 led[index].b = b; 534 led[index].b = b;
535#ifdef RGBW
536 led[index].w = 0;
537#endif
529 rgblight_set(); 538 rgblight_set();
530} 539}
531 540
@@ -560,6 +569,9 @@ void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8
560 led[i].r = r; 569 led[i].r = r;
561 led[i].g = g; 570 led[i].g = g;
562 led[i].b = b; 571 led[i].b = b;
572#ifdef RGBW
573 led[i].w = 0;
574#endif
563 } 575 }
564 rgblight_set(); 576 rgblight_set();
565 wait_ms(1); 577 wait_ms(1);
@@ -595,6 +607,9 @@ void rgblight_set(void) {
595 led[i].r = 0; 607 led[i].r = 0;
596 led[i].g = 0; 608 led[i].g = 0;
597 led[i].b = 0; 609 led[i].b = 0;
610# ifdef RGBW
611 led[i].w = 0;
612# endif
598 } 613 }
599 } 614 }
600# ifdef RGBLIGHT_LED_MAP 615# ifdef RGBLIGHT_LED_MAP
@@ -606,11 +621,7 @@ void rgblight_set(void) {
606# else 621# else
607 start_led = led + clipping_start_pos; 622 start_led = led + clipping_start_pos;
608# endif 623# endif
609# ifdef RGBW
610 ws2812_setleds_rgbw(start_led, num_leds);
611# else
612 ws2812_setleds(start_led, num_leds); 624 ws2812_setleds(start_led, num_leds);
613# endif
614} 625}
615#endif 626#endif
616 627
@@ -908,6 +919,9 @@ void rgblight_effect_snake(animation_status_t *anim) {
908 ledp->r = 0; 919 ledp->r = 0;
909 ledp->g = 0; 920 ledp->g = 0;
910 ledp->b = 0; 921 ledp->b = 0;
922# ifdef RGBW
923 ledp->w = 0;
924# endif
911 for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) { 925 for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) {
912 k = pos + j * increment; 926 k = pos + j * increment;
913 if (k > RGBLED_NUM) { 927 if (k > RGBLED_NUM) {
@@ -965,6 +979,9 @@ void rgblight_effect_knight(animation_status_t *anim) {
965 led[i].r = 0; 979 led[i].r = 0;
966 led[i].g = 0; 980 led[i].g = 0;
967 led[i].b = 0; 981 led[i].b = 0;
982# ifdef RGBW
983 led[i].w = 0;
984# endif
968 } 985 }
969 // Determine which LEDs should be lit up 986 // Determine which LEDs should be lit up
970 for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) { 987 for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) {
@@ -976,6 +993,9 @@ void rgblight_effect_knight(animation_status_t *anim) {
976 led[cur].r = 0; 993 led[cur].r = 0;
977 led[cur].g = 0; 994 led[cur].g = 0;
978 led[cur].b = 0; 995 led[cur].b = 0;
996# ifdef RGBW
997 led[cur].w = 0;
998# endif
979 } 999 }
980 } 1000 }
981 rgblight_set(); 1001 rgblight_set();