summaryrefslogtreecommitdiff
path: root/quantum/led_matrix/led_matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/led_matrix/led_matrix.c')
-rw-r--r--quantum/led_matrix/led_matrix.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c
index 50510e49aa..2f0086d368 100644
--- a/quantum/led_matrix/led_matrix.c
+++ b/quantum/led_matrix/led_matrix.c
@@ -33,14 +33,6 @@ const led_point_t k_led_matrix_center = {112, 32};
const led_point_t k_led_matrix_center = LED_MATRIX_CENTER;
#endif
-// clang-format off
-#ifndef LED_MATRIX_IMMEDIATE_EEPROM
-# define led_eeconfig_update(v) led_update_eeprom |= v
-#else
-# define led_eeconfig_update(v) if (v) eeconfig_update_led_matrix()
-#endif
-// clang-format on
-
// Generic effect runners
#include "led_matrix_runners.inc"
@@ -107,7 +99,6 @@ last_hit_t g_last_hit_tracker;
// internals
static bool suspend_state = false;
-static bool led_update_eeprom = false;
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};
@@ -127,9 +118,7 @@ static last_hit_t last_hit_buffer;
const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT;
#endif
-void eeconfig_read_led_matrix(void) { eeprom_read_block(&led_matrix_eeconfig, EECONFIG_LED_MATRIX, sizeof(led_matrix_eeconfig)); }
-
-void eeconfig_update_led_matrix(void) { eeprom_update_block(&led_matrix_eeconfig, EECONFIG_LED_MATRIX, sizeof(led_matrix_eeconfig)); }
+EECONFIG_DEBOUNCE_HELPER(led_matrix, EECONFIG_LED_MATRIX, led_matrix_eeconfig);
void eeconfig_update_led_matrix_default(void) {
dprintf("eeconfig_update_led_matrix_default\n");
@@ -138,7 +127,7 @@ void eeconfig_update_led_matrix_default(void) {
led_matrix_eeconfig.val = LED_MATRIX_STARTUP_VAL;
led_matrix_eeconfig.speed = LED_MATRIX_STARTUP_SPD;
led_matrix_eeconfig.flags = LED_FLAG_ALL;
- eeconfig_update_led_matrix();
+ eeconfig_flush_led_matrix(true);
}
void eeconfig_debug_led_matrix(void) {
@@ -279,9 +268,8 @@ static void led_task_timers(void) {
}
static void led_task_sync(void) {
+ eeconfig_flush_led_matrix(false);
// next task
- if (led_update_eeprom) eeconfig_update_led_matrix();
- led_update_eeprom = false;
if (sync_timer_elapsed32(g_led_timer) >= LED_MATRIX_LED_FLUSH_LIMIT) led_task_state = STARTING;
}
@@ -449,7 +437,7 @@ void led_matrix_init(void) {
eeconfig_update_led_matrix_default();
}
- eeconfig_read_led_matrix();
+ eeconfig_init_led_matrix();
if (!led_matrix_eeconfig.mode) {
dprintf("led_matrix_init_drivers led_matrix_eeconfig.mode = 0. Write default values to EEPROM.\n");
eeconfig_update_led_matrix_default();
@@ -472,7 +460,7 @@ bool led_matrix_get_suspend_state(void) { return suspend_state; }
void led_matrix_toggle_eeprom_helper(bool write_to_eeprom) {
led_matrix_eeconfig.enable ^= 1;
led_task_state = STARTING;
- led_eeconfig_update(write_to_eeprom);
+ eeconfig_flag_led_matrix(write_to_eeprom);
dprintf("led matrix toggle [%s]: led_matrix_eeconfig.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.enable);
}
void led_matrix_toggle_noeeprom(void) { led_matrix_toggle_eeprom_helper(false); }
@@ -480,7 +468,7 @@ void led_matrix_toggle(void) { led_matrix_toggle_eeprom_helper(true); }
void led_matrix_enable(void) {
led_matrix_enable_noeeprom();
- led_eeconfig_update(true);
+ eeconfig_flag_led_matrix(true);
}
void led_matrix_enable_noeeprom(void) {
@@ -490,7 +478,7 @@ void led_matrix_enable_noeeprom(void) {
void led_matrix_disable(void) {
led_matrix_disable_noeeprom();
- led_eeconfig_update(true);
+ eeconfig_flag_led_matrix(true);
}
void led_matrix_disable_noeeprom(void) {
@@ -512,7 +500,7 @@ void led_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) {
led_matrix_eeconfig.mode = mode;
}
led_task_state = STARTING;
- led_eeconfig_update(write_to_eeprom);
+ eeconfig_flag_led_matrix(write_to_eeprom);
dprintf("led matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.mode);
}
void led_matrix_mode_noeeprom(uint8_t mode) { led_matrix_mode_eeprom_helper(mode, false); }
@@ -539,7 +527,7 @@ void led_matrix_set_val_eeprom_helper(uint8_t val, bool write_to_eeprom) {
return;
}
led_matrix_eeconfig.val = (val > LED_MATRIX_MAXIMUM_BRIGHTNESS) ? LED_MATRIX_MAXIMUM_BRIGHTNESS : val;
- led_eeconfig_update(write_to_eeprom);
+ eeconfig_flag_led_matrix(write_to_eeprom);
dprintf("led matrix set val [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.val);
}
void led_matrix_set_val_noeeprom(uint8_t val) { led_matrix_set_val_eeprom_helper(val, false); }
@@ -557,7 +545,7 @@ void led_matrix_decrease_val(void) { led_matrix_decrease_val_helper(true); }
void led_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) {
led_matrix_eeconfig.speed = speed;
- led_eeconfig_update(write_to_eeprom);
+ eeconfig_flag_led_matrix(write_to_eeprom);
dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.speed);
}
void led_matrix_set_speed_noeeprom(uint8_t speed) { led_matrix_set_speed_eeprom_helper(speed, false); }