From 96396d97f248df8f5426fb43996409ca8f5e5f01 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Thu, 27 Jan 2022 12:02:28 -0800 Subject: [PATCH 1/2] Add layout change callbacks to VIA --- quantum/via.c | 4 ++++ quantum/via.h | 1 + 2 files changed, 5 insertions(+) diff --git a/quantum/via.c b/quantum/via.c index 7c8aa753e762..a3bd82d9b3d0 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -96,6 +96,7 @@ void via_init(void) { // Let keyboard level test EEPROM valid state, // but not set it valid, it is done here. via_init_kb(); + via_set_layout_options_kb(via_get_layout_options()); // If the EEPROM has the magic, the data is good. // OK to load from EEPROM. @@ -131,7 +132,10 @@ uint32_t via_get_layout_options(void) { return value; } +__attribute__((weak)) void via_set_layout_options_kb(uint32_t value) {} + void via_set_layout_options(uint32_t value) { + via_set_layout_options_kb(value); // Start at the least significant byte void *target = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR + VIA_EEPROM_LAYOUT_OPTIONS_SIZE - 1); for (uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++) { diff --git a/quantum/via.h b/quantum/via.h index 3db318a45465..5d16917dfa4f 100644 --- a/quantum/via.h +++ b/quantum/via.h @@ -159,6 +159,7 @@ void via_init(void); // Used by VIA to store and retrieve the layout options. uint32_t via_get_layout_options(void); void via_set_layout_options(uint32_t value); +void via_set_layout_options_kb(uint32_t value); // Called by QMK core to process VIA-specific keycodes. bool process_record_via(uint16_t keycode, keyrecord_t *record); From d7777d555b90145d5a473542120bb81a0655b4e5 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Thu, 27 Jan 2022 12:53:48 -0800 Subject: [PATCH 2/2] Update worklouder example --- keyboards/work_louder/work_board/work_board.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/keyboards/work_louder/work_board/work_board.c b/keyboards/work_louder/work_board/work_board.c index 7a8edc1a9ea5..d25ea0cdbaf4 100644 --- a/keyboards/work_louder/work_board/work_board.c +++ b/keyboards/work_louder/work_board/work_board.c @@ -100,15 +100,15 @@ led_config_t g_led_config = { { } }; // clang-format on +# ifdef VIA_ENABLE +bool via_layout_2u = false; + +void via_set_layout_options_kb(uint32_t value) { via_layout_2u = (bool)value; } +# endif // VIA_ENABLE + __attribute__((weak)) void rgb_matrix_indicators_user(void) { # ifdef VIA_ENABLE - static bool layout_2u = false; - static uint16_t timer = 0; - if (timer_elapsed(timer) > 500) { - timer = timer_read(); - layout_2u = (bool)via_get_layout_options(); - } - if (layout_2u) { + if (via_layout_2u) { rgb_matrix_set_color(5, 0, 0, 0); rgb_matrix_set_color(7, 0, 0, 0); } else {