fw-rust: Improve setup screen
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Remove redundant match arms when handling inputs and code when drawing
the setup screen.
This commit is contained in:
finga 2022-04-02 18:42:52 +02:00
parent c36581e703
commit b51511dbab

View file

@ -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) {
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);
match &self.active {
Selection::Contrast => {
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:");