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

81 lines
1.9 KiB
Rust

use arrayvec::ArrayString;
use core::fmt::Write;
use cortex_m::asm;
use cortex_m_rt::{entry, exception};
use embedded_graphics::{
drawable::Drawable, fonts::Text, image::Image, pixelcolor::BinaryColor, pixelcolor::Rgb565,
prelude::*, primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyleBuilder,
style::TextStyleBuilder,
};
use embedded_hal::digital::v2::{InputPin, OutputPin};
use profont::{ProFont12Point, ProFont14Point, ProFont9Point};
use rtt_target::{rprintln, rtt_init_print};
use st7735_lcd::Orientation;
use stm32f1xx_hal::{
delay::Delay,
gpio::{gpioa, gpiob, gpioc, Alternate, Floating, Input, Output, PushPull},
pac,
prelude::*,
qei, rcc,
spi::{Mode, Phase, Polarity, Spi, Spi1NoRemap},
stm32,
timer::{Tim3PartialRemap, Timer},
};
use tinybmp::Bmp;
use crate::profiles;
mod confirm_profile;
mod profile_selection;
mod run_profile;
mod setup;
mod splash;
pub use setup::setup;
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>>),
>;
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,
}
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();
}
}
}