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

60 lines
1.8 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::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 style_black = PrimitiveStyleBuilder::new()
.fill_color(Rgb565::BLACK)
.build();
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();
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
}
}