From 9c752c120e47b1f20c7128ced2928970434082d0 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Mon, 7 Aug 2023 19:25:22 +0800 Subject: [PATCH] fl16: Fix white backlight not recovering after reset If the backlight brightness was changed and the keyboard unplugged and replugged, the lights would stay off. They should come back to the previous value, which will happen automatically but the code would override. Signed-off-by: Daniel Schaefer --- keyboards/framework/matrix.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/keyboards/framework/matrix.c b/keyboards/framework/matrix.c index 5e713d802c..bd8860d740 100644 --- a/keyboards/framework/matrix.c +++ b/keyboards/framework/matrix.c @@ -51,6 +51,8 @@ // 29000 = 2.9V * 10000 const adc10ksample_t ADC_THRESHOLD = (adc10ksample_t) 29000; +bool have_slept = false; + adc10ksample_t to_voltage(adcsample_t sample) { int voltage = sample * 33000; return voltage / 1023; @@ -273,7 +275,12 @@ bool handle_idle(void) { if (is_backlight_enabled() != !asleep) { if (asleep) { backlight_disable(); - } else { + have_slept = true; + } else if (have_slept) { + // For some reason this will not set the proper value right after + // turning on. But the quantum code will have set it properly + // already, so there's no need to run this. Unless we actually wake + // up from sleep. backlight_enable_old_level(); } } @@ -369,7 +376,6 @@ static void adc_mux_init(void) { * Overriding behavior of matrix_init from quantum/matrix.c */ void matrix_init_custom(void) { - backlight_enable(); // To signal "live-ness" adc_mux_init(); adc_gpio_init(ADC_CH2_PIN);