Fix RGB matrix not syncing and turning off properly on timeout (#25467)
This commit is contained in:
parent
64c84e64c7
commit
cb3149b7f2
2 changed files with 36 additions and 28 deletions
|
|
@ -78,11 +78,12 @@ static const uint8_t led_matrix_flag_steps[] = LED_MATRIX_FLAG_STEPS;
|
||||||
#define LED_MATRIX_FLAG_STEPS_COUNT ARRAY_SIZE(led_matrix_flag_steps)
|
#define LED_MATRIX_FLAG_STEPS_COUNT ARRAY_SIZE(led_matrix_flag_steps)
|
||||||
|
|
||||||
// internals
|
// internals
|
||||||
static bool suspend_state = false;
|
static bool suspend_state = false;
|
||||||
static uint8_t led_last_enable = UINT8_MAX;
|
static uint8_t led_last_enable = UINT8_MAX;
|
||||||
static uint8_t led_last_effect = UINT8_MAX;
|
static uint8_t led_last_effect = UINT8_MAX;
|
||||||
static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false};
|
static uint8_t led_current_effect = 0;
|
||||||
static led_task_states led_task_state = SYNCING;
|
static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false};
|
||||||
|
static led_task_states led_task_state = SYNCING;
|
||||||
|
|
||||||
// double buffers
|
// double buffers
|
||||||
static uint32_t led_timer_buffer;
|
static uint32_t led_timer_buffer;
|
||||||
|
|
@ -268,6 +269,17 @@ static void led_task_start(void) {
|
||||||
g_last_hit_tracker = last_hit_buffer;
|
g_last_hit_tracker = last_hit_buffer;
|
||||||
#endif // LED_MATRIX_KEYREACTIVE_ENABLED
|
#endif // LED_MATRIX_KEYREACTIVE_ENABLED
|
||||||
|
|
||||||
|
// 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_MATRIX_TIMEOUT > 0
|
||||||
|
(last_input_activity_elapsed() > (uint32_t)LED_MATRIX_TIMEOUT) ||
|
||||||
|
#endif // LED_MATRIX_TIMEOUT > 0
|
||||||
|
false;
|
||||||
|
|
||||||
|
// Set effect to be renedered
|
||||||
|
led_current_effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode;
|
||||||
|
|
||||||
// next task
|
// next task
|
||||||
led_task_state = RENDERING;
|
led_task_state = RENDERING;
|
||||||
}
|
}
|
||||||
|
|
@ -349,15 +361,7 @@ static void led_task_flush(uint8_t effect) {
|
||||||
void led_matrix_task(void) {
|
void led_matrix_task(void) {
|
||||||
led_task_timers();
|
led_task_timers();
|
||||||
|
|
||||||
// Ideally we would also stop sending zeros to the LED driver PWM buffers
|
uint8_t effect = led_current_effect;
|
||||||
// while suspended and just do a software shutdown. This is a cheap hack for now.
|
|
||||||
bool suspend_backlight = suspend_state ||
|
|
||||||
#if LED_MATRIX_TIMEOUT > 0
|
|
||||||
(last_input_activity_elapsed() > (uint32_t)LED_MATRIX_TIMEOUT) ||
|
|
||||||
#endif // LED_MATRIX_TIMEOUT > 0
|
|
||||||
false;
|
|
||||||
|
|
||||||
uint8_t effect = suspend_backlight || !led_matrix_eeconfig.enable ? 0 : led_matrix_eeconfig.mode;
|
|
||||||
|
|
||||||
switch (led_task_state) {
|
switch (led_task_state) {
|
||||||
case STARTING:
|
case STARTING:
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,12 @@ static const uint8_t rgb_matrix_flag_steps[] = RGB_MATRIX_FLAG_STEPS;
|
||||||
#define RGB_MATRIX_FLAG_STEPS_COUNT ARRAY_SIZE(rgb_matrix_flag_steps)
|
#define RGB_MATRIX_FLAG_STEPS_COUNT ARRAY_SIZE(rgb_matrix_flag_steps)
|
||||||
|
|
||||||
// internals
|
// internals
|
||||||
static bool suspend_state = false;
|
static bool suspend_state = false;
|
||||||
static uint8_t rgb_last_enable = UINT8_MAX;
|
static uint8_t rgb_last_enable = UINT8_MAX;
|
||||||
static uint8_t rgb_last_effect = UINT8_MAX;
|
static uint8_t rgb_last_effect = UINT8_MAX;
|
||||||
static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
|
static uint8_t rgb_current_effect = 0;
|
||||||
static rgb_task_states rgb_task_state = SYNCING;
|
static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
|
||||||
|
static rgb_task_states rgb_task_state = SYNCING;
|
||||||
|
|
||||||
// double buffers
|
// double buffers
|
||||||
static uint32_t rgb_timer_buffer;
|
static uint32_t rgb_timer_buffer;
|
||||||
|
|
@ -296,6 +297,17 @@ static void rgb_task_start(void) {
|
||||||
g_last_hit_tracker = last_hit_buffer;
|
g_last_hit_tracker = last_hit_buffer;
|
||||||
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
|
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
|
||||||
|
|
||||||
|
// 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 RGB_MATRIX_TIMEOUT > 0
|
||||||
|
(last_input_activity_elapsed() > (uint32_t)RGB_MATRIX_TIMEOUT) ||
|
||||||
|
#endif // RGB_MATRIX_TIMEOUT > 0
|
||||||
|
false;
|
||||||
|
|
||||||
|
// Set effect to be renedered
|
||||||
|
rgb_current_effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
|
||||||
|
|
||||||
// next task
|
// next task
|
||||||
rgb_task_state = RENDERING;
|
rgb_task_state = RENDERING;
|
||||||
}
|
}
|
||||||
|
|
@ -384,15 +396,7 @@ static void rgb_task_flush(uint8_t effect) {
|
||||||
void rgb_matrix_task(void) {
|
void rgb_matrix_task(void) {
|
||||||
rgb_task_timers();
|
rgb_task_timers();
|
||||||
|
|
||||||
// Ideally we would also stop sending zeros to the LED driver PWM buffers
|
uint8_t effect = rgb_current_effect;
|
||||||
// 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
|
|
||||||
(last_input_activity_elapsed() > (uint32_t)RGB_MATRIX_TIMEOUT) ||
|
|
||||||
#endif // RGB_MATRIX_TIMEOUT > 0
|
|
||||||
false;
|
|
||||||
|
|
||||||
uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
|
|
||||||
|
|
||||||
switch (rgb_task_state) {
|
switch (rgb_task_state) {
|
||||||
case STARTING:
|
case STARTING:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue