From a688d4c5eda6fcbd0008febe0370f8674254af61 Mon Sep 17 00:00:00 2001 From: finga Date: Sat, 5 Mar 2022 21:55:07 +0100 Subject: [PATCH] fw-rust: Show splash screen Put assets for the splash screen into the data segment and print it. --- firmware/rust/src/main.rs | 83 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/firmware/rust/src/main.rs b/firmware/rust/src/main.rs index f7e5bda..a5abd86 100644 --- a/firmware/rust/src/main.rs +++ b/firmware/rust/src/main.rs @@ -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() };