RGB/LED matrix use limits size optimisation (#22325)
parent
896d3dc497
commit
f293658147
|
@ -375,14 +375,7 @@ void led_matrix_indicators_advanced(effect_params_t *params) {
|
||||||
* and not sure which would be better. Otherwise, this should be called from
|
* and not sure which would be better. Otherwise, this should be called from
|
||||||
* led_task_render, right before the iter++ line.
|
* 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 < LED_MATRIX_LED_COUNT
|
LED_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1);
|
||||||
uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * (params->iter - 1);
|
|
||||||
uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT;
|
|
||||||
if (max > LED_MATRIX_LED_COUNT) max = LED_MATRIX_LED_COUNT;
|
|
||||||
#else
|
|
||||||
uint8_t min = 0;
|
|
||||||
uint8_t max = LED_MATRIX_LED_COUNT;
|
|
||||||
#endif
|
|
||||||
led_matrix_indicators_advanced_kb(min, max);
|
led_matrix_indicators_advanced_kb(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,6 +387,36 @@ __attribute__((weak)) bool led_matrix_indicators_advanced_user(uint8_t led_min,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct led_matrix_limits_t led_matrix_get_limits(uint8_t iter) {
|
||||||
|
struct led_matrix_limits_t limits = {0};
|
||||||
|
#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)
|
||||||
|
limits.led_min_index = LED_MATRIX_LED_PROCESS_LIMIT * (iter);
|
||||||
|
limits.led_max_index = limits.led_min_index + LED_MATRIX_LED_PROCESS_LIMIT;
|
||||||
|
if (limits.led_max_index > LED_MATRIX_LED_COUNT) limits.led_max_index = LED_MATRIX_LED_COUNT;
|
||||||
|
uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT;
|
||||||
|
if (is_keyboard_left() && (limits.led_max_index > k_led_matrix_split[0])) limits.led_max_index = k_led_matrix_split[0];
|
||||||
|
if (!(is_keyboard_left()) && (limits.led_min_index < k_led_matrix_split[0])) limits.led_min_index = k_led_matrix_split[0];
|
||||||
|
# else
|
||||||
|
limits.led_min_index = LED_MATRIX_LED_PROCESS_LIMIT * (iter);
|
||||||
|
limits.led_max_index = limits.led_min_index + LED_MATRIX_LED_PROCESS_LIMIT;
|
||||||
|
if (limits.led_max_index > LED_MATRIX_LED_COUNT) limits.led_max_index = LED_MATRIX_LED_COUNT;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if defined(LED_MATRIX_SPLIT)
|
||||||
|
limits.led_min_index = 0;
|
||||||
|
limits.led_max_index = LED_MATRIX_LED_COUNT;
|
||||||
|
const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT;
|
||||||
|
if (is_keyboard_left() && (limits.led_max_index > k_led_matrix_split[0])) limits.led_max_index = k_led_matrix_split[0];
|
||||||
|
if (!(is_keyboard_left()) && (limits.led_min_index < k_led_matrix_split[0])) limits.led_min_index = k_led_matrix_split[0];
|
||||||
|
# else
|
||||||
|
limits.led_min_index = 0;
|
||||||
|
limits.led_max_index = LED_MATRIX_LED_COUNT;
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
return limits;
|
||||||
|
}
|
||||||
|
|
||||||
void led_matrix_init(void) {
|
void led_matrix_init(void) {
|
||||||
led_matrix_driver.init();
|
led_matrix_driver.init();
|
||||||
|
|
||||||
|
|
|
@ -89,35 +89,21 @@
|
||||||
# define LED_MATRIX_LED_PROCESS_LIMIT ((LED_MATRIX_LED_COUNT + 4) / 5)
|
# define LED_MATRIX_LED_PROCESS_LIMIT ((LED_MATRIX_LED_COUNT + 4) / 5)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < LED_MATRIX_LED_COUNT
|
struct led_matrix_limits_t {
|
||||||
# if defined(LED_MATRIX_SPLIT)
|
uint8_t led_min_index;
|
||||||
# define LED_MATRIX_USE_LIMITS(min, max) \
|
uint8_t led_max_index;
|
||||||
uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \
|
};
|
||||||
uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \
|
|
||||||
if (max > LED_MATRIX_LED_COUNT) max = LED_MATRIX_LED_COUNT; \
|
struct led_matrix_limits_t led_matrix_get_limits(uint8_t iter);
|
||||||
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]; \
|
#define LED_MATRIX_USE_LIMITS_ITER(min, max, iter) \
|
||||||
if (!(is_keyboard_left()) && (min < k_led_matrix_split[0])) min = k_led_matrix_split[0];
|
struct led_matrix_limits_t limits = led_matrix_get_limits(iter); \
|
||||||
# else
|
uint8_t min = limits.led_min_index; \
|
||||||
# define LED_MATRIX_USE_LIMITS(min, max) \
|
uint8_t max = limits.led_max_index; \
|
||||||
uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \
|
(void)min; \
|
||||||
uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \
|
(void)max;
|
||||||
if (max > LED_MATRIX_LED_COUNT) max = LED_MATRIX_LED_COUNT;
|
|
||||||
# endif
|
#define LED_MATRIX_USE_LIMITS(min, max) LED_MATRIX_USE_LIMITS_ITER(min, max, params->iter)
|
||||||
#else
|
|
||||||
# if defined(LED_MATRIX_SPLIT)
|
|
||||||
# define LED_MATRIX_USE_LIMITS(min, max) \
|
|
||||||
uint8_t min = 0; \
|
|
||||||
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 = LED_MATRIX_LED_COUNT;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LED_MATRIX_TEST_LED_FLAGS() \
|
#define LED_MATRIX_TEST_LED_FLAGS() \
|
||||||
if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue
|
if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue
|
||||||
|
|
|
@ -410,6 +410,36 @@ __attribute__((weak)) bool rgb_matrix_indicators_user(void) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct rgb_matrix_limits_t rgb_matrix_get_limits(uint8_t iter) {
|
||||||
|
struct rgb_matrix_limits_t limits = {0};
|
||||||
|
#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)
|
||||||
|
limits.led_min_index = RGB_MATRIX_LED_PROCESS_LIMIT * (iter);
|
||||||
|
limits.led_max_index = limits.led_min_index + RGB_MATRIX_LED_PROCESS_LIMIT;
|
||||||
|
if (limits.led_max_index > RGB_MATRIX_LED_COUNT) limits.led_max_index = RGB_MATRIX_LED_COUNT;
|
||||||
|
uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
|
||||||
|
if (is_keyboard_left() && (limits.led_max_index > k_rgb_matrix_split[0])) limits.led_max_index = k_rgb_matrix_split[0];
|
||||||
|
if (!(is_keyboard_left()) && (limits.led_min_index < k_rgb_matrix_split[0])) limits.led_min_index = k_rgb_matrix_split[0];
|
||||||
|
# else
|
||||||
|
limits.led_min_index = RGB_MATRIX_LED_PROCESS_LIMIT * (iter);
|
||||||
|
limits.led_max_index = limits.led_min_index + RGB_MATRIX_LED_PROCESS_LIMIT;
|
||||||
|
if (limits.led_max_index > RGB_MATRIX_LED_COUNT) limits.led_max_index = RGB_MATRIX_LED_COUNT;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if defined(RGB_MATRIX_SPLIT)
|
||||||
|
limits.led_min_index = 0;
|
||||||
|
limits.led_max_index = RGB_MATRIX_LED_COUNT;
|
||||||
|
const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
|
||||||
|
if (is_keyboard_left() && (limits.led_max_index > k_rgb_matrix_split[0])) limits.led_max_index = k_rgb_matrix_split[0];
|
||||||
|
if (!(is_keyboard_left()) && (limits.led_min_index < k_rgb_matrix_split[0])) limits.led_min_index = k_rgb_matrix_split[0];
|
||||||
|
# else
|
||||||
|
limits.led_min_index = 0;
|
||||||
|
limits.led_max_index = RGB_MATRIX_LED_COUNT;
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
return limits;
|
||||||
|
}
|
||||||
|
|
||||||
void rgb_matrix_indicators_advanced(effect_params_t *params) {
|
void rgb_matrix_indicators_advanced(effect_params_t *params) {
|
||||||
/* special handling is needed for "params->iter", since it's already been incremented.
|
/* special handling is needed for "params->iter", since it's already been incremented.
|
||||||
* Could move the invocations to rgb_task_render, but then it's missing a few checks
|
* Could move the invocations to rgb_task_render, but then it's missing a few checks
|
||||||
|
|
|
@ -107,35 +107,19 @@
|
||||||
# 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
|
#endif
|
||||||
|
|
||||||
#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT
|
struct rgb_matrix_limits_t {
|
||||||
# if defined(RGB_MATRIX_SPLIT)
|
uint8_t led_min_index;
|
||||||
# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
|
uint8_t led_max_index;
|
||||||
uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \
|
};
|
||||||
uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
|
|
||||||
if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; \
|
struct rgb_matrix_limits_t rgb_matrix_get_limits(uint8_t iter);
|
||||||
uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
|
|
||||||
if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
|
#define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
|
||||||
if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
|
struct rgb_matrix_limits_t limits = rgb_matrix_get_limits(iter); \
|
||||||
# else
|
uint8_t min = limits.led_min_index; \
|
||||||
# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
|
uint8_t max = limits.led_max_index; \
|
||||||
uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \
|
(void)min; \
|
||||||
uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
|
(void)max;
|
||||||
if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT;
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# if defined(RGB_MATRIX_SPLIT)
|
|
||||||
# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
|
|
||||||
uint8_t min = 0; \
|
|
||||||
uint8_t max = RGB_MATRIX_LED_COUNT; \
|
|
||||||
const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
|
|
||||||
if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
|
|
||||||
if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
|
|
||||||
# else
|
|
||||||
# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
|
|
||||||
uint8_t min = 0; \
|
|
||||||
uint8_t max = RGB_MATRIX_LED_COUNT;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define RGB_MATRIX_USE_LIMITS(min, max) RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter)
|
#define RGB_MATRIX_USE_LIMITS(min, max) RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue