mirror of
https://github.com/LegitCamper/picocalc-os-rs.git
synced 2026-02-11 06:15:25 +00:00
gif plays at low fps
This commit is contained in:
@@ -28,11 +28,7 @@ use embedded_layout::{
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
print(&format!(
|
||||
"user panic: {} @ {:?}",
|
||||
info.message(),
|
||||
info.location(),
|
||||
));
|
||||
print!("user panic: {} @ {:?}", info.message(), info.location(),);
|
||||
loop {}
|
||||
}
|
||||
|
||||
@@ -42,7 +38,7 @@ pub extern "Rust" fn _start() {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
print("Starting Calculator app");
|
||||
print!("Starting Calculator app");
|
||||
let mut display = Display;
|
||||
|
||||
let mut input = vec!['e', 'x', 'p', 'r', ':', ' '];
|
||||
|
||||
@@ -10,7 +10,7 @@ use abi::{
|
||||
keyboard::{KeyCode, KeyState},
|
||||
print,
|
||||
};
|
||||
use alloc::{format, string::ToString};
|
||||
use alloc::{format, string::ToString, vec};
|
||||
use core::panic::PanicInfo;
|
||||
use embedded_graphics::{
|
||||
Drawable, image::Image, mono_font::MonoTextStyle, mono_font::ascii::FONT_6X10,
|
||||
@@ -20,11 +20,7 @@ use tinybmp::Bmp;
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
print(&format!(
|
||||
"user panic: {} @ {:?}",
|
||||
info.message(),
|
||||
info.location(),
|
||||
));
|
||||
print!("user panic: {} @ {:?}", info.message(), info.location());
|
||||
loop {}
|
||||
}
|
||||
|
||||
@@ -34,8 +30,8 @@ pub extern "Rust" fn _start() {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
print("Starting Gallery app");
|
||||
static mut BMP_BUF: [u8; 100_000] = [0_u8; 100_000];
|
||||
print!("Starting Gallery app");
|
||||
let mut bmp_buf = vec![0_u8; 100_000];
|
||||
let mut display = Display;
|
||||
|
||||
// Grid parameters
|
||||
@@ -55,13 +51,13 @@ pub fn main() {
|
||||
}
|
||||
|
||||
if let Some(f) = file {
|
||||
print(&format!("file: {}", f.name));
|
||||
print!("file: {}", f.name);
|
||||
if f.name.extension() == b"bmp" || f.name.extension() == b"BMP" {
|
||||
let file = format!("/images/{}", f.name);
|
||||
|
||||
let read = read_file(&file, 0, &mut unsafe { &mut BMP_BUF[..] });
|
||||
let read = read_file(&file, 0, &mut &mut bmp_buf[..]);
|
||||
if read > 0 {
|
||||
let bmp = Bmp::from_slice(unsafe { &BMP_BUF }).expect("failed to parse bmp");
|
||||
let bmp = Bmp::from_slice(&bmp_buf).expect("failed to parse bmp");
|
||||
|
||||
let row = images_drawn / grid_cols;
|
||||
let col = images_drawn % grid_cols;
|
||||
|
||||
@@ -9,18 +9,14 @@ use abi::{
|
||||
keyboard::{KeyCode, KeyState},
|
||||
print, sleep,
|
||||
};
|
||||
use alloc::{format, vec::Vec};
|
||||
use alloc::vec;
|
||||
use core::panic::PanicInfo;
|
||||
use embedded_graphics::{image::ImageDrawable, pixelcolor::Rgb565};
|
||||
use tinygif::Gif;
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
print(&format!(
|
||||
"user panic: {} @ {:?}",
|
||||
info.message(),
|
||||
info.location(),
|
||||
));
|
||||
print!("user panic: {} @ {:?}", info.message(), info.location(),);
|
||||
loop {}
|
||||
}
|
||||
|
||||
@@ -30,16 +26,18 @@ pub extern "Rust" fn _start() {
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
print("Starting Gif app");
|
||||
print!("Starting Gif app");
|
||||
let mut display = Display;
|
||||
|
||||
let size = file_len("/gifs/bad_apple.gif");
|
||||
let mut buf = Vec::with_capacity(size);
|
||||
let mut buf = vec![0_u8; size];
|
||||
let read = read_file("/gifs/bad_apple.gif", 0, &mut buf);
|
||||
print!("read: {}, file size: {}", read, size);
|
||||
assert!(read == size);
|
||||
|
||||
let gif = Gif::<Rgb565>::from_slice(&buf).unwrap();
|
||||
|
||||
let mut frame_num = 0;
|
||||
loop {
|
||||
for frame in gif.frames() {
|
||||
let start = get_ms();
|
||||
@@ -48,6 +46,9 @@ pub fn main() {
|
||||
frame.draw(&mut display).unwrap();
|
||||
lock_display(false);
|
||||
|
||||
frame_num += 1;
|
||||
print!("drew {}", frame_num);
|
||||
|
||||
sleep(((frame.delay_centis as u64) * 10).saturating_sub(start));
|
||||
|
||||
let event = get_key();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MEMORY
|
||||
{
|
||||
RAM : ORIGIN = 0x0, LENGTH = 150K
|
||||
RAM : ORIGIN = 0x0, LENGTH = 250K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
|
||||
@@ -9,18 +9,13 @@ use abi::{
|
||||
keyboard::{KeyCode, KeyState},
|
||||
print, sleep,
|
||||
};
|
||||
use alloc::format;
|
||||
use core::panic::PanicInfo;
|
||||
use embedded_graphics::{pixelcolor::Rgb565, prelude::RgbColor};
|
||||
use embedded_snake::{Direction, SnakeGame};
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(info: &PanicInfo) -> ! {
|
||||
print(&format!(
|
||||
"user panic: {} @ {:?}",
|
||||
info.message(),
|
||||
info.location(),
|
||||
));
|
||||
print!("user panic: {} @ {:?}", info.message(), info.location(),);
|
||||
loop {}
|
||||
}
|
||||
|
||||
@@ -32,7 +27,7 @@ pub extern "Rust" fn _start() {
|
||||
const CELL_SIZE: usize = 8;
|
||||
|
||||
pub fn main() {
|
||||
print("Starting Snake app");
|
||||
print!("Starting Snake app");
|
||||
let mut display = Display;
|
||||
|
||||
let mut game = SnakeGame::<100, Rgb565, Rng>::new(
|
||||
|
||||
Reference in New Issue
Block a user