mirror of
https://github.com/qmk/qmk_firmware
synced 2024-11-18 01:46:09 +00:00
Use White channel on RGBW LEDs (#7678)
* Use White channel on RGBW LEDs Co-authored-by: kwerdenker <sebastian.spindler@gmail.com> * Manually apply white channel to array * Move where convert_rgb_to_rgbw is called * Fix type for rgbw led struct * Add changes to Ergodox EZ can revert if deemed necessary * Revert "Add changes to Ergodox EZ" This reverts commitaa44db198d
. * Revert "Fix type for rgbw led struct" This reverts commitc5c744cba0
. * Revert "Move where convert_rgb_to_rgbw is called" This reverts commitcd7f17caf6
. * Revert changes and fix up functions * Enable white channel for Ergodox EZ as well * Only run conversion of rgblight is enabled Co-authored-by: kwerdenker <sebastian.spindler@gmail.com>
This commit is contained in:
parent
a52e55ec09
commit
7ba6456c0b
5 changed files with 33 additions and 4 deletions
|
@ -51,7 +51,13 @@ void rgblight_set(void) {
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RGBW
|
||||
else {
|
||||
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
|
||||
convert_rgb_to_rgbw(&led[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t led_num = RGBLED_NUM;
|
||||
i2c_init();
|
||||
|
|
|
@ -85,3 +85,17 @@ RGB hsv_to_rgb(HSV hsv) {
|
|||
|
||||
return rgb;
|
||||
}
|
||||
|
||||
#ifdef RGBW
|
||||
#ifndef MIN
|
||||
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
void convert_rgb_to_rgbw(LED_TYPE *led) {
|
||||
// Determine lowest value in all three colors, put that into
|
||||
// the white channel and then shift all colors by that amount
|
||||
led->w = MIN(led->r, MIN(led->g, led->b));
|
||||
led->r -= led->w;
|
||||
led->g -= led->w;
|
||||
led->b -= led->w;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -64,5 +64,7 @@ typedef struct PACKED {
|
|||
#endif
|
||||
|
||||
RGB hsv_to_rgb(HSV hsv);
|
||||
|
||||
#ifdef RGBW
|
||||
void convert_rgb_to_rgbw(LED_TYPE *led);
|
||||
#endif
|
||||
#endif // COLOR_H
|
||||
|
|
|
@ -113,7 +113,7 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) {
|
|||
led[i].g = g;
|
||||
led[i].b = b;
|
||||
# ifdef RGBW
|
||||
led[i].w = 0;
|
||||
convert_rgb_to_rgbw(led[i]);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
|
|
@ -611,6 +611,7 @@ void rgblight_set(void) {
|
|||
# endif
|
||||
}
|
||||
}
|
||||
|
||||
# ifdef RGBLIGHT_LED_MAP
|
||||
LED_TYPE led0[RGBLED_NUM];
|
||||
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
|
||||
|
@ -620,6 +621,12 @@ void rgblight_set(void) {
|
|||
# else
|
||||
start_led = led + clipping_start_pos;
|
||||
# endif
|
||||
|
||||
#ifdef RGBW
|
||||
for (uint8_t i = 0; i < num_leds; i++) {
|
||||
convert_rgb_to_rgbw(&start_led[i]);
|
||||
}
|
||||
#endif
|
||||
ws2812_setleds(start_led, num_leds);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue