Code cleanup
This commit is contained in:
parent
be65b842fb
commit
79650dcc2b
@ -177,9 +177,9 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// Check if esc key is pressed while power on. If yes then enter bootloader
|
// Check if esc key is pressed while power on. If yes then enter bootloader
|
||||||
if button_matrix.buttons_pressed()[0] {
|
if button_matrix.buttons_pressed()[0] {
|
||||||
status_led.update(StatusMode::BOOTLOADER);
|
status_led.update(StatusMode::Bootloader);
|
||||||
let gpio_activity_pin_mask = 0;
|
let gpio_activity_pin_mask: u32 = 0;
|
||||||
let disable_interface_mask = 0;
|
let disable_interface_mask: u32 = 0;
|
||||||
rp2040_hal::rom_data::reset_to_usb_boot(gpio_activity_pin_mask, disable_interface_mask);
|
rp2040_hal::rom_data::reset_to_usb_boot(gpio_activity_pin_mask, disable_interface_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
fn_mode = get_fn_mode(pressed_keys);
|
fn_mode = get_fn_mode(pressed_keys);
|
||||||
|
|
||||||
if caps_lock_active == false {
|
if !caps_lock_active {
|
||||||
update_status_led(&mut status_led, caps_lock_active, gui_lock_active);
|
update_status_led(&mut status_led, caps_lock_active, gui_lock_active);
|
||||||
}
|
}
|
||||||
for (index, key) in pressed_keys.iter().enumerate() {
|
for (index, key) in pressed_keys.iter().enumerate() {
|
||||||
@ -212,7 +212,7 @@ fn main() -> ! {
|
|||||||
Err(UsbHidError::Duplicate) => {}
|
Err(UsbHidError::Duplicate) => {}
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
status_led.update(StatusMode::ERROR);
|
status_led.update(StatusMode::Error);
|
||||||
core::panic!("Failed to write keyboard report: {:?}", e)
|
core::panic!("Failed to write keyboard report: {:?}", e)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -225,7 +225,7 @@ fn main() -> ! {
|
|||||||
Err(UsbHidError::WouldBlock) => {}
|
Err(UsbHidError::WouldBlock) => {}
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
status_led.update(StatusMode::ERROR);
|
status_led.update(StatusMode::Error);
|
||||||
core::panic!("Failed to process keyboard tick: {:?}", e)
|
core::panic!("Failed to process keyboard tick: {:?}", e)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -235,7 +235,7 @@ fn main() -> ! {
|
|||||||
match keyboard.device().read_report() {
|
match keyboard.device().read_report() {
|
||||||
Err(UsbError::WouldBlock) => {}
|
Err(UsbError::WouldBlock) => {}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
status_led.update(StatusMode::ERROR);
|
status_led.update(StatusMode::Error);
|
||||||
core::panic!("Failed to read keyboard report: {:?}", e)
|
core::panic!("Failed to read keyboard report: {:?}", e)
|
||||||
}
|
}
|
||||||
Ok(leds) => {
|
Ok(leds) => {
|
||||||
@ -267,11 +267,11 @@ fn update_status_led<P, SM, I>(
|
|||||||
SM: StateMachineIndex,
|
SM: StateMachineIndex,
|
||||||
{
|
{
|
||||||
if caps_lock_active {
|
if caps_lock_active {
|
||||||
status_led.update(StatusMode::WARNING);
|
status_led.update(StatusMode::Warning);
|
||||||
} else if gui_lock_active {
|
} else if gui_lock_active {
|
||||||
status_led.update(StatusMode::ACTIVITY);
|
status_led.update(StatusMode::Activity);
|
||||||
} else {
|
} else {
|
||||||
status_led.update(StatusMode::NORMAL);
|
status_led.update(StatusMode::Normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ fn get_keyboard_report(
|
|||||||
if key.pressed != key.previous_pressed
|
if key.pressed != key.previous_pressed
|
||||||
&& key.pressed
|
&& key.pressed
|
||||||
&& index == layout::GUI_LOCK_BUTTON[0] as usize
|
&& index == layout::GUI_LOCK_BUTTON[0] as usize
|
||||||
&& *gui_lock_active == false
|
&& !(*gui_lock_active)
|
||||||
&& fn_mode == layout::GUI_LOCK_BUTTON[1]
|
&& fn_mode == layout::GUI_LOCK_BUTTON[1]
|
||||||
{
|
{
|
||||||
*gui_lock_active = true;
|
*gui_lock_active = true;
|
||||||
@ -345,7 +345,7 @@ fn get_keyboard_report(
|
|||||||
keyboard_report[GUI_REPORT_INDEX] = Keyboard::LeftGUI;
|
keyboard_report[GUI_REPORT_INDEX] = Keyboard::LeftGUI;
|
||||||
} else if *gui_lock_trigger_index as usize == index && key.pressed {
|
} else if *gui_lock_trigger_index as usize == index && key.pressed {
|
||||||
keyboard_report[GUI_REPORT_INDEX] = Keyboard::LeftGUI;
|
keyboard_report[GUI_REPORT_INDEX] = Keyboard::LeftGUI;
|
||||||
} else if *gui_lock_trigger_index as usize == index && key.pressed == false {
|
} else if *gui_lock_trigger_index as usize == index && !key.pressed {
|
||||||
*gui_lock_active = false;
|
*gui_lock_active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,13 +23,13 @@ use ws2812_pio::Ws2812Direct;
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
#[derive(PartialEq, Eq, Copy, Clone)]
|
||||||
pub enum StatusMode {
|
pub enum StatusMode {
|
||||||
OFF = 0,
|
Off = 0,
|
||||||
NORMAL = 1,
|
Normal = 1,
|
||||||
ACTIVITY = 2,
|
Activity = 2,
|
||||||
OTHER = 3,
|
Other = 3,
|
||||||
WARNING = 4,
|
Warning = 4,
|
||||||
ERROR = 5,
|
Error = 5,
|
||||||
BOOTLOADER = 6,
|
Bootloader = 6,
|
||||||
}
|
}
|
||||||
#[warn(dead_code)]
|
#[warn(dead_code)]
|
||||||
|
|
||||||
@ -110,12 +110,12 @@ where
|
|||||||
(0, 10, 10).into(), // Purple
|
(0, 10, 10).into(), // Purple
|
||||||
];
|
];
|
||||||
|
|
||||||
if mode == StatusMode::WARNING && self.state == false {
|
if mode == StatusMode::Warning && !self.state {
|
||||||
self.ws2812_direct
|
self.ws2812_direct
|
||||||
.write([colors[mode as usize]].iter().copied())
|
.write([colors[mode as usize]].iter().copied())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
self.state = true;
|
self.state = true;
|
||||||
} else if mode == StatusMode::WARNING || mode == StatusMode::OFF {
|
} else if mode == StatusMode::Warning || mode == StatusMode::Off {
|
||||||
self.ws2812_direct
|
self.ws2812_direct
|
||||||
.write([colors[0]].iter().copied())
|
.write([colors[0]].iter().copied())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user