center gif

This commit is contained in:
2025-10-28 19:06:32 -06:00
parent 7bc6aeb998
commit ba426f5baa
3 changed files with 28 additions and 69 deletions

View File

@@ -6,4 +6,4 @@ edition = "2024"
[dependencies]
abi = { path = "../../abi" }
embedded-graphics = "0.8.1"
tinygif = "0.0.4"
tinygif = { git = "https://github.com/LegitCamper/tinygif" }

View File

@@ -11,7 +11,9 @@ use abi::{
};
use alloc::vec;
use core::panic::PanicInfo;
use embedded_graphics::{image::ImageDrawable, pixelcolor::Rgb565};
use embedded_graphics::{
image::ImageDrawable, pixelcolor::Rgb565, prelude::Point, transform::Transform,
};
use tinygif::Gif;
#[panic_handler]
@@ -36,13 +38,17 @@ pub fn main() {
assert!(read == size);
let gif = Gif::<Rgb565>::from_slice(&buf).unwrap();
let height = gif.height();
let mut frame_num = 0;
loop {
for frame in gif.frames() {
for mut frame in gif.frames() {
let start = get_ms();
frame.draw(&mut display).unwrap();
frame
.translate_mut(Point::new(0, (320 - height as i32) / 2))
.draw(&mut display)
.unwrap();
frame_num += 1;
if frame_num % 100 == 0 {