diff --git a/card10/src/lcd.rs b/card10/src/lcd.rs new file mode 100644 index 0000000000000000000000000000000000000000..c6e472560b3466ee784f90edf67cd405ce5502fb --- /dev/null +++ b/card10/src/lcd.rs @@ -0,0 +1,30 @@ +#[link(name = "card10")] +extern { + fn LCD_SetBacklight(brightness: usize); + fn LCD_Clear(color: usize); + fn LCD_ClearWindow(xstart: usize, ystart: usize, xend: usize, yend: usize, color: usize); + fn LCD_SetWindowColor(xstart: usize, ystart: usize, xend: usize, yend: usize, color: usize); + fn LCD_SetUWORD(x: usize, y: usize, color: usize); + fn LCD_Update(); +} + +pub const W: usize = 160; +pub const H: usize = 80; + +pub fn set_backlight(brightness: usize) { + unsafe { + LCD_SetBacklight(brightness); + } +} + +pub fn put_pixel(x: usize, y: usize, color: usize) { + unsafe { + LCD_SetUWORD(x, y, color); + } +} + +pub fn update() { + unsafe { + LCD_Update(); + } +} diff --git a/card10/src/lib.rs b/card10/src/lib.rs index 53f5e068d08dfa64583829baf5f96c3212277298..e738d46683899f8ad939bec91fb4ac0b83204c96 100644 --- a/card10/src/lib.rs +++ b/card10/src/lib.rs @@ -4,6 +4,8 @@ pub use max32665; pub use cortex_m_rt as _; pub use cortex_m_rt::entry; +pub mod lcd; + #[link(name = "card10")] extern { fn card10_init(); diff --git a/watchapp/src/main.rs b/watchapp/src/main.rs index 0a55cec730def4ce5cccdf40905e2d01789fc481..478bd4c7ee7b1f864f7e67d51c9d114138662494 100644 --- a/watchapp/src/main.rs +++ b/watchapp/src/main.rs @@ -2,12 +2,27 @@ #![no_main] use panic_abort as _; -use card10::entry; +use card10::{entry, lcd}; #[entry] fn main() -> ! { card10::init(); - panic!("TODO"); + lcd::set_backlight(1000); + let mut t = 0; + loop { + for x in 0..lcd::W { + for y in 0..lcd::H { + if (((x - 2 * t) / 8) + ((y + t) / 8)) % 2 == 0 { + lcd::put_pixel(x, y, 0); + } else { + lcd::put_pixel(x, y, 0xffff); + } + } + } + lcd::update(); + + t += 1; + } }