Finish slideshow with larger images from program memory
This commit is contained in:
parent
c1bd4acfd0
commit
309ca727fc
BIN
images/cat.qoi
BIN
images/cat.qoi
Binary file not shown.
BIN
images/mario.qoi
BIN
images/mario.qoi
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
images/rick.qoi
Normal file
BIN
images/rick.qoi
Normal file
Binary file not shown.
BIN
images/steve.qoi
BIN
images/steve.qoi
Binary file not shown.
BIN
images/xp_desktop.qoi
Normal file
BIN
images/xp_desktop.qoi
Normal file
Binary file not shown.
22
src/main.rs
22
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user