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

43 lines
1.2 KiB
Rust

use embedded_graphics::{
drawable::Drawable, image::Image, pixelcolor::Rgb565, prelude::*,
primitives::rectangle::Rectangle, style::PrimitiveStyleBuilder,
};
use embedded_hal::digital::v2::OutputPin;
use st7735_lcd::Orientation;
use stm32f1xx_hal::prelude::*;
use tinybmp::Bmp;
use crate::application::App;
impl App {
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();
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();
let bmp = Bmp::from_slice(include_bytes!("logo.bmp")).unwrap();
let image = Image::new(&bmp, Point::new(16, 0));
image.draw(&mut disp).unwrap();
self.delay.delay_ms(2000u16);
let (spi, disp_dc, disp_rst) = disp.release();
self.spi = spi;
self.disp_dc = disp_dc;
self.disp_rst = disp_rst;
self
}
}