Finish slideshow with larger images from program memory

This commit is contained in:
Sofia 2025-09-13 13:30:15 +03:00
parent c1bd4acfd0
commit 309ca727fc
9 changed files with 25 additions and 5 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
images/rick.qoi Normal file

Binary file not shown.

Binary file not shown.

BIN
images/xp_desktop.qoi Normal file

Binary file not shown.

View File

@ -20,7 +20,7 @@ use panic_halt as _;
use crate::{ use crate::{
display::{Display, Position}, display::{Display, Position},
peripherals::Button, 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; mod display;
@ -78,13 +78,25 @@ fn main() -> ! {
let mut button = Button::from(pins.pd5.into_pull_up_input()); let mut button = Button::from(pins.pd5.into_pull_up_input());
let mut idx = 0; 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(); 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 { loop {
if button.poll() { if button.poll() {
idx = (idx + 1) % len;
match draw_image( match draw_image(
&mut serial, &mut serial,
&images[idx], &images[idx],
@ -94,6 +106,8 @@ fn main() -> ! {
Ok(_) => ufmt::uwriteln!(serial, "Successfully read QOI").unwrap(), Ok(_) => ufmt::uwriteln!(serial, "Successfully read QOI").unwrap(),
Err(e) => ufmt::uwriteln!(serial, "Error: {:?}", e).unwrap(), Err(e) => ufmt::uwriteln!(serial, "Error: {:?}", e).unwrap(),
} }
idx = (idx + 1) % len;
} }
} }
} }

View File

@ -16,7 +16,13 @@ use crate::{
// https://qoiformat.org/qoi-specification.pdf // https://qoiformat.org/qoi-specification.pdf
#[unsafe(link_section = ".progmem.data")] #[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 { pub struct Image {
ptr: *const u8, ptr: *const u8,