From 05798c19c10eb21eca7202af5f95c3df907449ba Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Thu, 30 Nov 2023 09:09:33 +0800 Subject: [PATCH] fl16: cleanup Signed-off-by: Daniel Schaefer --- keyboards/framework/factory.c | 16 ++------------- keyboards/framework/framework.c | 36 +++++++++++++++++++++++---------- keyboards/framework/framework.h | 6 ++++++ keyboards/framework/matrix.c | 20 ------------------ quantum/os_detection.c | 4 ---- 5 files changed, 33 insertions(+), 49 deletions(-) diff --git a/keyboards/framework/factory.c b/keyboards/framework/factory.c index 8260c32ad8..43890d210a 100644 --- a/keyboards/framework/factory.c +++ b/keyboards/framework/factory.c @@ -66,21 +66,9 @@ void handle_factory_command(uint8_t *data) { break; case f_bios_mode: if (command_data[0] == 0x01) { - bios_mode = true; - // Red -#if defined(RGB_MATRIX_ENABLE) - rgb_matrix_sethsv_noeeprom(0, 0xFF, 0xFF); - rgb_matrix_mode_noeeprom(1); -#endif - writePin(GP24, 1); + set_bios_mode(true); } else { - // White -#if defined(RGB_MATRIX_ENABLE) - rgb_matrix_sethsv_noeeprom(0, 0, 0xFF); - rgb_matrix_mode_noeeprom(1); -#endif - //bios_mode = false; - writePin(GP24, 0); + set_bios_mode(false); } break; case f_factory_mode: diff --git a/keyboards/framework/framework.c b/keyboards/framework/framework.c index 008e880890..16e8846b4b 100644 --- a/keyboards/framework/framework.c +++ b/keyboards/framework/framework.c @@ -67,6 +67,27 @@ void suspend_wakeup_init_kb(void) { // If in BIOS mode, no matter what the keys have been remapped to, always send them as the F keys bool bios_mode = true; +void set_bios_mode(bool val) { + bios_mode = val; + +#ifdef BIOS_HOTKEY_DEBUG + if (bios_mode) { + // Red +#if defined(RGB_MATRIX_ENABLE) + rgb_matrix_sethsv_noeeprom(0, 0xFF, 0xFF); + rgb_matrix_mode_noeeprom(1); +#endif + writePin(GP24, 1); + } else { + // White +#if defined(RGB_MATRIX_ENABLE) + rgb_matrix_sethsv_noeeprom(0, 0, 0xFF); + rgb_matrix_mode_noeeprom(1); +#endif + writePin(GP24, 0); + } +#endif +} bool handle_bios_hotkeys(uint16_t keycode, keyrecord_t *record) { // Not in bios mode, no special handling, handle as normal if (!bios_mode) @@ -176,11 +197,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { process_record_user(keycode, record); os_variant_t os = detected_host_os(); -#if defined(RGB_MATRIX_ENABLE) - //rgb_matrix_mode_noeeprom(1); -#endif - bios_mode = true; - writePin(GP24, 0); + set_bios_mode(true); //#if defined(RGB_MATRIX_ENABLE) // switch (os) { // case OS_UNSURE: @@ -217,19 +234,16 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { case OS_UNSURE: break; case OS_LINUX: - bios_mode = false; - writePin(GP24, 1); + set_bios_mode(false); break; case OS_WINDOWS: - bios_mode = false; - writePin(GP24, 1); + set_bios_mode(false); break; case OS_MACOS: break; case OS_UEFI: case OS_IOS: - bios_mode = true; - writePin(GP24, 0); + set_bios_mode(true); // works on M1 mac break; } diff --git a/keyboards/framework/framework.h b/keyboards/framework/framework.h index 7624af1d41..e69556f160 100644 --- a/keyboards/framework/framework.h +++ b/keyboards/framework/framework.h @@ -25,6 +25,12 @@ enum framework_keycodes { extern bool bios_mode; +// Uncomment this to show hotkey mode with capslock LED and backlight +// hotkey mode on: capslock ON, RGB red +// hotkey mode off: capslock OFF, RGB white +//#define BIOS_HOTKEY_DEBUG +void set_bios_mode(bool val); + #define SLEEP_GPIO GP0 #define MUX_ENABLE_GPIO GP4 #define BOOT_DONE_GPIO GP5 diff --git a/keyboards/framework/matrix.c b/keyboards/framework/matrix.c index 4774799257..36a3032700 100644 --- a/keyboards/framework/matrix.c +++ b/keyboards/framework/matrix.c @@ -313,26 +313,10 @@ bool handle_idle(void) { return false; } -#ifdef RGB_MATRIX_ENABLE -static bool rgb_init = false; -static uint16_t rgb_init_timer = 0; -#endif - /** * Overriding behavior of matrix_scan from quantum/matrix.c */ bool matrix_scan_custom(matrix_row_t current_matrix[]) { -#ifdef RGB_MATRIX_ENABLE - if (!rgb_init) { - if (!bios_mode) { - //if (rgb_init_timer > 0 && TIMER_DIFF_16(timer_read(), rgb_init_timer) >= 10000) { - //if (rgb_init_timer > 0 && TIMER_DIFF_16(timer_read(), rgb_init_timer) >= 100) { - //if (!bios_mode || rgb_init_timer > 0 && TIMER_DIFF_16(timer_read(), rgb_init_timer) >= 10000) { - //rgb_matrix_init(); - rgb_init = true; - } - } -#endif bool changed = false; adc10ksample_t voltages[MATRIX_ROWS][MATRIX_COLS] = {}; @@ -452,8 +436,4 @@ void matrix_init_custom(void) { // Set unused pins to input to avoid interfering. They're hooked up to rows 5 and 6 setPinInput(GP6); setPinInput(GP7); - -#ifdef RGB_MATRIX_ENABLE - rgb_init_timer = timer_read(); -#endif } diff --git a/quantum/os_detection.c b/quantum/os_detection.c index b3a6ade7a4..14d97493fb 100644 --- a/quantum/os_detection.c +++ b/quantum/os_detection.c @@ -54,10 +54,6 @@ void make_guess(void) { //if (setups_data.count < 3 && setups_data.cnt_zoid != 0) { // return; //} - //if (setups_data.cnt_zoid == 0) { - // detected_os = OS_UEFI; - // return; - //} if (setups_data.cnt_zoid == 0) { detected_os = OS_UEFI; return;