Code cleanup

This commit is contained in:
Christoffer Martinsson 2025-01-16 21:04:56 +01:00
parent 647635a67b
commit 06d1247701

View File

@ -161,8 +161,8 @@ fn main() -> ! {
let mut status_led_count_down = timer.count_down(); let mut status_led_count_down = timer.count_down();
status_led_count_down.start(250.millis()); status_led_count_down.start(250.millis());
let mut start_count_down = timer.count_down(); // let mut start_count_down = timer.count_down();
start_count_down.start(5000.millis()); // start_count_down.start(5000.millis());
// Create variables to track caps lock and fn mode // Create variables to track caps lock and fn mode
let mut caps_lock_active: bool = false; let mut caps_lock_active: bool = false;
@ -192,18 +192,18 @@ fn main() -> ! {
update_status_led(&mut status_led, &caps_lock_active, &sticky_state, &started); update_status_led(&mut status_led, &caps_lock_active, &sticky_state, &started);
} }
if start_count_down.wait().is_ok() && !started { // if start_count_down.wait().is_ok() && !started {
started = true; // started = true;
} // }
if usb_hid_report_count_down.wait().is_ok() { if usb_hid_report_count_down.wait().is_ok() {
let pressed_keys = button_matrix.buttons_pressed(); let pressed_keys = button_matrix.buttons_pressed();
fn_mode = get_fn_mode(pressed_keys); fn_mode = get_fn_mode(pressed_keys);
if !caps_lock_active && sticky_state != 2 { // if !caps_lock_active && sticky_state != 2 {
update_status_led(&mut status_led, &caps_lock_active, &sticky_state, &started); // update_status_led(&mut status_led, &caps_lock_active, &sticky_state, &started);
} // }
for (index, key) in pressed_keys.iter().enumerate() { for (index, key) in pressed_keys.iter().enumerate() {
buttons[index].pressed = *key; buttons[index].pressed = *key;
@ -245,6 +245,7 @@ fn main() -> ! {
} }
Ok(leds) => { Ok(leds) => {
caps_lock_active = leds.caps_lock; caps_lock_active = leds.caps_lock;
started = true;
} }
} }
} }
@ -265,7 +266,7 @@ fn update_status_led<P, SM, I>(
status_led: &mut Ws2812StatusLed<P, SM, I>, status_led: &mut Ws2812StatusLed<P, SM, I>,
caps_lock_active: &bool, caps_lock_active: &bool,
sticky_state: &u8, sticky_state: &u8,
_started: &bool, started: &bool,
) where ) where
P: PIOExt + FunctionConfig, P: PIOExt + FunctionConfig,
I: PinId, I: PinId,
@ -278,6 +279,8 @@ fn update_status_led<P, SM, I>(
status_led.update(StatusMode::Activity); status_led.update(StatusMode::Activity);
} else if *sticky_state == 2 { } else if *sticky_state == 2 {
status_led.update(StatusMode::ActivityFlash); status_led.update(StatusMode::ActivityFlash);
} else if !(*started) {
status_led.update(StatusMode::Warning);
} else { } else {
status_led.update(StatusMode::Normal); status_led.update(StatusMode::Normal);
} }