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

71 lines
2.1 KiB
Rust

use embedded_graphics::{
drawable::Drawable, fonts::Text, pixelcolor::Rgb565, prelude::*, primitive_style,
primitives::rectangle::Rectangle, primitives::Line, style::PrimitiveStyle,
style::PrimitiveStyleBuilder, style::TextStyleBuilder,
};
use embedded_hal::digital::v2::OutputPin;
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 crate::application::App;
use crate::profiles;
impl App {
pub fn run_profile(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 rect = Rectangle::new(Point::new(0, 0), Point::new(160, 128))
.into_styled(self.styles.fill_black);
rect.draw(&mut disp).unwrap();
for x in (0..160).step_by(30) {
Line::new(Point::new(x, 20), Point::new(x, 127))
.into_styled(self.styles.grid)
.draw(&mut disp)
.unwrap();
}
for y in (0..110).step_by(10) {
Line::new(Point::new(0, 127 - y), Point::new(195, 127 - y))
.into_styled(self.styles.grid)
.draw(&mut disp)
.unwrap();
}
for t in 0..320 {
let y = 148
- (profiles::REFLOW_PROFILES[self.selected_profile].get_temp(t as f32) / 2.0)
as i32;
Pixel(Point::new((t / 2) as i32, y), self.styles.profile_color)
.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;
loop {}
self
}
}