From c42b4595c76d3de513b2a36261e8ed77208643ae Mon Sep 17 00:00:00 2001 From: finga Date: Fri, 4 Mar 2022 13:20:56 +0100 Subject: [PATCH] fw-rust: Clear the screen After initializing the LCD display, clear the screen. --- firmware/rust/src/main.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/firmware/rust/src/main.rs b/firmware/rust/src/main.rs index 38569cb..f7e5bda 100644 --- a/firmware/rust/src/main.rs +++ b/firmware/rust/src/main.rs @@ -61,7 +61,7 @@ fn main() -> ! { ); // Init LCD - let _lcd_cd = pins.pb0.into_output(); + let mut lcd_cd = pins.pb0.into_output(); let mut lcd_rst = pins.pb1.into_output(); // TODO: Test if delay is really needed delay.delay_ms(1_u8); @@ -80,6 +80,25 @@ 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 + for page in 0..8 { + block!(spi.send(0x00)).unwrap(); + block!(spi.send(0x10)).unwrap(); + block!(spi.send(0xB0 + page)).unwrap(); + + // TODO: This delay fixes issues, try find a better solution + delay.delay_ms(1_u8); + lcd_cd.set_high(); + + for _ in 0..102 { + block!(spi.send(0x00)).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() };