diff options
Diffstat (limited to 'keyboards/wilba_tech/wt_rgb_backlight.c')
-rw-r--r-- | keyboards/wilba_tech/wt_rgb_backlight.c | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/keyboards/wilba_tech/wt_rgb_backlight.c b/keyboards/wilba_tech/wt_rgb_backlight.c index 936286c2ee..e52d002060 100644 --- a/keyboards/wilba_tech/wt_rgb_backlight.c +++ b/keyboards/wilba_tech/wt_rgb_backlight.c @@ -60,7 +60,6 @@ #if defined(RGB_BACKLIGHT_DAWN60) #include "ws2812.h" -rgb_led_t g_ws2812_leds[WS2812_LED_TOTAL]; #endif #include "progmem.h" @@ -1011,6 +1010,9 @@ void backlight_update_pwm_buffers(void) driver = 0; } #else +#if defined(RGB_BACKLIGHT_DAWN60) + ws2812_flush(); +#endif is31fl3731_update_pwm_buffers( 0 ); is31fl3731_update_pwm_buffers( 1 ); is31fl3731_update_led_control_registers( 0 ); @@ -1037,10 +1039,7 @@ void backlight_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) if( index < IS31FL3731_LED_COUNT ) { is31fl3731_set_color( index, red, green, blue ); } else { - g_ws2812_leds[index - IS31FL3731_LED_COUNT].r = red; - g_ws2812_leds[index - IS31FL3731_LED_COUNT].g = green; - g_ws2812_leds[index - IS31FL3731_LED_COUNT].b = blue; - ws2812_setleds(g_ws2812_leds, WS2812_LED_TOTAL); + ws2812_set_color( index - IS31FL3731_LED_COUNT, red, green, blue ); } #else is31fl3731_set_color( index, red, green, blue ); @@ -1075,12 +1074,7 @@ void backlight_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) } #elif defined(RGB_BACKLIGHT_DAWN60) is31fl3731_set_color_all( red, green, blue ); - for (uint8_t i = 0; i < WS2812_LED_TOTAL; i++) { - g_ws2812_leds[i].r = red; - g_ws2812_leds[i].g = green; - g_ws2812_leds[i].b = blue; - } - ws2812_setleds(g_ws2812_leds, WS2812_LED_TOTAL); + ws2812_set_color_all( red, green, blue ); #else is31fl3731_set_color_all( red, green, blue ); #endif @@ -1264,16 +1258,16 @@ void backlight_effect_all_off(void) // Solid color void backlight_effect_solid_color(void) { - HSV hsv = { .h = g_config.color_1.h, .s = g_config.color_1.s, .v = g_config.brightness }; - RGB rgb = hsv_to_rgb( hsv ); + hsv_t hsv = { .h = g_config.color_1.h, .s = g_config.color_1.s, .v = g_config.brightness }; + rgb_t rgb = hsv_to_rgb( hsv ); backlight_set_color_all( rgb.r, rgb.g, rgb.b ); } // alphas = color1, mods = color2 void backlight_effect_alphas_mods(void) { - RGB rgb1 = hsv_to_rgb( (HSV){ .h = g_config.color_1.h, .s = g_config.color_1.s, .v = g_config.brightness } ); - RGB rgb2 = hsv_to_rgb( (HSV){ .h = g_config.color_2.h, .s = g_config.color_2.s, .v = g_config.brightness } ); + rgb_t rgb1 = hsv_to_rgb( (hsv_t){ .h = g_config.color_1.h, .s = g_config.color_1.s, .v = g_config.brightness } ); + rgb_t rgb2 = hsv_to_rgb( (hsv_t){ .h = g_config.color_2.h, .s = g_config.color_2.s, .v = g_config.brightness } ); bool is_alpha = false; for ( int row = 0; row < MATRIX_ROWS; row++ ) { @@ -1325,7 +1319,7 @@ void backlight_effect_alphas_mods(void) } } #if defined(RGB_BACKLIGHT_DAWN60) - for (int i = 0; i < WS2812_LED_TOTAL; i++) { + for (int i = 0; i < WS2812_LED_COUNT; i++) { if ((RGB_UNDERGLOW_ALPHA_TOP_START <= i && i <= RGB_UNDERGLOW_ALPHA_TOP_END) || (RGB_UNDERGLOW_ALPHA_BOT_START <= i && i <= RGB_UNDERGLOW_ALPHA_BOT_END)) { backlight_set_color(i + IS31FL3731_LED_COUNT, rgb1.r, rgb1.g, rgb1.b); @@ -1358,8 +1352,8 @@ void backlight_effect_gradient_up_down(void) int16_t s2 = g_config.color_2.s; int16_t deltaS = ( s2 - s1 ) / 4; - HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; - RGB rgb; + hsv_t hsv = { .h = 0, .s = 255, .v = g_config.brightness }; + rgb_t rgb; Point point; for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) { @@ -1396,8 +1390,8 @@ void backlight_effect_raindrops(bool initialize) int16_t s2 = g_config.color_2.s; int16_t deltaS = ( s2 - s1 ) / 4; - HSV hsv; - RGB rgb; + hsv_t hsv; + rgb_t rgb; // Change one LED every tick uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % BACKLIGHT_LED_COUNT : 255; @@ -1437,8 +1431,8 @@ void backlight_effect_cycle_all(void) #endif offset2 = (offset2<=63) ? (63-offset2) : 0; - HSV hsv = { .h = offset+offset2, .s = 255, .v = g_config.brightness }; - RGB rgb = hsv_to_rgb( hsv ); + hsv_t hsv = { .h = offset+offset2, .s = 255, .v = g_config.brightness }; + rgb_t rgb = hsv_to_rgb( hsv ); backlight_set_color( i, rgb.r, rgb.g, rgb.b ); } } @@ -1446,8 +1440,8 @@ void backlight_effect_cycle_all(void) void backlight_effect_cycle_left_right(void) { uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF; - HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; - RGB rgb; + hsv_t hsv = { .h = 0, .s = 255, .v = g_config.brightness }; + rgb_t rgb; Point point; for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) { @@ -1473,8 +1467,8 @@ void backlight_effect_cycle_left_right(void) void backlight_effect_cycle_up_down(void) { uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF; - HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; - RGB rgb; + hsv_t hsv = { .h = 0, .s = 255, .v = g_config.brightness }; + rgb_t rgb; Point point; for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) { @@ -1499,8 +1493,8 @@ void backlight_effect_cycle_up_down(void) void backlight_effect_jellybean_raindrops( bool initialize ) { - HSV hsv; - RGB rgb; + hsv_t hsv; + rgb_t rgb; // Change one LED every tick uint8_t led_to_change = ( g_tick & 0x000 ) == 0 ? rand() % BACKLIGHT_LED_COUNT : 255; @@ -1525,8 +1519,8 @@ void backlight_effect_jellybean_raindrops( bool initialize ) void backlight_effect_cycle_radial1(void) { uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF; - HSV hsv = { .h = 0, .s = 255, .v = g_config.brightness }; - RGB rgb; + hsv_t hsv = { .h = 0, .s = 255, .v = g_config.brightness }; + rgb_t rgb; Point point; for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) { @@ -1543,8 +1537,8 @@ void backlight_effect_cycle_radial2(void) { uint8_t offset = ( g_tick << g_config.effect_speed ) & 0xFF; - HSV hsv = { .h = 0, .s = g_config.color_1.s, .v = g_config.brightness }; - RGB rgb; + hsv_t hsv = { .h = 0, .s = g_config.color_1.s, .v = g_config.brightness }; + rgb_t rgb; Point point; for ( int i=0; i<BACKLIGHT_LED_COUNT; i++ ) { @@ -1565,10 +1559,10 @@ void backlight_effect_cycle_radial2(void) #if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_M10_C) void backlight_effect_custom_colors(void) { - RGB rgb; + rgb_t rgb; for ( uint8_t i = 0; i < RGB_BACKLIGHT_CUSTOM_COLORS_COUNT; i++ ) { - HSV hsv = { .h = g_config.custom_color[i].h, .s = g_config.custom_color[i].s, .v = g_config.brightness }; + hsv_t hsv = { .h = g_config.custom_color[i].h, .s = g_config.custom_color[i].s, .v = g_config.brightness }; rgb = hsv_to_rgb( hsv ); uint8_t led; map_row_column_to_led( 0, i, &led ); @@ -1586,8 +1580,8 @@ void backlight_effect_custom_colors(void) void backlight_effect_indicators_set_colors( uint8_t index, HS color ) { - HSV hsv = { .h = color.h, .s = color.s, .v = g_config.brightness }; - RGB rgb = hsv_to_rgb( hsv ); + hsv_t hsv = { .h = color.h, .s = color.s, .v = g_config.brightness }; + rgb_t rgb = hsv_to_rgb( hsv ); if ( index == 254 ) { backlight_set_color_all( rgb.r, rgb.g, rgb.b ); |