diff --git a/firmware/rust/src/main.rs b/firmware/rust/src/main.rs index 1bb4ff1..ddea84b 100644 --- a/firmware/rust/src/main.rs +++ b/firmware/rust/src/main.rs @@ -426,38 +426,34 @@ struct HomeScreen { } impl HomeScreen { - fn input(&self, input: &Input) -> Screens { - match input { - Input::Next => match self.active { - HomeSelection::Ch1 => Screens::Home(HomeScreen { - active: HomeSelection::Ch2, - }), - HomeSelection::Ch2 => Screens::Home(HomeScreen { - active: HomeSelection::Ch3, - }), - HomeSelection::Ch3 => Screens::Home(HomeScreen { - active: HomeSelection::Setup, - }), - HomeSelection::Setup => Screens::Home(HomeScreen { - active: HomeSelection::Ch1, - }), - }, - Input::Previous => match self.active { - HomeSelection::Ch1 => Screens::Home(HomeScreen { - active: HomeSelection::Setup, - }), - HomeSelection::Ch2 => Screens::Home(HomeScreen { - active: HomeSelection::Ch1, - }), - HomeSelection::Ch3 => Screens::Home(HomeScreen { - active: HomeSelection::Ch2, - }), - HomeSelection::Setup => Screens::Home(HomeScreen { - active: HomeSelection::Ch3, - }), - }, + fn new() -> Self { + Self { + active: HomeSelection::Ch1, } } + + fn input(&self, input: &Input) -> Screens { + Screens::Home(Self { + active: match self.active { + HomeSelection::Ch1 => match input { + Input::Next => HomeSelection::Ch2, + Input::Previous => HomeSelection::Setup, + }, + HomeSelection::Ch2 => match input { + Input::Next => HomeSelection::Ch3, + Input::Previous => HomeSelection::Ch1, + }, + HomeSelection::Ch3 => match input { + Input::Next => HomeSelection::Setup, + Input::Previous => HomeSelection::Ch2, + }, + HomeSelection::Setup => match input { + Input::Next => HomeSelection::Ch1, + Input::Previous => HomeSelection::Ch3, + }, + }, + }) + } } impl Draw for HomeScreen { @@ -586,9 +582,7 @@ fn main() -> ! { delay.delay_ms(2000_u16); // Set home screen - screen = Screens::Home(HomeScreen { - active: HomeSelection::Ch1, - }); + screen = Screens::Home(HomeScreen::new()); // Draw screen lcd.draw(&screen);