First draft for profile selection
This commit is contained in:
parent
1187021d42
commit
c0283eefd8
|
@ -24,6 +24,8 @@ use stm32f1xx_hal::{
|
|||
};
|
||||
use tinybmp::Bmp;
|
||||
|
||||
use crate::profiles;
|
||||
|
||||
type AppSPI = Spi<
|
||||
pac::SPI1,
|
||||
Spi1NoRemap,
|
||||
|
@ -49,6 +51,8 @@ pub struct App {
|
|||
disp_rst: gpioa::PA1<Output<PushPull>>,
|
||||
max_cs: gpioa::PA9<Output<PushPull>>,
|
||||
qei: AppQEI,
|
||||
|
||||
selected_profile: usize,
|
||||
}
|
||||
|
||||
pub fn setup(cp: cortex_m::peripheral::Peripherals, dp: stm32::Peripherals) -> App {
|
||||
|
@ -124,11 +128,20 @@ pub fn setup(cp: cortex_m::peripheral::Peripherals, dp: stm32::Peripherals) -> A
|
|||
disp_rst: rst,
|
||||
max_cs: max_cs,
|
||||
qei: qei,
|
||||
|
||||
selected_profile: 0,
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
pub fn run(mut self) -> ! {
|
||||
self = self.splash_screen();
|
||||
self = self.profile_selection();
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
pub fn splash_screen(mut self) -> App {
|
||||
let mut disp =
|
||||
st7735_lcd::ST7735::new(self.spi, self.disp_dc, self.disp_rst, true, false, 160, 128);
|
||||
self.disp_cs.set_low().unwrap();
|
||||
|
@ -140,15 +153,97 @@ impl App {
|
|||
let style_black = PrimitiveStyleBuilder::new()
|
||||
.fill_color(Rgb565::BLACK)
|
||||
.build();
|
||||
Rectangle::new(Point::new(0, 0), Point::new(160, 128))
|
||||
.into_styled(style_black)
|
||||
.draw(&mut disp)
|
||||
.unwrap();
|
||||
let rect = Rectangle::new(Point::new(0, 0), Point::new(160, 128)).into_styled(style_black);
|
||||
|
||||
rect.draw(&mut disp).unwrap();
|
||||
|
||||
let bmp = Bmp::from_slice(include_bytes!("logo.bmp")).unwrap();
|
||||
let image = Image::new(&bmp, Point::new(16, 0));
|
||||
image.draw(&mut disp).unwrap();
|
||||
|
||||
loop {}
|
||||
self.delay.delay_ms(2000u16);
|
||||
|
||||
rect.draw(&mut disp).unwrap();
|
||||
|
||||
let (spi, disp_dc, disp_rst) = disp.release();
|
||||
self.spi = spi;
|
||||
self.disp_dc = disp_dc;
|
||||
self.disp_rst = disp_rst;
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub fn profile_selection(mut self) -> App {
|
||||
let mut disp =
|
||||
st7735_lcd::ST7735::new(self.spi, self.disp_dc, self.disp_rst, true, false, 160, 128);
|
||||
self.disp_cs.set_low().unwrap();
|
||||
|
||||
disp.init(&mut self.delay).unwrap();
|
||||
disp.set_orientation(&Orientation::LandscapeSwapped)
|
||||
.unwrap();
|
||||
|
||||
let text_lager = TextStyleBuilder::new(ProFont12Point)
|
||||
.text_color(Rgb565::WHITE)
|
||||
.build();
|
||||
|
||||
let profile_box = PrimitiveStyleBuilder::new()
|
||||
.fill_color(Rgb565::BLACK)
|
||||
.stroke_color(Rgb565::WHITE)
|
||||
.stroke_width(1)
|
||||
.build();
|
||||
|
||||
let selected_box = PrimitiveStyleBuilder::new()
|
||||
.fill_color(Rgb565::BLUE)
|
||||
.stroke_color(Rgb565::WHITE)
|
||||
.stroke_width(1)
|
||||
.build();
|
||||
|
||||
Text::new("Selected a profile", Point::new(4, 4))
|
||||
.into_styled(text_lager)
|
||||
.draw(&mut disp)
|
||||
.unwrap();
|
||||
|
||||
let mut needs_redraw = true;
|
||||
loop {
|
||||
if needs_redraw {
|
||||
for i in 0..profiles::REFLOW_PROFILES.len() {
|
||||
let rect = Rectangle::new(
|
||||
Point::new(0, 20 + (i as i32) * 16),
|
||||
Point::new(159, 20 + (i as i32) * 16 + 16),
|
||||
);
|
||||
|
||||
let styled_rect = if i == self.selected_profile {
|
||||
rect.into_styled(selected_box)
|
||||
} else {
|
||||
rect.into_styled(profile_box)
|
||||
};
|
||||
|
||||
styled_rect.draw(&mut disp).unwrap();
|
||||
|
||||
Text::new(
|
||||
profiles::REFLOW_PROFILES[i].get_name(),
|
||||
Point::new(4, 21 + (i as i32) * 16),
|
||||
)
|
||||
.into_styled(text_lager)
|
||||
.draw(&mut disp)
|
||||
.unwrap();
|
||||
}
|
||||
needs_redraw = false;
|
||||
}
|
||||
|
||||
self.delay.delay_ms(100u16);
|
||||
let new_selection = ((self.qei.count() as usize) / 4) % profiles::REFLOW_PROFILES.len();
|
||||
if new_selection != self.selected_profile {
|
||||
self.selected_profile = new_selection;
|
||||
needs_redraw = true;
|
||||
}
|
||||
}
|
||||
|
||||
let (spi, disp_dc, disp_rst) = disp.release();
|
||||
self.spi = spi;
|
||||
self.disp_dc = disp_dc;
|
||||
self.disp_rst = disp_rst;
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ impl ReflowProfile {
|
|||
}
|
||||
}
|
||||
|
||||
pub const REFLOW_PROFILES: [ReflowProfile; 2] = [
|
||||
pub const REFLOW_PROFILES: [ReflowProfile; 4] = [
|
||||
ReflowProfile {
|
||||
name: "Profile 1",
|
||||
points: [
|
||||
|
@ -91,4 +91,62 @@ pub const REFLOW_PROFILES: [ReflowProfile; 2] = [
|
|||
},
|
||||
],
|
||||
},
|
||||
ReflowProfile {
|
||||
name: "Empty ",
|
||||
points: [
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
],
|
||||
},
|
||||
ReflowProfile {
|
||||
name: "Emtpy",
|
||||
points: [
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
ProfilePoint {
|
||||
time: 0f32,
|
||||
temp: 0f32,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue