From bb52119a6dfe9c6f0314d1bcd948efda59626a70 Mon Sep 17 00:00:00 2001 From: M-AS Date: Mon, 22 Apr 2019 11:37:40 -0400 Subject: RGB Matrix Animations: Three/six new reactive effects (wide, cross, nexus) (#5602) * added 3 new RGB_Matrix effects * made cross effect behavior smoother * removed dead code * added effect descriptions --- quantum/rgb_matrix.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'quantum/rgb_matrix.c') diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index a1193d4c07..41ed8983ef 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -41,6 +41,9 @@ #include "rgb_matrix_animations/digital_rain_anim.h" #include "rgb_matrix_animations/solid_reactive_simple_anim.h" #include "rgb_matrix_animations/solid_reactive_anim.h" +#include "rgb_matrix_animations/solid_reactive_wide.h" +#include "rgb_matrix_animations/solid_reactive_cross.h" +#include "rgb_matrix_animations/solid_reactive_nexus.h" #include "rgb_matrix_animations/splash_anim.h" #include "rgb_matrix_animations/solid_splash_anim.h" #include "rgb_matrix_animations/breathing_anim.h" @@ -380,6 +383,36 @@ static void rgb_task_render(uint8_t effect) { rendering = rgb_matrix_solid_reactive(&rgb_effect_params); // Max 4ms Avg 3ms break; #endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE + case RGB_MATRIX_SOLID_REACTIVE_WIDE: + rendering = rgb_matrix_solid_reactive_wide(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE + case RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE: + rendering = rgb_matrix_solid_reactive_multiwide(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS + case RGB_MATRIX_SOLID_REACTIVE_CROSS: + rendering = rgb_matrix_solid_reactive_cross(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS + case RGB_MATRIX_SOLID_REACTIVE_MULTICROSS: + rendering = rgb_matrix_solid_reactive_multicross(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS + case RGB_MATRIX_SOLID_REACTIVE_NEXUS: + rendering = rgb_matrix_solid_reactive_nexus(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +#ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS + case RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS: + rendering = rgb_matrix_solid_reactive_multinexus(&rgb_effect_params); // Max ?? ms Avg ?? ms + break; +#endif // DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS #ifndef DISABLE_RGB_MATRIX_SPLASH case RGB_MATRIX_SPLASH: rendering = rgb_matrix_splash(&rgb_effect_params); // Max 5ms Avg 3ms -- cgit v1.2.3 From 1d784f0f9575b70e35c9c8338b0ff80dc7316d7e Mon Sep 17 00:00:00 2001 From: Daniel Prilik Date: Mon, 29 Apr 2019 17:48:41 -0400 Subject: RGB Matrix: Custom effects on a kb/user level (#5338) * Revamped custom effects approach See docs for example usage * push-up RGB Matrix default mode Override default effect using RGB_MATRIX_STARTUP_MODE. Useful on boards without EEPROM support (*cough* Massdrop ALT/CTRL *cough*) * update docs --- quantum/rgb_matrix.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'quantum/rgb_matrix.c') diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 41ed8983ef..5ca9b87a63 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -48,6 +48,19 @@ #include "rgb_matrix_animations/solid_splash_anim.h" #include "rgb_matrix_animations/breathing_anim.h" +#if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) + #define RGB_MATRIX_CUSTOM_EFFECT_IMPLS + #define RGB_MATRIX_EFFECT(name, ...) + #ifdef RGB_MATRIX_CUSTOM_KB + #include "rgb_matrix_kb.inc" + #endif + #ifdef RGB_MATRIX_CUSTOM_USER + #include "rgb_matrix_user.inc" + #endif + #undef RGB_MATRIX_EFFECT + #undef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif + #ifndef RGB_DISABLE_AFTER_TIMEOUT #define RGB_DISABLE_AFTER_TIMEOUT 0 #endif @@ -81,6 +94,15 @@ #define RGB_MATRIX_SPD_STEP 16 #endif +#if !defined(RGB_MATRIX_STARTUP_MODE) + #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL + #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT + #else + // fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace + #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_SOLID_COLOR + #endif +#endif + bool g_suspend_state = false; rgb_config_t rgb_matrix_config; @@ -104,12 +126,7 @@ void eeconfig_update_rgb_matrix(uint32_t val) { void eeconfig_update_rgb_matrix_default(void) { dprintf("eeconfig_update_rgb_matrix_default\n"); rgb_matrix_config.enable = 1; -#ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT - rgb_matrix_config.mode = RGB_MATRIX_CYCLE_LEFT_RIGHT; -#else - // fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace - rgb_matrix_config.mode = RGB_MATRIX_SOLID_COLOR; -#endif + rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE; rgb_matrix_config.hue = 0; rgb_matrix_config.sat = UINT8_MAX; rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS; @@ -435,6 +452,20 @@ static void rgb_task_render(uint8_t effect) { #endif // DISABLE_RGB_MATRIX_SOLID_MULTISPLASH #endif // RGB_MATRIX_KEYREACTIVE_ENABLED +#if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) + #define RGB_MATRIX_EFFECT(name, ...) \ + case RGB_MATRIX_CUSTOM_##name: \ + rendering = name(&rgb_effect_params); \ + break; + #ifdef RGB_MATRIX_CUSTOM_KB + #include "rgb_matrix_kb.inc" + #endif + #ifdef RGB_MATRIX_CUSTOM_USER + #include "rgb_matrix_user.inc" + #endif + #undef RGB_MATRIX_EFFECT +#endif + // Factory default magic value case UINT8_MAX: { rgb_matrix_test(); -- cgit v1.2.3 From a7113c8ed090d0ac647f30ee9b8ef41252e568ed Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 30 Apr 2019 00:18:50 +0200 Subject: Updated rgb_led struct field modifier to flags (#5619) Updated effects to test led flags Updated massdrop to use new flags field for led toggle --- quantum/rgb_matrix.c | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) (limited to 'quantum/rgb_matrix.c') diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 5ca9b87a63..8c16c7790e 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -162,28 +162,11 @@ void rgb_matrix_update_pwm_buffers(void) { } void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { -#ifdef RGB_MATRIX_EXTRA_TOG - const bool is_key = g_rgb_leds[index].matrix_co.raw != 0xff; - if ( - (rgb_matrix_config.enable == RGB_ZONE_KEYS && !is_key) || - (rgb_matrix_config.enable == RGB_ZONE_UNDER && is_key) - ) { - rgb_matrix_driver.set_color(index, 0, 0, 0); - return; - } -#endif - rgb_matrix_driver.set_color(index, red, green, blue); } void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { -#ifdef RGB_MATRIX_EXTRA_TOG - for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - rgb_matrix_set_color(i, red, green, blue); - } -#else rgb_matrix_driver.set_color_all(red, green, blue); -#endif } bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { @@ -262,7 +245,7 @@ static bool rgb_matrix_none(effect_params_t* params) { static uint8_t rgb_last_enable = UINT8_MAX; static uint8_t rgb_last_effect = UINT8_MAX; -static effect_params_t rgb_effect_params = { 0, 0 }; +static effect_params_t rgb_effect_params = { 0, 0xFF }; static rgb_task_states rgb_task_state = SYNCING; static void rgb_task_timers(void) { @@ -575,29 +558,31 @@ void rgb_matrix_set_suspend_state(bool state) { } void rgb_matrix_toggle(void) { - rgb_matrix_config.enable++; - if (!rgb_matrix_config.enable) { - rgb_task_state = STARTING; - } + rgb_matrix_config.enable ^= 1; + rgb_task_state = STARTING; eeconfig_update_rgb_matrix(rgb_matrix_config.raw); } void rgb_matrix_enable(void) { - rgb_matrix_config.enable = 1; + rgb_matrix_enable_noeeprom(); eeconfig_update_rgb_matrix(rgb_matrix_config.raw); } void rgb_matrix_enable_noeeprom(void) { - rgb_matrix_config.enable = 1; + if (!rgb_matrix_config.enable) + rgb_task_state = STARTING; + rgb_matrix_config.enable = 1; } void rgb_matrix_disable(void) { - rgb_matrix_config.enable = 0; + rgb_matrix_disable_noeeprom(); eeconfig_update_rgb_matrix(rgb_matrix_config.raw); } void rgb_matrix_disable_noeeprom(void) { - rgb_matrix_config.enable = 0; + if (rgb_matrix_config.enable) + rgb_task_state = STARTING; + rgb_matrix_config.enable = 0; } void rgb_matrix_step(void) { @@ -658,6 +643,14 @@ void rgb_matrix_decrease_speed(void) { eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this } +led_flags_t rgb_matrix_get_flags(void) { + return rgb_effect_params.flags; +} + +void rgb_matrix_set_flags(led_flags_t flags) { + rgb_effect_params.flags = flags; +} + void rgb_matrix_mode(uint8_t mode) { rgb_matrix_config.mode = mode; rgb_task_state = STARTING; -- cgit v1.2.3 From bb208f3e3b69fb154f4f78d7538ffa28482f232f Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 30 Apr 2019 09:55:53 -0500 Subject: Implement kb function for rgb matrix to led lookup (#5738) --- quantum/rgb_matrix.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'quantum/rgb_matrix.c') diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 8c16c7790e..5528a08347 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -144,9 +144,14 @@ void eeconfig_debug_rgb_matrix(void) { dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed); } +__attribute__ ((weak)) +uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { + return 0; +} + uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { // TODO: This is kinda expensive, fix this soonish - uint8_t led_count = 0; + uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); for (uint8_t i = 0; i < DRIVER_LED_TOTAL && led_count < LED_HITS_TO_REMEMBER; i++) { matrix_co_t matrix_co = g_rgb_leds[i].matrix_co; if (row == matrix_co.row && column == matrix_co.col) { -- cgit v1.2.3 From af89752bffbaf5dcea30ea16be66b4d682701bc4 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 7 May 2019 18:22:46 -0500 Subject: rgb_led struct conversion (aka: Per led (key) type rgb matrix effects - part 2) (#5783) * Initial conversion of the rgb_led struct * Converting last keyboard & updating effects to take advantage of the new structure * New struct should not be const * Updated docs * Changing define ___ for no led to NO_LED * Missed converting some keymap usages of the old struct layout --- quantum/rgb_matrix.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'quantum/rgb_matrix.c') diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 5528a08347..edbcee9cd1 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -105,6 +105,7 @@ bool g_suspend_state = false; +extern led_config_t g_led_config; rgb_config_t rgb_matrix_config; rgb_counters_t g_rgb_counters; @@ -150,14 +151,11 @@ uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t } uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { - // TODO: This is kinda expensive, fix this soonish uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); - for (uint8_t i = 0; i < DRIVER_LED_TOTAL && led_count < LED_HITS_TO_REMEMBER; i++) { - matrix_co_t matrix_co = g_rgb_leds[i].matrix_co; - if (row == matrix_co.row && column == matrix_co.col) { - led_i[led_count] = i; - led_count++; - } + uint8_t led_index = g_led_config.matrix_co[row][column]; + if (led_index != NO_LED) { + led_i[led_count] = led_index; + led_count++; } return led_count; } @@ -201,8 +199,8 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { for(uint8_t i = 0; i < led_count; i++) { uint8_t index = last_hit_buffer.count; - last_hit_buffer.x[index] = g_rgb_leds[led[i]].point.x; - last_hit_buffer.y[index] = g_rgb_leds[led[i]].point.y; + last_hit_buffer.x[index] = g_led_config.point[led[i]].x; + last_hit_buffer.y[index] = g_led_config.point[led[i]].y; last_hit_buffer.index[index] = led[i]; last_hit_buffer.tick[index] = 0; last_hit_buffer.count++; -- cgit v1.2.3 From 60eae7335b711e8d4be7d48ad2290141e04debe7 Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 7 May 2019 21:17:00 -0500 Subject: RGB Matrix Typing Heatmap (#5786) * RGB Matrix Typing Heatmap Effect * Fixing file name and effect init --- quantum/rgb_matrix.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'quantum/rgb_matrix.c') diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index edbcee9cd1..92a94df80f 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -38,6 +38,7 @@ #include "rgb_matrix_animations/rainbow_pinwheels_anim.h" #include "rgb_matrix_animations/rainbow_moving_chevron_anim.h" #include "rgb_matrix_animations/jellybean_raindrops_anim.h" +#include "rgb_matrix_animations/typing_heatmap_anim.h" #include "rgb_matrix_animations/digital_rain_anim.h" #include "rgb_matrix_animations/solid_reactive_simple_anim.h" #include "rgb_matrix_animations/solid_reactive_anim.h" @@ -111,6 +112,10 @@ rgb_config_t rgb_matrix_config; rgb_counters_t g_rgb_counters; static uint32_t rgb_counters_buffer; +#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS +uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; +#endif + #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED last_hit_t g_last_hit_tracker; static last_hit_t last_hit_buffer; @@ -206,6 +211,13 @@ bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { last_hit_buffer.count++; } #endif // RGB_MATRIX_KEYREACTIVE_ENABLED + +#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) + if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) { + process_rgb_matrix_typing_heatmap(record); + } +#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(DISABLE_RGB_MATRIX_TYPING_HEATMAP) + return true; } @@ -370,11 +382,20 @@ static void rgb_task_render(uint8_t effect) { rendering = rgb_matrix_jellybean_raindrops(&rgb_effect_params); // Max 1ms Avg 0ms break; #endif // DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS + +#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS +#ifndef DISABLE_RGB_MATRIX_TYPING_HEATMAP + case RGB_MATRIX_TYPING_HEATMAP: + rendering = rgb_matrix_typing_heatmap(&rgb_effect_params); // Max 4ms Avg 3ms + break; +#endif // DISABLE_RGB_MATRIX_TYPING_HEATMAP #ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN case RGB_MATRIX_DIGITAL_RAIN: rendering = rgb_matrix_digital_rain(&rgb_effect_params); // Max 9ms Avg 8ms | this is expensive, fix it break; #endif // DISABLE_RGB_MATRIX_DIGITAL_RAIN +#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS + #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE case RGB_MATRIX_SOLID_REACTIVE_SIMPLE: -- cgit v1.2.3