diff options
Diffstat (limited to 'quantum/led_matrix.c')
| -rw-r--r-- | quantum/led_matrix.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/quantum/led_matrix.c b/quantum/led_matrix.c index 7e0fdf896..9b6151604 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,8 @@ 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(); | ||
| 289 | led_update_eeprom = false; | ||
| 283 | if (sync_timer_elapsed32(g_led_timer) >= LED_MATRIX_LED_FLUSH_LIMIT) led_task_state = STARTING; | 290 | if (sync_timer_elapsed32(g_led_timer) >= LED_MATRIX_LED_FLUSH_LIMIT) led_task_state = STARTING; |
| 284 | } | 291 | } |
| 285 | 292 | ||
| @@ -469,9 +476,7 @@ bool led_matrix_get_suspend_state(void) { return suspend_state; } | |||
| 469 | void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { | 476 | void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) { |
| 470 | led_matrix_eeconfig.enable ^= 1; | 477 | led_matrix_eeconfig.enable ^= 1; |
| 471 | led_task_state = STARTING; | 478 | led_task_state = STARTING; |
| 472 | if (write_to_eeprom) { | 479 | 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); | 480 | dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable); |
| 476 | } | 481 | } |
| 477 | void led_matrix_toggle_noeeprom(void) { led_matrix_toggle_eeprom_helper(false); } | 482 | void led_matrix_toggle_noeeprom(void) { led_matrix_toggle_eeprom_helper(false); } |
| @@ -479,7 +484,7 @@ void led_matrix_toggle(void) { led_matrix_toggle_eeprom_helper(true); } | |||
| 479 | 484 | ||
| 480 | void led_matrix_enable(void) { | 485 | void led_matrix_enable(void) { |
| 481 | led_matrix_enable_noeeprom(); | 486 | led_matrix_enable_noeeprom(); |
| 482 | eeconfig_update_led_matrix(); | 487 | led_eeconfig_update(true); |
| 483 | } | 488 | } |
| 484 | 489 | ||
| 485 | void led_matrix_enable_noeeprom(void) { | 490 | void led_matrix_enable_noeeprom(void) { |
| @@ -489,7 +494,7 @@ void led_matrix_enable_noeeprom(void) { | |||
| 489 | 494 | ||
| 490 | void led_matrix_disable(void) { | 495 | void led_matrix_disable(void) { |
| 491 | led_matrix_disable_noeeprom(); | 496 | led_matrix_disable_noeeprom(); |
| 492 | eeconfig_update_led_matrix(); | 497 | led_eeconfig_update(true); |
| 493 | } | 498 | } |
| 494 | 499 | ||
| 495 | void led_matrix_disable_noeeprom(void) { | 500 | void led_matrix_disable_noeeprom(void) { |
| @@ -511,9 +516,7 @@ void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { | |||
| 511 | led_matrix_eeconfig.mode = mode; | 516 | led_matrix_eeconfig.mode = mode; |
| 512 | } | 517 | } |
| 513 | led_task_state = STARTING; | 518 | led_task_state = STARTING; |
| 514 | if (write_to_eeprom) { | 519 | 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); | 520 | dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode); |
| 518 | } | 521 | } |
| 519 | void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); } | 522 | void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); } |
| @@ -540,9 +543,7 @@ void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) { | |||
| 540 | return; | 543 | return; |
| 541 | } | 544 | } |
| 542 | led_matrix_eeconfig.val = (val > LED_MATRIX_MAXIMUM_BRIGHTNESS) ? LED_MATRIX_MAXIMUM_BRIGHTNESS : val; | 545 | led_matrix_eeconfig.val = (val > LED_MATRIX_MAXIMUM_BRIGHTNESS) ? LED_MATRIX_MAXIMUM_BRIGHTNESS : val; |
| 543 | if (write_to_eeprom) { | 546 | 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); | 547 | dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val); |
| 547 | } | 548 | } |
| 548 | void led_matrix_set_val_noeeprom(uint8_t val) { led_matrix_set_val_eeprom_helper(val, false); } | 549 | void led_matrix_set_val_noeeprom(uint8_t val) { led_matrix_set_val_eeprom_helper(val, false); } |
| @@ -560,9 +561,7 @@ void led_matrix_decrease_val(void) { led_matrix_decrease_val_helper(true); } | |||
| 560 | 561 | ||
| 561 | void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { | 562 | void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { |
| 562 | led_matrix_eeconfig.speed = speed; | 563 | led_matrix_eeconfig.speed = speed; |
| 563 | if (write_to_eeprom) { | 564 | 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); | 565 | dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed); |
| 567 | } | 566 | } |
| 568 | void led_matrix_set_speed_noeeprom(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, false); } | 567 | void led_matrix_set_speed_noeeprom(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, false); } |
