diff options
Diffstat (limited to 'quantum/led_matrix.c')
-rw-r--r-- | quantum/led_matrix.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c index 7e0fdf896..e7e933e1d 100644 --- a/quantum/led_matrix.c +++ b/quantum/led_matrix.c | |||
@@ -33,6 +33,14 @@ const led_point_t k_led_matrix_center = {112, 32}; | |||
33 | const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; | 33 | const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | // clang-format off | ||
37 | #ifndef LED_MATRIX_IMMEDIATE_EEPROM | ||
38 | # define led_eeconfig_update(v) led_update_eeprom |= v | ||
39 | #else | ||
40 | # define led_eeconfig_update(v) if (v) eeconfig_update_led_matrix() | ||
41 | #endif | ||
42 | // clang-format on | ||
43 | |||
36 | // Generic effect runners | 44 | // Generic effect runners |
37 | #include "led_matrix_runners/effect_runner_dx_dy_dist.h" | 45 | #include "led_matrix_runners/effect_runner_dx_dy_dist.h" |
38 | #include "led_matrix_runners/effect_runner_dx_dy.h" | 46 | #include "led_matrix_runners/effect_runner_dx_dy.h" |
@@ -67,10 +75,6 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; | |||
67 | # define LED_DISABLE_TIMEOUT 0 | 75 | # define LED_DISABLE_TIMEOUT 0 |
68 | #endif | 76 | #endif |
69 | 77 | ||
70 | #if LED_DISABLE_WHEN_USB_SUSPENDED != 1 | ||
71 | # undef LED_DISABLE_WHEN_USB_SUSPENDED | ||
72 | #endif | ||
73 | |||
74 | #if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX | 78 | #if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX |
75 | # undef LED_MATRIX_MAXIMUM_BRIGHTNESS | 79 | # undef LED_MATRIX_MAXIMUM_BRIGHTNESS |
76 | # define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX | 80 | # define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX |
@@ -108,6 +112,7 @@ last_hit_t g_last_hit_tracker; | |||
108 | 112 | ||
109 | // internals | 113 | // internals |
110 | static bool suspend_state = false; | 114 | static bool suspend_state = false; |
115 | static bool led_update_eeprom = false; | ||
111 | static uint8_t led_last_enable = UINT8_MAX; | 116 | static uint8_t led_last_enable = UINT8_MAX; |
112 | static uint8_t led_last_effect = UINT8_MAX; | 117 | static uint8_t led_last_effect = UINT8_MAX; |
113 | static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; | 118 | static effect_params_t led_effect_params = {0, LED_FLAG_ALL, false}; |
@@ -280,6 +285,7 @@ static void led_task_timers(void) { | |||
280 | 285 | ||
281 | static void led_task_sync(void) { | 286 | static void led_task_sync(void) { |
282 | // next task | 287 | // next task |
288 | if (led_update_eeprom) eeconfig_update_led_matrix(); | ||
283 | if (sync_timer_elapsed32(g_led_timer) >= LED_MATRIX_LED_FLUSH_LIMIT) led_task_state = STARTING; | 289 | if (sync_timer_elapsed32(g_led_timer) >= LED_MATRIX_LED_FLUSH_LIMIT) led_task_state = STARTING; |
284 | } | 290 | } |
285 | 291 | ||
@@ -469,9 +475,7 @@ bool led_matrix_get_suspend_state(void) { return suspend_state; } | |||
469 | void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { | 475 | void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { |
470 | led_matrix_eeconfig.enable ^= 1; | 476 | led_matrix_eeconfig.enable ^= 1; |
471 | led_task_state = STARTING; | 477 | led_task_state = STARTING; |
472 | if (write_to_eeprom) { | 478 | led_eeconfig_update(write_to_eeprom); |
473 | eeconfig_update_led_matrix(); | ||
474 | } | ||
475 | dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable); | 479 | dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable); |
476 | } | 480 | } |
477 | void led_matrix_toggle_noeeprom(void) { led_matrix_toggle_eeprom_helper(false); } | 481 | void led_matrix_toggle_noeeprom(void) { led_matrix_toggle_eeprom_helper(false); } |
@@ -479,7 +483,7 @@ void led_matrix_toggle(void) { led_matrix_toggle_eeprom_helper(true); } | |||
479 | 483 | ||
480 | void led_matrix_enable(void) { | 484 | void led_matrix_enable(void) { |
481 | led_matrix_enable_noeeprom(); | 485 | led_matrix_enable_noeeprom(); |
482 | eeconfig_update_led_matrix(); | 486 | led_eeconfig_update(true); |
483 | } | 487 | } |
484 | 488 | ||
485 | void led_matrix_enable_noeeprom(void) { | 489 | void led_matrix_enable_noeeprom(void) { |
@@ -489,7 +493,7 @@ void led_matrix_enable_noeeprom(void) { | |||
489 | 493 | ||
490 | void led_matrix_disable(void) { | 494 | void led_matrix_disable(void) { |
491 | led_matrix_disable_noeeprom(); | 495 | led_matrix_disable_noeeprom(); |
492 | eeconfig_update_led_matrix(); | 496 | led_eeconfig_update(true); |
493 | } | 497 | } |
494 | 498 | ||
495 | void led_matrix_disable_noeeprom(void) { | 499 | void led_matrix_disable_noeeprom(void) { |
@@ -511,9 +515,7 @@ void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | |||
511 | led_matrix_eeconfig.mode = mode; | 515 | led_matrix_eeconfig.mode = mode; |
512 | } | 516 | } |
513 | led_task_state = STARTING; | 517 | led_task_state = STARTING; |
514 | if (write_to_eeprom) { | 518 | led_eeconfig_update(write_to_eeprom); |
515 | eeconfig_update_led_matrix(); | ||
516 | } | ||
517 | dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode); | 519 | dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode); |
518 | } | 520 | } |
519 | void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); } | 521 | void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); } |
@@ -540,9 +542,7 @@ void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) { | |||
540 | return; | 542 | return; |
541 | } | 543 | } |
542 | led_matrix_eeconfig.val = (val > LED_MATRIX_MAXIMUM_BRIGHTNESS) ? LED_MATRIX_MAXIMUM_BRIGHTNESS : val; | 544 | led_matrix_eeconfig.val = (val > LED_MATRIX_MAXIMUM_BRIGHTNESS) ? LED_MATRIX_MAXIMUM_BRIGHTNESS : val; |
543 | if (write_to_eeprom) { | 545 | led_eeconfig_update(write_to_eeprom); |
544 | eeconfig_update_led_matrix(); | ||
545 | } | ||
546 | dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val); | 546 | dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val); |
547 | } | 547 | } |
548 | void led_matrix_set_val_noeeprom(uint8_t val) { led_matrix_set_val_eeprom_helper(val, false); } | 548 | void led_matrix_set_val_noeeprom(uint8_t val) { led_matrix_set_val_eeprom_helper(val, false); } |
@@ -560,9 +560,7 @@ void led_matrix_decrease_val(void) { led_matrix_decrease_val_helper(true); } | |||
560 | 560 | ||
561 | void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { | 561 | void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { |
562 | led_matrix_eeconfig.speed = speed; | 562 | led_matrix_eeconfig.speed = speed; |
563 | if (write_to_eeprom) { | 563 | led_eeconfig_update(write_to_eeprom); |
564 | eeconfig_update_led_matrix(); | ||
565 | } | ||
566 | dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed); | 564 | dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed); |
567 | } | 565 | } |
568 | void led_matrix_set_speed_noeeprom(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, false); } | 566 | void led_matrix_set_speed_noeeprom(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, false); } |