diff options
Diffstat (limited to 'quantum/led_matrix')
-rw-r--r-- | quantum/led_matrix/led_matrix.c | 100 | ||||
-rw-r--r-- | quantum/led_matrix/led_matrix.h | 26 | ||||
-rw-r--r-- | quantum/led_matrix/led_matrix_drivers.c | 2 | ||||
-rw-r--r-- | quantum/led_matrix/led_matrix_types.h | 4 |
4 files changed, 68 insertions, 64 deletions
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index b421480d41..59bfbdf0db 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c @@ -54,12 +54,8 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; // -----End led effect includes macros------- // ------------------------------------------ -#if defined(LED_DISABLE_AFTER_TIMEOUT) && !defined(LED_DISABLE_TIMEOUT) -# define LED_DISABLE_TIMEOUT (LED_DISABLE_AFTER_TIMEOUT * 1200UL) -#endif - -#ifndef LED_DISABLE_TIMEOUT -# define LED_DISABLE_TIMEOUT 0 +#ifndef LED_MATRIX_TIMEOUT +# define LED_MATRIX_TIMEOUT 0 #endif #if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX @@ -75,16 +71,16 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; # define LED_MATRIX_SPD_STEP 16 #endif -#if !defined(LED_MATRIX_STARTUP_MODE) -# define LED_MATRIX_STARTUP_MODE LED_MATRIX_SOLID +#if !defined(LED_MATRIX_DEFAULT_MODE) +# define LED_MATRIX_DEFAULT_MODE LED_MATRIX_SOLID #endif -#if !defined(LED_MATRIX_STARTUP_VAL) -# define LED_MATRIX_STARTUP_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS +#if !defined(LED_MATRIX_DEFAULT_VAL) +# define LED_MATRIX_DEFAULT_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS #endif -#if !defined(LED_MATRIX_STARTUP_SPD) -# define LED_MATRIX_STARTUP_SPD UINT8_MAX / 2 +#if !defined(LED_MATRIX_DEFAULT_SPD) +# define LED_MATRIX_DEFAULT_SPD UINT8_MAX / 2 #endif #if defined(LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL) && (LED_MATRIX_BRIGHTNESS_TURN_OFF_VAL >= LED_MATRIX_MAXIMUM_BRIGHTNESS) @@ -109,10 +105,10 @@ static uint8_t led_last_enable = UINT8_MAX; static uint8_t led_last_effect = UINT8_MAX; static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; static led_task_states led_task_state = SYNCING; -#if LED_DISABLE_TIMEOUT > 0 +#if led_matrix_timeout > 0 static uint32_t led_anykey_timer; -static uint32_t led_disable_timeout = LED_DISABLE_TIMEOUT; -#endif // LED_DISABLE_TIMEOUT > 0 +static uint32_t led_matrix_timeout = LED_MATRIX_TIMEOUT; +#endif // LED_MATRIX_TIMEOUT > 0 // double buffers static uint32_t led_timer_buffer; @@ -136,9 +132,9 @@ void eeconfig_update_led_matrix(void) { void eeconfig_update_led_matrix_default(void) { dprintf("eeconfig_update_led_matrix_default\n"); led_matrix_eeconfig.enable = 1; - led_matrix_eeconfig.mode = LED_MATRIX_STARTUP_MODE; - led_matrix_eeconfig.val = LED_MATRIX_STARTUP_VAL; - led_matrix_eeconfig.speed = LED_MATRIX_STARTUP_SPD; + led_matrix_eeconfig.mode = LED_MATRIX_DEFAULT_MODE; + led_matrix_eeconfig.val = LED_MATRIX_DEFAULT_VAL; + led_matrix_eeconfig.speed = LED_MATRIX_DEFAULT_SPD; led_matrix_eeconfig.flags = LED_FLAG_ALL; eeconfig_flush_led_matrix(true); } @@ -179,7 +175,7 @@ void led_matrix_set_value(int index, uint8_t value) { void led_matrix_set_value_all(uint8_t value) { #if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT) - for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) + for (uint8_t i = 0; i < LED_MATRIX_LED_COUNT; i++) led_matrix_set_value(i, value); #else # ifdef USE_CIE1931_CURVE @@ -194,9 +190,9 @@ void process_led_matrix(uint8_t row, uint8_t col, bool pressed) { #ifndef LED_MATRIX_SPLIT if (!is_keyboard_master()) return; #endif -#if LED_DISABLE_TIMEOUT > 0 +#if LED_MATRIX_TIMEOUT > 0 led_anykey_timer = 0; -#endif // LED_DISABLE_TIMEOUT > 0 +#endif // LED_MATRIX_TIMEOUT > 0 #ifdef LED_MATRIX_KEYREACTIVE_ENABLED uint8_t led[LED_HITS_TO_REMEMBER]; @@ -256,13 +252,13 @@ static bool led_matrix_none(effect_params_t *params) { } static void led_task_timers(void) { -#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 +#if defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_MATRIX_TIMEOUT > 0 uint32_t deltaTime = sync_timer_elapsed32(led_timer_buffer); -#endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_DISABLE_TIMEOUT > 0 +#endif // defined(LED_MATRIX_KEYREACTIVE_ENABLED) || LED_MATRIX_TIMEOUT > 0 led_timer_buffer = sync_timer_read32(); // Update double buffer timers -#if LED_DISABLE_TIMEOUT > 0 +#if LED_MATRIX_TIMEOUT > 0 if (led_anykey_timer < UINT32_MAX) { if (UINT32_MAX - deltaTime < led_anykey_timer) { led_anykey_timer = UINT32_MAX; @@ -270,7 +266,7 @@ static void led_task_timers(void) { led_anykey_timer += deltaTime; } } -#endif // LED_DISABLE_TIMEOUT > 0 +#endif // LED_MATRIX_TIMEOUT > 0 // Update double buffer last hit timers #ifdef LED_MATRIX_KEYREACTIVE_ENABLED @@ -368,17 +364,17 @@ static void led_task_flush(uint8_t effect) { led_matrix_driver.exit_shutdown(); driver_shutdown = false; } -#endif +#endif // update pwm buffers led_matrix_update_pwm_buffers(); #ifdef LED_MATRIX_DRIVER_SHUTDOWN_ENABLE // shutdown if neccesary - if (effect == LED_MATRIX_NONE && !driver_shutdown && led_matrix_driver_allow_shutdown()) { + if (effect == LED_MATRIX_NONE && !driver_shutdown && led_matrix_driver_allow_shutdown()) { led_matrix_driver_shutdown(); } -#endif +#endif // next task led_task_state = SYNCING; @@ -390,9 +386,9 @@ void led_matrix_task(void) { // Ideally we would also stop sending zeros to the LED driver PWM buffers // while suspended and just do a software shutdown. This is a cheap hack for now. bool suspend_backlight = suspend_state || -#if LED_DISABLE_TIMEOUT > 0 - (led_anykey_timer > led_disable_timeout) || -#endif // LED_DISABLE_TIMEOUT > 0 +#if LED_MATRIX_TIMEOUT > 0 + (led_anykey_timer > led_matrix_timeout) || +#endif // led_matrix_timeout > 0 false; uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode; @@ -422,9 +418,13 @@ void led_matrix_indicators(void) { led_matrix_indicators_user(); } -__attribute__((weak)) void led_matrix_indicators_kb(void) {} +__attribute__((weak)) bool led_matrix_indicators_kb(void) { + return led_matrix_indicators_user(); +} -__attribute__((weak)) void led_matrix_indicators_user(void) {} +__attribute__((weak)) bool led_matrix_indicators_user(void) { + return true; +} void led_matrix_indicators_advanced(effect_params_t *params) { /* special handling is needed for "params->iter", since it's already been incremented. @@ -432,27 +432,31 @@ void led_matrix_indicators_advanced(effect_params_t *params) { * and not sure which would be better. Otherwise, this should be called from * led_task_render, right before the iter++ line. */ -#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL +#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < LED_MATRIX_LED_COUNT uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * (params->iter - 1); uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; - if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; + if (max > LED_MATRIX_LED_COUNT) max = LED_MATRIX_LED_COUNT; #else uint8_t min = 0; - uint8_t max = DRIVER_LED_TOTAL; + uint8_t max = LED_MATRIX_LED_COUNT; #endif led_matrix_indicators_advanced_kb(min, max); led_matrix_indicators_advanced_user(min, max); } -__attribute__((weak)) void led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {} +__attribute__((weak)) bool led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) { + return led_matrix_indicators_advanced_user(led_min, led_max); +} -__attribute__((weak)) void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {} +__attribute__((weak)) bool led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { + return true; +} void led_matrix_init(void) { led_matrix_driver.init(); #ifdef LED_MATRIX_DRIVER_SHUTDOWN_ENABLE driver_shutdown = false; -#endif +#endif #ifdef LED_MATRIX_KEYREACTIVE_ENABLED g_last_hit_tracker.count = 0; @@ -698,24 +702,24 @@ void led_matrix_set_flags_noeeprom(led_flags_t flags) { led_matrix_set_flags_eeprom_helper(flags, false); } -#if LED_DISABLE_TIMEOUT > 0 -void led_matrix_disable_timeout_set(uint32_t timeout) { - led_disable_timeout = timeout; +#if LED_MATRIX_TIMEOUT > 0 +void led_matrix_disable_timeout_set(uint32_t timeout) { + led_matrix_timeout = timeout; } -void led_matrix_disable_time_reset(void){ - led_anykey_timer = 0; +void led_matrix_disable_time_reset(void){ + led_anykey_timer = 0; } #endif #ifdef LED_MATRIX_DRIVER_SHUTDOWN_ENABLE -void led_matrix_driver_shutdown(void) { +void led_matrix_driver_shutdown(void) { led_matrix_driver.shutdown(); driver_shutdown = true; }; -bool led_matrix_is_driver_shutdown(void) { - return driver_shutdown; +bool led_matrix_is_driver_shutdown(void) { + return driver_shutdown; } __attribute__((weak)) bool led_matrix_driver_allow_shutdown(void) { return true; }; -#endif
\ No newline at end of file +#endif diff --git a/quantum/led_matrix/led_matrix.h b/quantum/led_matrix/led_matrix.h index d5da114c92..5f3088514c 100644 --- a/quantum/led_matrix/led_matrix.h +++ b/quantum/led_matrix/led_matrix.h @@ -42,15 +42,15 @@ #endif #ifndef LED_MATRIX_LED_PROCESS_LIMIT -# define LED_MATRIX_LED_PROCESS_LIMIT (DRIVER_LED_TOTAL + 4) / 5 +# define LED_MATRIX_LED_PROCESS_LIMIT (LED_MATRIX_LED_COUNT + 4) / 5 #endif -#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL +#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < LED_MATRIX_LED_COUNT # if defined(LED_MATRIX_SPLIT) # define LED_MATRIX_USE_LIMITS(min, max) \ uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \ - if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; \ + if (max > LED_MATRIX_LED_COUNT) max = LED_MATRIX_LED_COUNT; \ uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT; \ if (is_keyboard_left() && (max > k_led_matrix_split[0])) max = k_led_matrix_split[0]; \ if (!(is_keyboard_left()) && (min < k_led_matrix_split[0])) min = k_led_matrix_split[0]; @@ -58,27 +58,27 @@ # define LED_MATRIX_USE_LIMITS(min, max) \ uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \ - if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL; + if (max > LED_MATRIX_LED_COUNT) max = LED_MATRIX_LED_COUNT; # endif #else # if defined(LED_MATRIX_SPLIT) # define LED_MATRIX_USE_LIMITS(min, max) \ uint8_t min = 0; \ - uint8_t max = DRIVER_LED_TOTAL; \ + uint8_t max = LED_MATRIX_LED_COUNT; \ const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT; \ if (is_keyboard_left() && (max > k_led_matrix_split[0])) max = k_led_matrix_split[0]; \ if (!(is_keyboard_left()) && (min < k_led_matrix_split[0])) min = k_led_matrix_split[0]; # else # define LED_MATRIX_USE_LIMITS(min, max) \ uint8_t min = 0; \ - uint8_t max = DRIVER_LED_TOTAL; + uint8_t max = LED_MATRIX_LED_COUNT; # endif #endif #define LED_MATRIX_TEST_LED_FLAGS() \ if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue -#define LED_DISABLE_TIME_INFINITE (UINT32_MAX) +#define LED_MATRIX_TIMEOUT_INFINITE (UINT32_MAX) enum led_matrix_effects { LED_MATRIX_NONE = 0, @@ -125,12 +125,12 @@ void led_matrix_none_indicators_user(void); // This runs after another backlight effect and replaces // values already set void led_matrix_indicators(void); -void led_matrix_indicators_kb(void); -void led_matrix_indicators_user(void); +bool led_matrix_indicators_kb(void); +bool led_matrix_indicators_user(void); void led_matrix_indicators_advanced(effect_params_t *params); -void led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max); -void led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); +bool led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max); +bool led_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); void led_matrix_init(void); @@ -205,9 +205,9 @@ static inline bool led_matrix_check_finished_leds(uint8_t led_idx) { uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT; return led_idx < k_led_matrix_split[0]; } else - return led_idx < DRIVER_LED_TOTAL; + return led_idx < LED_MATRIX_LED_COUNT; #else - return led_idx < DRIVER_LED_TOTAL; + return led_idx < LED_MATRIX_LED_COUNT; #endif } diff --git a/quantum/led_matrix/led_matrix_drivers.c b/quantum/led_matrix/led_matrix_drivers.c index f437b3ede2..eb0f2e4ad5 100644 --- a/quantum/led_matrix/led_matrix_drivers.c +++ b/quantum/led_matrix/led_matrix_drivers.c @@ -96,7 +96,7 @@ static void init(void) { # endif # endif - for (int index = 0; index < DRIVER_LED_TOTAL; index++) { + for (int index = 0; index < LED_MATRIX_LED_COUNT; index++) { # if defined(IS31FL3731) IS31FL3731_set_led_control_register(index, true); # elif defined(IS31FL3733) diff --git a/quantum/led_matrix/led_matrix_types.h b/quantum/led_matrix/led_matrix_types.h index 3dc533100f..6d79a3592d 100644 --- a/quantum/led_matrix/led_matrix_types.h +++ b/quantum/led_matrix/led_matrix_types.h @@ -76,8 +76,8 @@ typedef struct PACKED { typedef struct PACKED { uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS]; - led_point_t point[DRIVER_LED_TOTAL]; - uint8_t flags[DRIVER_LED_TOTAL]; + led_point_t point[LED_MATRIX_LED_COUNT]; + uint8_t flags[LED_MATRIX_LED_COUNT]; } led_config_t; typedef union { |