gif need psram
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/target
|
||||
*.uf2
|
||||
abi_sys.h
|
||||
assets/gif/bad_apple.gif
|
||||
|
||||
99
Cargo.lock
generated
99
Cargo.lock
generated
@@ -20,7 +20,7 @@ dependencies = [
|
||||
"embedded-graphics",
|
||||
"embedded-sdmmc",
|
||||
"rand_core 0.9.3",
|
||||
"spin",
|
||||
"spin 0.10.0",
|
||||
"talc",
|
||||
]
|
||||
|
||||
@@ -125,7 +125,7 @@ version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3"
|
||||
dependencies = [
|
||||
"rustc_version",
|
||||
"rustc_version 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -220,7 +220,7 @@ dependencies = [
|
||||
"embedded-io",
|
||||
"embedded-io-async",
|
||||
"futures-intrusive",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
@@ -398,7 +398,7 @@ dependencies = [
|
||||
"embedded-hal 1.0.0",
|
||||
"embedded-io-async",
|
||||
"futures",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
"num_enum 0.5.11",
|
||||
]
|
||||
|
||||
@@ -777,7 +777,7 @@ dependencies = [
|
||||
"embedded-io-async",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -792,7 +792,7 @@ dependencies = [
|
||||
"embedded-io-async",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -845,7 +845,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80e2ee86063bd028a420a5fb5898c18c87a8898026da1d4c852af2c443d0a454"
|
||||
dependencies = [
|
||||
"embassy-executor-timer-queue",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -859,7 +859,7 @@ dependencies = [
|
||||
"embassy-sync 0.7.2",
|
||||
"embassy-usb-driver 0.2.0",
|
||||
"embedded-io-async",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
"ssmarshal",
|
||||
"usbd-hid",
|
||||
]
|
||||
@@ -1012,7 +1012,7 @@ dependencies = [
|
||||
"defmt 0.3.100",
|
||||
"embedded-hal 1.0.0",
|
||||
"embedded-io",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1262,6 +1262,15 @@ dependencies = [
|
||||
"wasi 0.14.7+wasi-0.2.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"abi",
|
||||
"embedded-graphics",
|
||||
"tinygif",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "goblin"
|
||||
version = "0.10.1"
|
||||
@@ -1282,6 +1291,15 @@ dependencies = [
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.3.1"
|
||||
@@ -1312,13 +1330,26 @@ version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.7.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
|
||||
dependencies = [
|
||||
"atomic-polyfill",
|
||||
"hash32 0.2.1",
|
||||
"rustc_version 0.4.1",
|
||||
"spin 0.9.8",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
|
||||
dependencies = [
|
||||
"hash32",
|
||||
"hash32 0.3.1",
|
||||
"serde",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
@@ -1461,14 +1492,14 @@ dependencies = [
|
||||
"embedded-sdmmc",
|
||||
"embedded-text",
|
||||
"goblin",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
"kolibri-embedded-gui",
|
||||
"num_enum 0.7.4",
|
||||
"once_cell",
|
||||
"panic-probe",
|
||||
"portable-atomic",
|
||||
"rand",
|
||||
"spin",
|
||||
"spin 0.10.0",
|
||||
"st7365p-lcd",
|
||||
"static_cell",
|
||||
"strum",
|
||||
@@ -1485,7 +1516,7 @@ dependencies = [
|
||||
"embedded-graphics",
|
||||
"embedded-iconoir",
|
||||
"foldhash",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2083,7 +2114,16 @@ version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
dependencies = [
|
||||
"semver",
|
||||
"semver 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
||||
dependencies = [
|
||||
"semver 1.0.27",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2141,6 +2181,12 @@ dependencies = [
|
||||
"semver-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.7.0"
|
||||
@@ -2246,6 +2292,15 @@ dependencies = [
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.10.0"
|
||||
@@ -2274,7 +2329,7 @@ dependencies = [
|
||||
"embedded-graphics-core",
|
||||
"embedded-hal 1.0.0",
|
||||
"embedded-hal-async",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
"nb 1.1.0",
|
||||
]
|
||||
|
||||
@@ -2487,6 +2542,16 @@ dependencies = [
|
||||
"embedded-graphics",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinygif"
|
||||
version = "0.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09f1406b710986188de8d393c810213d4bbf940e327d90d52cff9930d007a248"
|
||||
dependencies = [
|
||||
"embedded-graphics",
|
||||
"heapless 0.7.17",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.11"
|
||||
@@ -2508,7 +2573,7 @@ dependencies = [
|
||||
"embassy-time 0.4.0",
|
||||
"embedded-io",
|
||||
"futures",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
"rand_core 0.6.4",
|
||||
"static_cell",
|
||||
"trouble-host-macros",
|
||||
@@ -2559,7 +2624,7 @@ version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98816b1accafbb09085168b90f27e93d790b4bfa19d883466b5e53315b5f06a6"
|
||||
dependencies = [
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
"portable-atomic",
|
||||
]
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ members = [
|
||||
"user-apps/calculator",
|
||||
"user-apps/snake",
|
||||
"user-apps/gallery",
|
||||
"user-apps/gif",
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
|
||||
@@ -22,6 +22,10 @@ pub fn sleep(ms: u64) {
|
||||
abi_sys::sleep(ms);
|
||||
}
|
||||
|
||||
pub fn get_ms() -> u64 {
|
||||
abi_sys::get_ms()
|
||||
}
|
||||
|
||||
pub fn get_key() -> KeyEvent {
|
||||
abi_sys::keyboard::get_key().into()
|
||||
}
|
||||
|
||||
1
justfile
1
justfile
@@ -16,3 +16,4 @@ userapps: cbindgen
|
||||
just userapp calculator
|
||||
just userapp snake
|
||||
just userapp gallery
|
||||
just userapp gif
|
||||
|
||||
9
user-apps/gif/Cargo.toml
Normal file
9
user-apps/gif/Cargo.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "gif"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
abi = { path = "../../abi" }
|
||||
embedded-graphics = "0.8.1"
|
||||
tinygif = "0.0.4"
|
||||
28
user-apps/gif/build.rs
Normal file
28
user-apps/gif/build.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
//! This build script copies the `memory.x` file from the crate root into
|
||||
//! a directory where the linker can always find it at build time.
|
||||
//! For many projects this is optional, as the linker always searches the
|
||||
//! project root directory -- wherever `Cargo.toml` is. However, if you
|
||||
//! are using a workspace or have a more complicated build setup, this
|
||||
//! build script becomes required. Additionally, by requesting that
|
||||
//! Cargo re-run the build script whenever `memory.x` is changed,
|
||||
//! updating `memory.x` ensures a rebuild of the application with the
|
||||
//! new memory settings.
|
||||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
// Put `memory.x` in our output directory and ensure it's
|
||||
// on the linker search path.
|
||||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
File::create(out.join("memory.x"))
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("../memory.x"))
|
||||
.unwrap();
|
||||
println!("cargo:rustc-link-search={}", out.display());
|
||||
|
||||
println!("cargo:rerun-if-changed=memory.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tmemory.x");
|
||||
}
|
||||
64
user-apps/gif/src/main.rs
Normal file
64
user-apps/gif/src/main.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
extern crate alloc;
|
||||
use abi::{
|
||||
display::{Display, lock_display},
|
||||
fs::read_file,
|
||||
get_key, get_ms,
|
||||
keyboard::{KeyCode, KeyState},
|
||||
print, sleep,
|
||||
};
|
||||
use alloc::format;
|
||||
use core::panic::PanicInfo;
|
||||
use embedded_graphics::{image::ImageDrawable, pixelcolor::Rgb565};
|
||||
use tinygif::{Gif, Header};
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
print(&format!(
|
||||
"user panic: {} @ {:?}",
|
||||
info.message(),
|
||||
info.location(),
|
||||
));
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "Rust" fn _start() {
|
||||
main()
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
print("Starting Gif app");
|
||||
let mut display = Display;
|
||||
|
||||
static mut BUF: [u8; 256] = [0_u8; 256];
|
||||
|
||||
read_file("/gif/bad_apple.gif", 0, unsafe { &mut BUF[0..6] });
|
||||
|
||||
let gif_header = Header::parse(unsafe { &BUF[0..6] });
|
||||
|
||||
let image = Gif::<Rgb565>::from_slice().unwrap();
|
||||
|
||||
loop {
|
||||
for frame in image.frames() {
|
||||
let start = get_ms();
|
||||
|
||||
frame.draw(&mut display).unwrap();
|
||||
|
||||
sleep(((frame.delay_centis as u64) * 10).saturating_sub(start));
|
||||
|
||||
let event = get_key();
|
||||
if event.state != KeyState::Idle {
|
||||
match event.key {
|
||||
KeyCode::Esc => return,
|
||||
_ => (),
|
||||
};
|
||||
};
|
||||
|
||||
lock_display(true);
|
||||
lock_display(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user