diff options
Diffstat (limited to 'quantum/rgb_matrix')
-rw-r--r-- | quantum/rgb_matrix/animations/jellybean_raindrops_anim.h | 11 | ||||
-rw-r--r-- | quantum/rgb_matrix/animations/pixel_fractal_anim.h | 6 | ||||
-rw-r--r-- | quantum/rgb_matrix/animations/pixel_rain_anim.h | 10 | ||||
-rw-r--r-- | quantum/rgb_matrix/post_config.h | 29 | ||||
-rw-r--r-- | quantum/rgb_matrix/rgb_matrix.c | 10 | ||||
-rw-r--r-- | quantum/rgb_matrix/rgb_matrix.h | 5 | ||||
-rw-r--r-- | quantum/rgb_matrix/rgb_matrix_drivers.c | 208 |
7 files changed, 164 insertions, 115 deletions
diff --git a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h index 6bde60053b..5d3df1059e 100644 --- a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h @@ -10,17 +10,16 @@ static void jellybean_raindrops_set_color(int i, effect_params_t* params) { } bool JELLYBEAN_RAINDROPS(effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); if (!params->init) { // Change one LED every tick, make sure speed is not 0 if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) { jellybean_raindrops_set_color(random8_max(RGB_MATRIX_LED_COUNT), params); } - return false; - } - - RGB_MATRIX_USE_LIMITS(led_min, led_max); - for (int i = led_min; i < led_max; i++) { - jellybean_raindrops_set_color(i, params); + } else { + for (int i = led_min; i < led_max; i++) { + jellybean_raindrops_set_color(i, params); + } } return rgb_matrix_check_finished_leds(led_max); } diff --git a/quantum/rgb_matrix/animations/pixel_fractal_anim.h b/quantum/rgb_matrix/animations/pixel_fractal_anim.h index 875b4ceb3d..4cd1d9b861 100644 --- a/quantum/rgb_matrix/animations/pixel_fractal_anim.h +++ b/quantum/rgb_matrix/animations/pixel_fractal_anim.h @@ -7,7 +7,11 @@ RGB_MATRIX_EFFECT(PIXEL_FRACTAL) # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static bool PIXEL_FRACTAL(effect_params_t* params) { -# define MID_COL MATRIX_COLS / 2 +# if MATRIX_COLS < 2 +# define MID_COL 1 +# else +# define MID_COL MATRIX_COLS / 2 +# endif static bool led[MATRIX_ROWS][MID_COL]; static uint32_t wait_timer = 0; diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h index 9d63f451e2..26cd73b578 100644 --- a/quantum/rgb_matrix/animations/pixel_rain_anim.h +++ b/quantum/rgb_matrix/animations/pixel_rain_anim.h @@ -16,13 +16,9 @@ static bool PIXEL_RAIN(effect_params_t* params) { if (!HAS_ANY_FLAGS(g_led_config.flags[led_index], params->flags)) { return; } - if (random8() & 2) { - rgb_matrix_set_color(led_index, 0, 0, 0); - } else { - HSV hsv = {random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}; - RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - rgb_matrix_set_color(led_index, rgb.r, rgb.g, rgb.b); - } + HSV hsv = (random8() & 2) ? (HSV){0, 0, 0} : (HSV){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}; + RGB rgb = rgb_matrix_hsv_to_rgb(hsv); + rgb_matrix_set_color(led_index, rgb.r, rgb.g, rgb.b); wait_timer = g_rgb_timer + interval(); } diff --git a/quantum/rgb_matrix/post_config.h b/quantum/rgb_matrix/post_config.h new file mode 100644 index 0000000000..7162c8679b --- /dev/null +++ b/quantum/rgb_matrix/post_config.h @@ -0,0 +1,29 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +// clang-format off + +// framebuffer +#if defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) || \ + defined(ENABLE_RGB_MATRIX_DIGITAL_RAIN) +# define RGB_MATRIX_FRAMEBUFFER_EFFECTS +#endif + +// reactive +#if defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE) || \ + defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE) || \ + defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || \ + defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) || \ + defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || \ + defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) || \ + defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || \ + defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) || \ + defined(ENABLE_RGB_MATRIX_SPLASH) || \ + defined(ENABLE_RGB_MATRIX_MULTISPLASH) || \ + defined(ENABLE_RGB_MATRIX_SOLID_SPLASH) || \ + defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || \ + defined(ENABLE_RGB_MATRIX_SOLID_MULTISPLASH) +# define RGB_MATRIX_KEYPRESSES +#endif diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 1f3912cf7e..96be615162 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -19,8 +19,13 @@ #include "rgb_matrix.h" #include "progmem.h" #include "eeprom.h" +#include "eeconfig.h" +#include "keyboard.h" +#include "sync_timer.h" +#include "debug.h" #include <string.h> #include <math.h> +#include <stdlib.h> #include <lib/lib8tion/lib8tion.h> @@ -428,7 +433,10 @@ void rgb_matrix_task(void) { case RENDERING: rgb_task_render(effect); if (effect) { - rgb_matrix_indicators(); + // Only run the basic indicators in the last render iteration (default there are 5 iterations) + if (rgb_effect_params.iter == RGB_MATRIX_LED_PROCESS_MAX_ITERATIONS) { + rgb_matrix_indicators(); + } rgb_matrix_indicators_advanced(&rgb_effect_params); } break; diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 9ea248b66d..38040fb0cc 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -22,7 +22,7 @@ #include <stdbool.h> #include "rgb_matrix_types.h" #include "color.h" -#include "quantum.h" +#include "keyboard.h" #ifdef IS31FL3731 # include "is31fl3731.h" @@ -49,8 +49,9 @@ #endif #ifndef RGB_MATRIX_LED_PROCESS_LIMIT -# define RGB_MATRIX_LED_PROCESS_LIMIT (RGB_MATRIX_LED_COUNT + 4) / 5 +# define RGB_MATRIX_LED_PROCESS_LIMIT ((RGB_MATRIX_LED_COUNT + 4) / 5) #endif +#define RGB_MATRIX_LED_PROCESS_MAX_ITERATIONS ((RGB_MATRIX_LED_COUNT + RGB_MATRIX_LED_PROCESS_LIMIT - 1) / RGB_MATRIX_LED_PROCESS_LIMIT) #if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT # if defined(RGB_MATRIX_SPLIT) diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index d66fc801dd..695ecc78a4 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -15,6 +15,7 @@ */ #include "rgb_matrix.h" +#include "util.h" /* Each driver needs to define the struct * const rgb_matrix_driver_t rgb_matrix_driver; @@ -37,13 +38,13 @@ static void init(void) { i2c_init(); # if defined(IS31FL3731) - IS31FL3731_init(DRIVER_ADDR_1); + is31fl3731_init(DRIVER_ADDR_1); # if defined(DRIVER_ADDR_2) - IS31FL3731_init(DRIVER_ADDR_2); + is31fl3731_init(DRIVER_ADDR_2); # if defined(DRIVER_ADDR_3) - IS31FL3731_init(DRIVER_ADDR_3); + is31fl3731_init(DRIVER_ADDR_3); # if defined(DRIVER_ADDR_4) - IS31FL3731_init(DRIVER_ADDR_4); + is31fl3731_init(DRIVER_ADDR_4); # endif # endif # endif @@ -52,58 +53,58 @@ static void init(void) { # if !defined(DRIVER_SYNC_1) # define DRIVER_SYNC_1 0 # endif - IS31FL3733_init(DRIVER_ADDR_1, DRIVER_SYNC_1); + is31fl3733_init(DRIVER_ADDR_1, DRIVER_SYNC_1); # if defined(DRIVER_ADDR_2) # if !defined(DRIVER_SYNC_2) # define DRIVER_SYNC_2 0 # endif - IS31FL3733_init(DRIVER_ADDR_2, DRIVER_SYNC_2); + is31fl3733_init(DRIVER_ADDR_2, DRIVER_SYNC_2); # if defined(DRIVER_ADDR_3) # if !defined(DRIVER_SYNC_3) # define DRIVER_SYNC_3 0 # endif - IS31FL3733_init(DRIVER_ADDR_3, DRIVER_SYNC_3); + is31fl3733_init(DRIVER_ADDR_3, DRIVER_SYNC_3); # if defined(DRIVER_ADDR_4) # if !defined(DRIVER_SYNC_4) # define DRIVER_SYNC_4 0 # endif - IS31FL3733_init(DRIVER_ADDR_4, DRIVER_SYNC_4); + is31fl3733_init(DRIVER_ADDR_4, DRIVER_SYNC_4); # endif # endif # endif # elif defined(IS31FL3736) - IS31FL3736_init(DRIVER_ADDR_1); + is31fl3736_init(DRIVER_ADDR_1); # if defined(DRIVER_ADDR_2) - IS31FL3736_init(DRIVER_ADDR_2); + is31fl3736_init(DRIVER_ADDR_2); # if defined(DRIVER_ADDR_3) - IS31FL3736_init(DRIVER_ADDR_3); + is31fl3736_init(DRIVER_ADDR_3); # if defined(DRIVER_ADDR_4) - IS31FL3736_init(DRIVER_ADDR_4); + is31fl3736_init(DRIVER_ADDR_4); # endif # endif # endif # elif defined(IS31FL3737) - IS31FL3737_init(DRIVER_ADDR_1); + is31fl3737_init(DRIVER_ADDR_1); # if defined(DRIVER_ADDR_2) - IS31FL3737_init(DRIVER_ADDR_2); + is31fl3737_init(DRIVER_ADDR_2); # if defined(DRIVER_ADDR_3) - IS31FL3737_init(DRIVER_ADDR_3); + is31fl3737_init(DRIVER_ADDR_3); # if defined(DRIVER_ADDR_4) - IS31FL3737_init(DRIVER_ADDR_4); + is31fl3737_init(DRIVER_ADDR_4); # endif # endif # endif # elif defined(IS31FL3741) - IS31FL3741_init(DRIVER_ADDR_1); + is31fl3741_init(DRIVER_ADDR_1); # if defined(DRIVER_ADDR_2) - IS31FL3741_init(DRIVER_ADDR_2); + is31fl3741_init(DRIVER_ADDR_2); # if defined(DRIVER_ADDR_3) - IS31FL3741_init(DRIVER_ADDR_3); + is31fl3741_init(DRIVER_ADDR_3); # if defined(DRIVER_ADDR_4) - IS31FL3741_init(DRIVER_ADDR_4); + is31fl3741_init(DRIVER_ADDR_4); # endif # endif # endif @@ -121,13 +122,13 @@ static void init(void) { # endif # elif defined(CKLED2001) - CKLED2001_init(DRIVER_ADDR_1); + ckled2001_init(DRIVER_ADDR_1); # if defined(DRIVER_ADDR_2) - CKLED2001_init(DRIVER_ADDR_2); + ckled2001_init(DRIVER_ADDR_2); # if defined(DRIVER_ADDR_3) - CKLED2001_init(DRIVER_ADDR_3); + ckled2001_init(DRIVER_ADDR_3); # if defined(DRIVER_ADDR_4) - CKLED2001_init(DRIVER_ADDR_4); + ckled2001_init(DRIVER_ADDR_4); # endif # endif # endif @@ -138,79 +139,79 @@ static void init(void) { // This only caches it for later # if defined(IS31FL3731) - IS31FL3731_set_led_control_register(index, enabled, enabled, enabled); + is31fl3731_set_led_control_register(index, enabled, enabled, enabled); # elif defined(IS31FL3733) - IS31FL3733_set_led_control_register(index, enabled, enabled, enabled); + is31fl3733_set_led_control_register(index, enabled, enabled, enabled); # elif defined(IS31FL3736) - IS31FL3736_set_led_control_register(index, enabled, enabled, enabled); + is31fl3736_set_led_control_register(index, enabled, enabled, enabled); # elif defined(IS31FL3737) - IS31FL3737_set_led_control_register(index, enabled, enabled, enabled); + is31fl3737_set_led_control_register(index, enabled, enabled, enabled); # elif defined(IS31FL3741) - IS31FL3741_set_led_control_register(index, enabled, enabled, enabled); + is31fl3741_set_led_control_register(index, enabled, enabled, enabled); # elif defined(IS31FLCOMMON) IS31FL_RGB_set_scaling_buffer(index, enabled, enabled, enabled); # elif defined(CKLED2001) - CKLED2001_set_led_control_register(index, enabled, enabled, enabled); + ckled2001_set_led_control_register(index, enabled, enabled, enabled); # endif } // This actually updates the LED drivers # if defined(IS31FL3731) - IS31FL3731_update_led_control_registers(DRIVER_ADDR_1, 0); + is31fl3731_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3731_update_led_control_registers(DRIVER_ADDR_2, 1); + is31fl3731_update_led_control_registers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3731_update_led_control_registers(DRIVER_ADDR_3, 2); + is31fl3731_update_led_control_registers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3731_update_led_control_registers(DRIVER_ADDR_4, 3); + is31fl3731_update_led_control_registers(DRIVER_ADDR_4, 3); # endif # endif # endif # elif defined(IS31FL3733) - IS31FL3733_update_led_control_registers(DRIVER_ADDR_1, 0); + is31fl3733_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3733_update_led_control_registers(DRIVER_ADDR_2, 1); + is31fl3733_update_led_control_registers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3733_update_led_control_registers(DRIVER_ADDR_3, 2); + is31fl3733_update_led_control_registers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3733_update_led_control_registers(DRIVER_ADDR_4, 3); + is31fl3733_update_led_control_registers(DRIVER_ADDR_4, 3); # endif # endif # endif # elif defined(IS31FL3736) - IS31FL3736_update_led_control_registers(DRIVER_ADDR_1, 0); + is31fl3736_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3736_update_led_control_registers(DRIVER_ADDR_2, 1); + is31fl3736_update_led_control_registers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3736_update_led_control_registers(DRIVER_ADDR_3, 2); + is31fl3736_update_led_control_registers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3736_update_led_control_registers(DRIVER_ADDR_4, 3); + is31fl3736_update_led_control_registers(DRIVER_ADDR_4, 3); # endif # endif # endif # elif defined(IS31FL3737) - IS31FL3737_update_led_control_registers(DRIVER_ADDR_1, 0); + is31fl3737_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3737_update_led_control_registers(DRIVER_ADDR_2, 1); + is31fl3737_update_led_control_registers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3737_update_led_control_registers(DRIVER_ADDR_3, 2); + is31fl3737_update_led_control_registers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3737_update_led_control_registers(DRIVER_ADDR_4, 3); + is31fl3737_update_led_control_registers(DRIVER_ADDR_4, 3); # endif # endif # endif # elif defined(IS31FL3741) - IS31FL3741_update_led_control_registers(DRIVER_ADDR_1, 0); + is31fl3741_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3741_update_led_control_registers(DRIVER_ADDR_2, 1); + is31fl3741_update_led_control_registers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3741_update_led_control_registers(DRIVER_ADDR_3, 2); + is31fl3741_update_led_control_registers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3741_update_led_control_registers(DRIVER_ADDR_4, 3); + is31fl3741_update_led_control_registers(DRIVER_ADDR_4, 3); # endif # endif # endif @@ -231,13 +232,13 @@ static void init(void) { # endif # elif defined(CKLED2001) - CKLED2001_update_led_control_registers(DRIVER_ADDR_1, 0); + ckled2001_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - CKLED2001_update_led_control_registers(DRIVER_ADDR_2, 1); + ckled2001_update_led_control_registers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - CKLED2001_update_led_control_registers(DRIVER_ADDR_3, 2); + ckled2001_update_led_control_registers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - CKLED2001_update_led_control_registers(DRIVER_ADDR_4, 3); + ckled2001_update_led_control_registers(DRIVER_ADDR_4, 3); # endif # endif # endif @@ -246,13 +247,13 @@ static void init(void) { # if defined(IS31FL3731) static void flush(void) { - IS31FL3731_update_pwm_buffers(DRIVER_ADDR_1, 0); + is31fl3731_update_pwm_buffers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3731_update_pwm_buffers(DRIVER_ADDR_2, 1); + is31fl3731_update_pwm_buffers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3731_update_pwm_buffers(DRIVER_ADDR_3, 2); + is31fl3731_update_pwm_buffers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3731_update_pwm_buffers(DRIVER_ADDR_4, 3); + is31fl3731_update_pwm_buffers(DRIVER_ADDR_4, 3); # endif # endif # endif @@ -261,19 +262,19 @@ static void flush(void) { const rgb_matrix_driver_t rgb_matrix_driver = { .init = init, .flush = flush, - .set_color = IS31FL3731_set_color, - .set_color_all = IS31FL3731_set_color_all, + .set_color = is31fl3731_set_color, + .set_color_all = is31fl3731_set_color_all, }; # elif defined(IS31FL3733) static void flush(void) { - IS31FL3733_update_pwm_buffers(DRIVER_ADDR_1, 0); + is31fl3733_update_pwm_buffers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3733_update_pwm_buffers(DRIVER_ADDR_2, 1); + is31fl3733_update_pwm_buffers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3733_update_pwm_buffers(DRIVER_ADDR_3, 2); + is31fl3733_update_pwm_buffers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3733_update_pwm_buffers(DRIVER_ADDR_4, 3); + is31fl3733_update_pwm_buffers(DRIVER_ADDR_4, 3); # endif # endif # endif @@ -282,19 +283,19 @@ static void flush(void) { const rgb_matrix_driver_t rgb_matrix_driver = { .init = init, .flush = flush, - .set_color = IS31FL3733_set_color, - .set_color_all = IS31FL3733_set_color_all, + .set_color = is31fl3733_set_color, + .set_color_all = is31fl3733_set_color_all, }; # elif defined(IS31FL3736) static void flush(void) { - IS31FL3736_update_pwm_buffers(DRIVER_ADDR_1, 0); + is31fl3736_update_pwm_buffers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3736_update_pwm_buffers(DRIVER_ADDR_2, 1); + is31fl3736_update_pwm_buffers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3736_update_pwm_buffers(DRIVER_ADDR_3, 2); + is31fl3736_update_pwm_buffers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3736_update_pwm_buffers(DRIVER_ADDR_4, 3); + is31fl3736_update_pwm_buffers(DRIVER_ADDR_4, 3); # endif # endif # endif @@ -303,19 +304,19 @@ static void flush(void) { const rgb_matrix_driver_t rgb_matrix_driver = { .init = init, .flush = flush, - .set_color = IS31FL3736_set_color, - .set_color_all = IS31FL3736_set_color_all, + .set_color = is31fl3736_set_color, + .set_color_all = is31fl3736_set_color_all, }; # elif defined(IS31FL3737) static void flush(void) { - IS31FL3737_update_pwm_buffers(DRIVER_ADDR_1, 0); + is31fl3737_update_pwm_buffers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3737_update_pwm_buffers(DRIVER_ADDR_2, 1); + is31fl3737_update_pwm_buffers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3737_update_pwm_buffers(DRIVER_ADDR_3, 2); + is31fl3737_update_pwm_buffers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3737_update_pwm_buffers(DRIVER_ADDR_4, 3); + is31fl3737_update_pwm_buffers(DRIVER_ADDR_4, 3); # endif # endif # endif @@ -324,19 +325,19 @@ static void flush(void) { const rgb_matrix_driver_t rgb_matrix_driver = { .init = init, .flush = flush, - .set_color = IS31FL3737_set_color, - .set_color_all = IS31FL3737_set_color_all, + .set_color = is31fl3737_set_color, + .set_color_all = is31fl3737_set_color_all, }; # elif defined(IS31FL3741) static void flush(void) { - IS31FL3741_update_pwm_buffers(DRIVER_ADDR_1, 0); + is31fl3741_update_pwm_buffers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - IS31FL3741_update_pwm_buffers(DRIVER_ADDR_2, 1); + is31fl3741_update_pwm_buffers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - IS31FL3741_update_pwm_buffers(DRIVER_ADDR_3, 2); + is31fl3741_update_pwm_buffers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - IS31FL3741_update_pwm_buffers(DRIVER_ADDR_4, 3); + is31fl3741_update_pwm_buffers(DRIVER_ADDR_4, 3); # endif # endif # endif @@ -345,8 +346,8 @@ static void flush(void) { const rgb_matrix_driver_t rgb_matrix_driver = { .init = init, .flush = flush, - .set_color = IS31FL3741_set_color, - .set_color_all = IS31FL3741_set_color_all, + .set_color = is31fl3741_set_color, + .set_color_all = is31fl3741_set_color_all, }; # elif defined(IS31FLCOMMON) @@ -372,13 +373,13 @@ const rgb_matrix_driver_t rgb_matrix_driver = { # elif defined(CKLED2001) static void flush(void) { - CKLED2001_update_pwm_buffers(DRIVER_ADDR_1, 0); + ckled2001_update_pwm_buffers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - CKLED2001_update_pwm_buffers(DRIVER_ADDR_2, 1); + ckled2001_update_pwm_buffers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - CKLED2001_update_pwm_buffers(DRIVER_ADDR_3, 2); + ckled2001_update_pwm_buffers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - CKLED2001_update_pwm_buffers(DRIVER_ADDR_4, 3); + ckled2001_update_pwm_buffers(DRIVER_ADDR_4, 3); # endif # endif # endif @@ -387,8 +388,8 @@ static void flush(void) { const rgb_matrix_driver_t rgb_matrix_driver = { .init = init, .flush = flush, - .set_color = CKLED2001_set_color, - .set_color_all = CKLED2001_set_color_all, + .set_color = ckled2001_set_color, + .set_color_all = ckled2001_set_color_all, }; # endif @@ -398,24 +399,24 @@ const rgb_matrix_driver_t rgb_matrix_driver = { static void init(void) { spi_init(); - AW20216_init(DRIVER_1_CS, DRIVER_1_EN); + aw20216_init(DRIVER_1_CS, DRIVER_1_EN); # if defined(DRIVER_2_CS) - AW20216_init(DRIVER_2_CS, DRIVER_2_EN); + aw20216_init(DRIVER_2_CS, DRIVER_2_EN); # endif } static void flush(void) { - AW20216_update_pwm_buffers(DRIVER_1_CS, 0); + aw20216_update_pwm_buffers(DRIVER_1_CS, 0); # if defined(DRIVER_2_CS) - AW20216_update_pwm_buffers(DRIVER_2_CS, 1); + aw20216_update_pwm_buffers(DRIVER_2_CS, 1); # endif } const rgb_matrix_driver_t rgb_matrix_driver = { .init = init, .flush = flush, - .set_color = AW20216_set_color, - .set_color_all = AW20216_set_color_all, + .set_color = aw20216_set_color, + .set_color_all = aw20216_set_color_all, }; #elif defined(WS2812) @@ -426,11 +427,17 @@ const rgb_matrix_driver_t rgb_matrix_driver = { // LED color buffer LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT]; +bool ws2812_dirty = false; -static void init(void) {} +static void init(void) { + ws2812_dirty = false; +} static void flush(void) { - ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT); + if (ws2812_dirty) { + ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT); + ws2812_dirty = false; + } } // Set an led in the buffer to a color @@ -448,6 +455,11 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { } # endif + if (rgb_matrix_ws2812_array[i].r == r && rgb_matrix_ws2812_array[i].g == g && rgb_matrix_ws2812_array[i].b == b) { + return; + } + + ws2812_dirty = true; rgb_matrix_ws2812_array[i].r = r; rgb_matrix_ws2812_array[i].g = g; rgb_matrix_ws2812_array[i].b = b; |