From b51511dbabddfea1a2afa8fa8c4fa8d03aeaec36 Mon Sep 17 00:00:00 2001 From: finga Date: Sat, 2 Apr 2022 18:42:52 +0200 Subject: [PATCH] fw-rust: Improve setup screen Remove redundant match arms when handling inputs and code when drawing the setup screen. --- firmware/rust/src/screen/setup.rs | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/firmware/rust/src/screen/setup.rs b/firmware/rust/src/screen/setup.rs index 4de2cf8..a06ee70 100644 --- a/firmware/rust/src/screen/setup.rs +++ b/firmware/rust/src/screen/setup.rs @@ -99,8 +99,7 @@ impl Setup { Selection::Back => match input { Input::Next => Selection::Backlight, Input::Previous => Selection::Contrast, - Input::Select => return Event::Screen(Screens::Home(Home::new())), - Input::Back => return Event::Screen(Screens::Home(Home::new())), + _ => return Event::Screen(Screens::Home(Home::new())), }, }; @@ -108,11 +107,12 @@ impl Setup { } pub fn draw(&self, lcd: &mut Lcd) { + lcd.fill_area(0, 0, 33, 2, 0xFF); + lcd.print_inverted(33, 0, "SETUP"); + lcd.fill_area(69, 0, 33, 2, 0xFF); + match &self.active { Selection::Contrast => { - lcd.fill_area(0, 0, 33, 2, 0xFF); - lcd.print_inverted(33, 0, "SETUP"); - lcd.fill_area(69, 0, 33, 2, 0xFF); lcd.print(0, 2, "BACKLIGHT:"); lcd.print_u8(81, 2, 3, self.backlight); lcd.print_inverted(0, 4, "CONTRAST:"); @@ -120,9 +120,6 @@ impl Setup { lcd.print(36, 6, "BACK"); } Selection::ContrastEdit => { - lcd.fill_area(0, 0, 33, 2, 0xFF); - lcd.print_inverted(33, 0, "SETUP"); - lcd.fill_area(69, 0, 33, 2, 0xFF); lcd.print(0, 2, "BACKLIGHT:"); lcd.print_u8(81, 2, 3, self.backlight); lcd.print(0, 4, "CONTRAST:"); @@ -130,9 +127,6 @@ impl Setup { lcd.print(36, 6, "BACK"); } Selection::Backlight => { - lcd.fill_area(0, 0, 33, 2, 0xFF); - lcd.print_inverted(33, 0, "SETUP"); - lcd.fill_area(69, 0, 33, 2, 0xFF); lcd.print_inverted(0, 2, "BACKLIGHT:"); lcd.print_u8(81, 2, 3, self.backlight); lcd.print(0, 4, "CONTRAST:"); @@ -140,9 +134,6 @@ impl Setup { lcd.print(36, 6, "BACK"); } Selection::BacklightEdit => { - lcd.fill_area(0, 0, 33, 2, 0xFF); - lcd.print_inverted(33, 0, "SETUP"); - lcd.fill_area(69, 0, 33, 2, 0xFF); lcd.print(0, 2, "BACKLIGHT:"); lcd.print_u8_inverted(81, 2, 3, self.backlight); lcd.print(0, 4, "CONTRAST:"); @@ -150,9 +141,6 @@ impl Setup { lcd.print(36, 6, "BACK"); } Selection::Back => { - lcd.fill_area(0, 0, 33, 2, 0xFF); - lcd.print_inverted(33, 0, "SETUP"); - lcd.fill_area(69, 0, 33, 2, 0xFF); lcd.print(0, 2, "BACKLIGHT:"); lcd.print_u8(81, 2, 3, self.backlight); lcd.print(0, 4, "CONTRAST:");