fw-rust: Break everything down in multiple files
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

To reduce length of `main.rs` and therefor improve readability create
source files for:

- Assets (`assets.rs`): Contains all graphical assets such as the
  splash screen assets, symbols and the symbol table.
- LCD (`lcd.rs`): Contains all lower level things regarding the LCD
  such as the `Lcd` struct and its implementations.
- Screen (`screen/mod.rs`):
    - Splash (`screen/splash.rs`)
    - Home (`screen/home.rs`)
    - Setup (`screen/setup.rs`)

In the future it would probably make sense to move the LCD module into
the screen module.
This commit is contained in:
finga 2022-03-17 12:03:22 +01:00
parent 91e120b258
commit c2920ea334
7 changed files with 693 additions and 647 deletions

View file

@ -0,0 +1,48 @@
use super::Screen;
use crate::{
assets::{ONDERS_ORG, SACRED_CHAO},
lcd::Lcd,
};
use atmega_hal::{clock::MHz8, delay::Delay};
use embedded_hal::{blocking::delay::DelayMs, spi::FullDuplex};
use nb::block;
pub struct Splash;
impl Screen for Splash {
fn draw(&self, lcd: &mut Lcd) {
let mut delay = Delay::<MHz8>::new();
for (i, page) in SACRED_CHAO.iter().enumerate() {
lcd.move_cursor(31, 1 + i as u8);
// TODO: This delay fixes issues, try find a better solution
delay.delay_ms(1_u8);
lcd.cd.set_high();
for segment in page {
block!(lcd.spi.send(*segment)).unwrap();
}
// TODO: This delay fixes issues, try find a better solution
delay.delay_ms(1_u8);
lcd.cd.set_low();
}
for (i, page) in ONDERS_ORG.iter().enumerate() {
lcd.move_cursor(27, 6 + i as u8);
// TODO: This delay fixes issues, try find a better solution
delay.delay_ms(1_u8);
lcd.cd.set_high();
for segment in page {
block!(lcd.spi.send(*segment)).unwrap();
}
// TODO: This delay fixes issues, try find a better solution
delay.delay_ms(1_u8);
lcd.cd.set_low();
}
}
}