fw-rust: Draw the splash screen via function
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Make the splash screen assets `const` and draw the splash screen with the new `draw_splash()` function.
This commit is contained in:
parent
36be6d27bc
commit
9425093391
1 changed files with 46 additions and 42 deletions
|
@ -24,7 +24,7 @@ eeprom! {
|
|||
}
|
||||
|
||||
// TODO: Use https://github.com/rust-lang/rust/issues/85077 when stabilized
|
||||
static SACRED_CHAO: [[u8; 40]; 5] = [
|
||||
const 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,
|
||||
|
@ -53,7 +53,7 @@ static SACRED_CHAO: [[u8; 40]; 5] = [
|
|||
];
|
||||
|
||||
// TODO: Use https://github.com/rust-lang/rust/issues/85077 when stabilized
|
||||
static ONDERS_ORG: [[u8; 48]; 2] = [
|
||||
const 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,
|
||||
|
@ -90,6 +90,48 @@ fn clear_screen(spi: &mut Spi, cd: &mut Pin<Output, PB0>) {
|
|||
}
|
||||
}
|
||||
|
||||
fn draw_splash(spi: &mut Spi, cd: &mut Pin<Output, PB0>) {
|
||||
clear_screen(spi, cd);
|
||||
|
||||
let mut delay = Delay::<MHz8>::new();
|
||||
|
||||
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);
|
||||
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);
|
||||
cd.set_low();
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
cd.set_low();
|
||||
}
|
||||
}
|
||||
|
||||
#[atmega_hal::entry]
|
||||
fn main() -> ! {
|
||||
interrupt::free(|_cs| {
|
||||
|
@ -176,46 +218,8 @@ fn main() -> ! {
|
|||
block!(spi.send(0x08)).unwrap(); // (9) Set Electronic Volume: Set Contrast // TODO: Use EEPROM
|
||||
block!(spi.send(0xAF)).unwrap(); // (12) Set Display Enable: Display on
|
||||
|
||||
// Clear screen
|
||||
clear_screen(&mut spi, &mut lcd_cd);
|
||||
|
||||
// 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();
|
||||
}
|
||||
// Draw splash screen
|
||||
draw_splash(&mut spi, &mut lcd_cd);
|
||||
});
|
||||
|
||||
#[allow(clippy::empty_loop)]
|
||||
|
|
Loading…
Reference in a new issue