diff --git a/images/cat.qoi b/images/cat.qoi index 53b9534..28cde1a 100644 Binary files a/images/cat.qoi and b/images/cat.qoi differ diff --git a/images/mario.qoi b/images/mario.qoi deleted file mode 100644 index 296854c..0000000 Binary files a/images/mario.qoi and /dev/null differ diff --git a/images/pikachu.qoi b/images/pikachu.qoi deleted file mode 100644 index 413f5f6..0000000 Binary files a/images/pikachu.qoi and /dev/null differ diff --git a/images/press_btn.qoi b/images/press_btn.qoi index a9fe652..8e91aab 100644 Binary files a/images/press_btn.qoi and b/images/press_btn.qoi differ diff --git a/images/rick.qoi b/images/rick.qoi new file mode 100644 index 0000000..de440b4 Binary files /dev/null and b/images/rick.qoi differ diff --git a/images/steve.qoi b/images/steve.qoi deleted file mode 100644 index aa16342..0000000 Binary files a/images/steve.qoi and /dev/null differ diff --git a/images/xp_desktop.qoi b/images/xp_desktop.qoi new file mode 100644 index 0000000..63685af Binary files /dev/null and b/images/xp_desktop.qoi differ diff --git a/src/main.rs b/src/main.rs index 3eb8584..b094651 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ use panic_halt as _; use crate::{ display::{Display, Position}, peripherals::Button, - qoi::{Image, LARGE_CAT_UNSAFE, draw_image}, + qoi::{Image, LARGE_CAT_UNSAFE, PRESS_BTN_UNSAFE, RICK_UNSAFE, XP_DESKTOP_UNSAFE, draw_image}, }; mod display; @@ -78,13 +78,25 @@ fn main() -> ! { let mut button = Button::from(pins.pd5.into_pull_up_input()); let mut idx = 0; - let images = [&Image::from(addr_of!(LARGE_CAT_UNSAFE))]; + let images = [ + Image::from(addr_of!(LARGE_CAT_UNSAFE)), + Image::from(addr_of!(XP_DESKTOP_UNSAFE)), + Image::from(addr_of!(RICK_UNSAFE)), + ]; let len = images.len(); + match draw_image( + &mut serial, + &Image::from(addr_of!(PRESS_BTN_UNSAFE)), + &mut display, + Position { x: 0, y: 0 }, + ) { + Ok(_) => ufmt::uwriteln!(serial, "Successfully read QOI").unwrap(), + Err(e) => ufmt::uwriteln!(serial, "Error: {:?}", e).unwrap(), + } + loop { if button.poll() { - idx = (idx + 1) % len; - match draw_image( &mut serial, &images[idx], @@ -94,6 +106,8 @@ fn main() -> ! { Ok(_) => ufmt::uwriteln!(serial, "Successfully read QOI").unwrap(), Err(e) => ufmt::uwriteln!(serial, "Error: {:?}", e).unwrap(), } + + idx = (idx + 1) % len; } } } diff --git a/src/qoi.rs b/src/qoi.rs index 4f10e61..4ee4832 100644 --- a/src/qoi.rs +++ b/src/qoi.rs @@ -16,7 +16,13 @@ use crate::{ // https://qoiformat.org/qoi-specification.pdf #[unsafe(link_section = ".progmem.data")] -pub static LARGE_CAT_UNSAFE: [u8; 23731] = *include_bytes!("../images/cat.qoi"); +pub static LARGE_CAT_UNSAFE: [u8; 8765] = *include_bytes!("../images/cat.qoi"); +#[unsafe(link_section = ".progmem.data")] +pub static XP_DESKTOP_UNSAFE: [u8; 7360] = *include_bytes!("../images/xp_desktop.qoi"); +#[unsafe(link_section = ".progmem.data")] +pub static RICK_UNSAFE: [u8; 2391] = *include_bytes!("../images/rick.qoi"); +#[unsafe(link_section = ".progmem.data")] +pub static PRESS_BTN_UNSAFE: [u8; 1225] = *include_bytes!("../images/press_btn.qoi"); pub struct Image { ptr: *const u8,