diff options
Diffstat (limited to 'quantum/rgb_matrix')
-rw-r--r-- | quantum/rgb_matrix/animations/solid_reactive_anim.h | 2 | ||||
-rw-r--r-- | quantum/rgb_matrix/rgb_matrix.c | 27 | ||||
-rw-r--r-- | quantum/rgb_matrix/rgb_matrix.h | 36 | ||||
-rw-r--r-- | quantum/rgb_matrix/rgb_matrix_drivers.c | 44 | ||||
-rw-r--r-- | quantum/rgb_matrix/rgb_matrix_drivers.h | 47 |
5 files changed, 89 insertions, 67 deletions
diff --git a/quantum/rgb_matrix/animations/solid_reactive_anim.h b/quantum/rgb_matrix/animations/solid_reactive_anim.h index edf6041350..e18ffb5f2b 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix/animations/solid_reactive_anim.h @@ -7,7 +7,7 @@ static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) { # ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4); # endif - hsv.h += qsub8(130, offset); + hsv.h += scale8(255 - offset, 64); return hsv; } diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index d93d189827..4865664ac0 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -76,9 +76,6 @@ static uint8_t rgb_last_enable = UINT8_MAX; static uint8_t rgb_last_effect = UINT8_MAX; static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; static rgb_task_states rgb_task_state = SYNCING; -#if RGB_MATRIX_TIMEOUT > 0 -static uint32_t rgb_anykey_timer; -#endif // RGB_MATRIX_TIMEOUT > 0 // double buffers static uint32_t rgb_timer_buffer; @@ -163,9 +160,6 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { #ifndef RGB_MATRIX_SPLIT if (!is_keyboard_master()) return; #endif -#if RGB_MATRIX_TIMEOUT > 0 - rgb_anykey_timer = 0; -#endif // RGB_MATRIX_TIMEOUT > 0 #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED uint8_t led[LED_HITS_TO_REMEMBER]; @@ -246,18 +240,11 @@ static bool rgb_matrix_none(effect_params_t *params) { } static void rgb_task_timers(void) { -#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 +#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); -#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 +#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) rgb_timer_buffer = sync_timer_read32(); - // Update double buffer timers -#if RGB_MATRIX_TIMEOUT > 0 - if (rgb_anykey_timer + deltaTime <= UINT32_MAX) { - rgb_anykey_timer += deltaTime; - } -#endif // RGB_MATRIX_TIMEOUT > 0 - // Update double buffer last hit timers #ifdef RGB_MATRIX_KEYREACTIVE_ENABLED uint8_t count = last_hit_buffer.count; @@ -370,7 +357,7 @@ void rgb_matrix_task(void) { // while suspended and just do a software shutdown. This is a cheap hack for now. bool suspend_backlight = suspend_state || #if RGB_MATRIX_TIMEOUT > 0 - (rgb_anykey_timer > (uint32_t)RGB_MATRIX_TIMEOUT) || + (last_input_activity_elapsed() > (uint32_t)RGB_MATRIX_TIMEOUT) || #endif // RGB_MATRIX_TIMEOUT > 0 false; @@ -473,12 +460,6 @@ void rgb_matrix_init(void) { } #endif // RGB_MATRIX_KEYREACTIVE_ENABLED - if (!eeconfig_is_enabled()) { - dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n"); - eeconfig_init(); - eeconfig_update_rgb_matrix_default(); - } - eeconfig_init_rgb_matrix(); if (!rgb_matrix_config.mode) { dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); @@ -488,7 +469,7 @@ void rgb_matrix_init(void) { } void rgb_matrix_set_suspend_state(bool state) { -#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED +#ifdef RGB_MATRIX_SLEEP if (state && !suspend_state) { // only run if turning off, and only once rgb_task_render(0); // turn off all LEDs when suspending rgb_task_flush(0); // and actually flash led state to LEDs diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 9a3ffb8ea3..b1bf839bf6 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -21,31 +21,10 @@ #include <stdint.h> #include <stdbool.h> #include "rgb_matrix_types.h" +#include "rgb_matrix_drivers.h" #include "color.h" #include "keyboard.h" -#if defined(RGB_MATRIX_IS31FL3218) -# include "is31fl3218.h" -#elif defined(RGB_MATRIX_IS31FL3731) -# include "is31fl3731.h" -#elif defined(RGB_MATRIX_IS31FL3733) -# include "is31fl3733.h" -#elif defined(RGB_MATRIX_IS31FL3736) -# include "is31fl3736.h" -#elif defined(RGB_MATRIX_IS31FL3737) -# include "is31fl3737.h" -#elif defined(RGB_MATRIX_IS31FL3741) -# include "is31fl3741.h" -#elif defined(IS31FLCOMMON) -# include "is31flcommon.h" -#elif defined(RGB_MATRIX_SNLED27351) -# include "snled27351.h" -#elif defined(RGB_MATRIX_AW20216S) -# include "aw20216s.h" -#elif defined(RGB_MATRIX_WS2812) -# include "ws2812.h" -#endif - #ifndef RGB_MATRIX_TIMEOUT # define RGB_MATRIX_TIMEOUT 0 #endif @@ -272,17 +251,6 @@ void rgb_matrix_set_flags_noeeprom(led_flags_t flags); # define rgblight_decrease_speed_noeeprom rgb_matrix_decrease_speed_noeeprom #endif -typedef struct { - /* Perform any initialisation required for the other driver functions to work. */ - void (*init)(void); - /* Set the colour of a single LED in the buffer. */ - void (*set_color)(int index, uint8_t r, uint8_t g, uint8_t b); - /* Set the colour of all LEDS on the keyboard in the buffer. */ - void (*set_color_all)(uint8_t r, uint8_t g, uint8_t b); - /* Flush any buffered changes to the hardware. */ - void (*flush)(void); -} rgb_matrix_driver_t; - static inline bool rgb_matrix_check_finished_leds(uint8_t led_idx) { #if defined(RGB_MATRIX_SPLIT) if (is_keyboard_left()) { @@ -295,8 +263,6 @@ static inline bool rgb_matrix_check_finished_leds(uint8_t led_idx) { #endif } -extern const rgb_matrix_driver_t rgb_matrix_driver; - extern rgb_config_t rgb_matrix_config; extern uint32_t g_rgb_timer; diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 0f979cb233..b5e539657d 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -14,7 +14,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "rgb_matrix.h" +#include "rgb_matrix_drivers.h" + +#include <stdbool.h> +#include "keyboard.h" +#include "color.h" #include "util.h" /* Each driver needs to define the struct @@ -72,12 +76,36 @@ const rgb_matrix_driver_t rgb_matrix_driver = { .set_color_all = is31fl3741_set_color_all, }; -#elif defined(IS31FLCOMMON) +#elif defined(RGB_MATRIX_IS31FL3742A) +const rgb_matrix_driver_t rgb_matrix_driver = { + .init = is31fl3742a_init_drivers, + .flush = is31fl3742a_flush, + .set_color = is31fl3742a_set_color, + .set_color_all = is31fl3742a_set_color_all, +}; + +#elif defined(RGB_MATRIX_IS31FL3743A) +const rgb_matrix_driver_t rgb_matrix_driver = { + .init = is31fl3743a_init_drivers, + .flush = is31fl3743a_flush, + .set_color = is31fl3743a_set_color, + .set_color_all = is31fl3743a_set_color_all, +}; + +#elif defined(RGB_MATRIX_IS31FL3745) +const rgb_matrix_driver_t rgb_matrix_driver = { + .init = is31fl3745_init_drivers, + .flush = is31fl3745_flush, + .set_color = is31fl3745_set_color, + .set_color_all = is31fl3745_set_color_all, +}; + +#elif defined(RGB_MATRIX_IS31FL3746A) const rgb_matrix_driver_t rgb_matrix_driver = { - .init = IS31FL_RGB_init_drivers, - .flush = IS31FL_common_flush, - .set_color = IS31FL_RGB_set_color, - .set_color_all = IS31FL_RGB_set_color_all, + .init = is31fl3746a_init_drivers, + .flush = is31fl3746a_flush, + .set_color = is31fl3746a_set_color, + .set_color_all = is31fl3746a_set_color_all, }; #elif defined(RGB_MATRIX_SNLED27351) @@ -103,7 +131,7 @@ const rgb_matrix_driver_t rgb_matrix_driver = { # endif // LED color buffer -rgb_led_t rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT]; +rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_COUNT]; bool ws2812_dirty = false; static void init(void) { @@ -112,7 +140,7 @@ static void init(void) { static void flush(void) { if (ws2812_dirty) { - ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT); + ws2812_setleds(rgb_matrix_ws2812_array, WS2812_LED_COUNT); ws2812_dirty = false; } } diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.h b/quantum/rgb_matrix/rgb_matrix_drivers.h new file mode 100644 index 0000000000..8f919b1b3c --- /dev/null +++ b/quantum/rgb_matrix/rgb_matrix_drivers.h @@ -0,0 +1,47 @@ +// Copyright 2023 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <stdint.h> + +#if defined(RGB_MATRIX_AW20216S) +# include "aw20216s.h" +#elif defined(RGB_MATRIX_IS31FL3218) +# include "is31fl3218.h" +#elif defined(RGB_MATRIX_IS31FL3731) +# include "is31fl3731.h" +#elif defined(RGB_MATRIX_IS31FL3733) +# include "is31fl3733.h" +#elif defined(RGB_MATRIX_IS31FL3736) +# include "is31fl3736.h" +#elif defined(RGB_MATRIX_IS31FL3737) +# include "is31fl3737.h" +#elif defined(RGB_MATRIX_IS31FL3741) +# include "is31fl3741.h" +#elif defined(RGB_MATRIX_IS31FL3742A) +# include "is31fl3742a.h" +#elif defined(RGB_MATRIX_IS31FL3743A) +# include "is31fl3743a.h" +#elif defined(RGB_MATRIX_IS31FL3745) +# include "is31fl3745.h" +#elif defined(RGB_MATRIX_IS31FL3746A) +# include "is31fl3746a.h" +#elif defined(RGB_MATRIX_SNLED27351) +# include "snled27351.h" +#elif defined(RGB_MATRIX_WS2812) +# include "ws2812.h" +#endif + +typedef struct { + /* Perform any initialisation required for the other driver functions to work. */ + void (*init)(void); + /* Set the colour of a single LED in the buffer. */ + void (*set_color)(int index, uint8_t r, uint8_t g, uint8_t b); + /* Set the colour of all LEDS on the keyboard in the buffer. */ + void (*set_color_all)(uint8_t r, uint8_t g, uint8_t b); + /* Flush any buffered changes to the hardware. */ + void (*flush)(void); +} rgb_matrix_driver_t; + +extern const rgb_matrix_driver_t rgb_matrix_driver; |