reflow-firmware3.0/src/application/mod.rs

71 lines
1.5 KiB
Rust

use embedded_hal::digital::v2::{InputPin, OutputPin};
use st7735_lcd::Orientation;
use stm32f1xx_hal::{
delay::Delay,
gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull},
pac, qei,
spi::{Spi, Spi1NoRemap},
timer::Tim3PartialRemap,
};
mod confirm_profile;
mod profile_selection;
mod run_profile;
mod setup;
mod splash;
mod styles;
pub use setup::setup;
use styles::Styles;
type AppSPI = Spi<
pac::SPI1,
Spi1NoRemap,
(
gpioa::PA5<Alternate<PushPull>>,
gpioa::PA6<Input<Floating>>,
gpioa::PA7<Alternate<PushPull>>,
),
>;
type AppQEI = qei::Qei<
pac::TIM3,
Tim3PartialRemap,
(gpiob::PB4<Input<Floating>>, gpiob::PB5<Input<Floating>>),
>;
type AppDisp =
st7735_lcd::ST7735<AppSPI, gpioa::PA4<Output<PushPull>>, gpioa::PA1<Output<PushPull>>>;
pub struct App {
delay: Delay,
board_led: gpioc::PC13<Output<PushPull>>,
spi: AppSPI,
disp_cs: gpioa::PA0<Output<PushPull>>,
disp_dc: gpioa::PA4<Output<PushPull>>,
disp_rst: gpioa::PA1<Output<PushPull>>,
max_cs: gpioa::PA9<Output<PushPull>>,
qei: AppQEI,
button: gpiob::PB3<Input<Floating>>,
selected_profile: usize,
styles: Styles,
}
impl App {
pub fn run(mut self) -> ! {
self = self.splash_screen();
loop {
self = self.profile_selection();
let (confirmed, app) = self.confirm_profile();
self = app;
if !confirmed {
continue;
}
self = self.run_profile();
}
}
}