From 118256058247712e337e293b4edc6260c35014d9 Mon Sep 17 00:00:00 2001 From: sawyer bristol Date: Tue, 28 Oct 2025 12:36:15 -0600 Subject: [PATCH] remvove lock_display --- abi/src/lib.rs | 4 ---- abi_sys/src/lib.rs | 24 +++++++----------------- kernel/src/abi.rs | 7 +------ kernel/src/elf.rs | 1 - user-apps/calculator/src/main.rs | 5 +---- user-apps/gallery/src/main.rs | 5 +---- user-apps/gif/src/main.rs | 28 ++++++++++++---------------- user-apps/snake/src/main.rs | 4 +--- 8 files changed, 23 insertions(+), 55 deletions(-) diff --git a/abi/src/lib.rs b/abi/src/lib.rs index 096758c..3d0778e 100644 --- a/abi/src/lib.rs +++ b/abi/src/lib.rs @@ -61,10 +61,6 @@ pub mod display { pub type Pixel565 = Pixel; - pub fn lock_display(lock: bool) { - abi_sys::lock_display(lock); - } - const BUF_SIZE: usize = 15 * 1024; // tune this for performance static mut BUF: [CPixel; BUF_SIZE] = [CPixel::new(); BUF_SIZE]; // const BUF_SIZE: usize = 250 * 1024; // tune this for performance diff --git a/abi_sys/src/lib.rs b/abi_sys/src/lib.rs index c66f61a..ed9e9f6 100644 --- a/abi_sys/src/lib.rs +++ b/abi_sys/src/lib.rs @@ -13,7 +13,7 @@ use strum::{EnumCount, EnumIter}; pub type EntryFn = fn(); -pub const ABI_CALL_TABLE_COUNT: usize = 12; +pub const ABI_CALL_TABLE_COUNT: usize = 11; const _: () = assert!(ABI_CALL_TABLE_COUNT == CallTable::COUNT); #[derive(Clone, Copy, EnumIter, EnumCount)] @@ -24,13 +24,12 @@ pub enum CallTable { PrintString = 2, SleepMs = 3, GetMs = 4, - LockDisplay = 5, - DrawIter = 6, - GetKey = 7, - GenRand = 8, - ListDir = 9, - ReadFile = 10, - FileLen = 11, + DrawIter = 5, + GetKey = 6, + GenRand = 7, + ListDir = 8, + ReadFile = 9, + FileLen = 10, } #[unsafe(no_mangle)] @@ -104,15 +103,6 @@ pub extern "C" fn get_ms() -> u64 { f() } -pub type LockDisplay = extern "C" fn(lock: bool); - -#[unsafe(no_mangle)] -pub extern "C" fn lock_display(lock: bool) { - let f: LockDisplay = - unsafe { core::mem::transmute(CALL_ABI_TABLE[CallTable::LockDisplay as usize]) }; - f(lock); -} - #[repr(C)] #[derive(Copy, Clone)] pub struct CPixel { diff --git a/kernel/src/abi.rs b/kernel/src/abi.rs index 2f1497b..e6c522e 100644 --- a/kernel/src/abi.rs +++ b/kernel/src/abi.rs @@ -1,6 +1,6 @@ use abi_sys::{ AllocAbi, CLayout, CPixel, DeallocAbi, DrawIterAbi, FileLen, GenRand, GetMsAbi, ListDir, - LockDisplay, PrintAbi, ReadFile, RngRequest, SleepMsAbi, keyboard::*, + PrintAbi, ReadFile, RngRequest, SleepMsAbi, keyboard::*, }; use alloc::{string::ToString, vec::Vec}; use core::{alloc::GlobalAlloc, sync::atomic::Ordering}; @@ -73,11 +73,6 @@ pub extern "C" fn get_ms() -> u64 { .as_millis() } -const _: LockDisplay = lock_display; -pub extern "C" fn lock_display(lock: bool) { - FB_PAUSED.store(lock, Ordering::Release); -} - const _: DrawIterAbi = draw_iter; pub extern "C" fn draw_iter(cpixels: *const CPixel, len: usize) { // SAFETY: caller guarantees `ptr` is valid for `len` bytes diff --git a/kernel/src/elf.rs b/kernel/src/elf.rs index 334e3ab..bdc15de 100644 --- a/kernel/src/elf.rs +++ b/kernel/src/elf.rs @@ -201,7 +201,6 @@ fn patch_abi( CallTable::PrintString => abi::print as usize, CallTable::SleepMs => abi::sleep as usize, CallTable::GetMs => abi::get_ms as usize, - CallTable::LockDisplay => abi::lock_display as usize, CallTable::DrawIter => abi::draw_iter as usize, CallTable::GetKey => abi::get_key as usize, CallTable::GenRand => abi::gen_rand as usize, diff --git a/user-apps/calculator/src/main.rs b/user-apps/calculator/src/main.rs index 7087e46..4bf802f 100644 --- a/user-apps/calculator/src/main.rs +++ b/user-apps/calculator/src/main.rs @@ -3,7 +3,7 @@ extern crate alloc; use abi::{ - display::{Display, lock_display}, + display::Display, get_key, keyboard::{KeyCode, KeyState}, print, @@ -58,8 +58,6 @@ pub fn main() { loop { if dirty { - lock_display(true); - let style = PrimitiveStyle::with_fill(Rgb565::BLACK); if let Some(area) = last_area { Rectangle::new(area.0.top_left, area.0.size) @@ -103,7 +101,6 @@ pub fn main() { eq_layout.draw(&mut display).unwrap(); dirty = false; - lock_display(false); } let event = get_key(); diff --git a/user-apps/gallery/src/main.rs b/user-apps/gallery/src/main.rs index 1b06ee5..631ac37 100644 --- a/user-apps/gallery/src/main.rs +++ b/user-apps/gallery/src/main.rs @@ -4,7 +4,7 @@ extern crate alloc; use abi::{ - display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH, lock_display}, + display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH}, fs::{list_dir, read_file}, get_key, keyboard::{KeyCode, KeyState}, @@ -70,7 +70,6 @@ pub fn main() { let x = cell_x + (cell_width - bmp_w) / 2; let y = cell_y + 5; // 5px top margin - lock_display(true); Image::new(&bmp, Point::new(x, y)) .draw(&mut display) .unwrap(); @@ -85,8 +84,6 @@ pub fn main() { .draw(&mut display) .unwrap(); - lock_display(false); - images_drawn += 1; } } diff --git a/user-apps/gif/src/main.rs b/user-apps/gif/src/main.rs index 48e7e1a..8c89a0a 100644 --- a/user-apps/gif/src/main.rs +++ b/user-apps/gif/src/main.rs @@ -3,7 +3,7 @@ extern crate alloc; use abi::{ - display::{Display, lock_display}, + display::Display, fs::{file_len, read_file}, get_key, get_ms, keyboard::{KeyCode, KeyState}, @@ -37,28 +37,24 @@ pub fn main() { let gif = Gif::::from_slice(&buf).unwrap(); - // let mut frame_num = 0; + let mut frame_num = 0; loop { for frame in gif.frames() { let start = get_ms(); - // lock_display(true); frame.draw(&mut display).unwrap(); - // lock_display(false); - - // frame_num += 1; + frame_num += 1; + if frame_num % 100 == 0 { + let event = get_key(); + if event.state != KeyState::Idle { + match event.key { + KeyCode::Esc => return, + _ => (), + }; + }; + } sleep(((frame.delay_centis as u64) * 10).saturating_sub(start)); - - // if frame_num % 100 == 0 { - // let event = get_key(); - // if event.state != KeyState::Idle { - // match event.key { - // KeyCode::Esc => return, - // _ => (), - // }; - // }; - // } } } } diff --git a/user-apps/snake/src/main.rs b/user-apps/snake/src/main.rs index ffb4a2c..2324761 100644 --- a/user-apps/snake/src/main.rs +++ b/user-apps/snake/src/main.rs @@ -4,7 +4,7 @@ extern crate alloc; use abi::{ Rng, - display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH, lock_display}, + display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH}, get_key, keyboard::{KeyCode, KeyState}, print, sleep, @@ -57,10 +57,8 @@ pub fn main() { }; // ensure all draws show up at once - lock_display(true); game.pre_draw(&mut display); game.draw(&mut display); - lock_display(false); sleep(15); }