fw-rust: Show splash screen

Put assets for the splash screen into the data segment and print it.
This commit is contained in:
finga 2022-03-05 21:55:07 +01:00
parent c42b4595c7
commit a688d4c5ed

View file

@ -16,6 +16,51 @@ use embedded_hal::{
use nb::block;
use panic_halt as _;
// TODO: Use https://github.com/rust-lang/rust/issues/85077 when stabilized
static SACRED_CHAO: [[u8; 40]; 5] = [
[
0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0xFE, 0xFC, 0xFC,
0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00,
],
[
0x80, 0xF0, 0xFC, 0xFE, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x0F, 0x07, 0x07, 0x07, 0x03, 0xC3,
0xE3, 0x73, 0x37, 0x17, 0x07, 0x0F, 0x1E, 0x3C, 0xF0, 0x80,
],
[
0xFF, 0xFF, 0xFF, 0xE7, 0xC3, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0xFC, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0x30, 0x00, 0x00, 0xFF,
],
[
0x01, 0x0F, 0x3F, 0x4F, 0x9F, 0x3F, 0x3E, 0x3C, 0x7C, 0x7C, 0x7C, 0x7C, 0x3E, 0x3E, 0x3E,
0x1F, 0x1F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x0F,
0x0F, 0x0F, 0x07, 0x07, 0x03, 0x81, 0x40, 0x30, 0x0E, 0x01,
],
[
0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x08, 0x10, 0x20, 0x20, 0x40, 0x40, 0x40,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20,
0x10, 0x08, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,
],
];
// TODO: Use https://github.com/rust-lang/rust/issues/85077 when stabilized
static ONDERS_ORG: [[u8; 48]; 2] = [
[
0xE0, 0x60, 0xE0, 0x00, 0x00, 0xE0, 0x60, 0xE0, 0x00, 0x00, 0xE0, 0x60, 0xF8, 0x00, 0x00,
0xE0, 0xA0, 0xE0, 0x00, 0x00, 0xE0, 0x20, 0x60, 0x00, 0x00, 0xE0, 0xA0, 0xA0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x60, 0xE0, 0x00, 0x00, 0xE0, 0x20, 0x60, 0x00, 0x00,
0xE0, 0x60, 0xE0,
],
[
0x03, 0x02, 0x03, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x03, 0x02, 0x03, 0x00, 0x00,
0x03, 0x02, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x03, 0x00, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x02, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x0B, 0x0A, 0x0F,
],
];
#[atmega_hal::entry]
fn main() -> ! {
// Disable interrupts when initializing
@ -99,6 +144,44 @@ fn main() -> ! {
lcd_cd.set_low();
}
// Draw sacred chao
for (i, page) in SACRED_CHAO.iter().enumerate() {
block!(spi.send(0x0F)).unwrap();
block!(spi.send(0x11)).unwrap();
block!(spi.send(0xB1 + i as u8)).unwrap();
// TODO: This delay fixes issues, try find a better solution
delay.delay_ms(1_u8);
lcd_cd.set_high();
for segment in page {
block!(spi.send(*segment)).unwrap();
}
// TODO: This delay fixes issues, try find a better solution
delay.delay_ms(1_u8);
lcd_cd.set_low();
}
// Draw onders.org
for (i, page) in ONDERS_ORG.iter().enumerate() {
block!(spi.send(0x0A)).unwrap();
block!(spi.send(0x11)).unwrap();
block!(spi.send(0xB6 + i as u8)).unwrap();
// TODO: This delay fixes issues, try find a better solution
delay.delay_ms(1_u8);
lcd_cd.set_high();
for segment in page {
block!(spi.send(*segment)).unwrap();
}
// TODO: This delay fixes issues, try find a better solution
delay.delay_ms(1_u8);
lcd_cd.set_low();
}
// Enable interrupts
unsafe { interrupt::enable() };