remvove lock_display

This commit is contained in:
2025-10-28 12:36:15 -06:00
parent a7daa4c5fc
commit 1182560582
8 changed files with 23 additions and 55 deletions

View File

@@ -61,10 +61,6 @@ pub mod display {
pub type Pixel565 = Pixel<Rgb565>; pub type Pixel565 = Pixel<Rgb565>;
pub fn lock_display(lock: bool) {
abi_sys::lock_display(lock);
}
const BUF_SIZE: usize = 15 * 1024; // tune this for performance const BUF_SIZE: usize = 15 * 1024; // tune this for performance
static mut BUF: [CPixel; BUF_SIZE] = [CPixel::new(); BUF_SIZE]; static mut BUF: [CPixel; BUF_SIZE] = [CPixel::new(); BUF_SIZE];
// const BUF_SIZE: usize = 250 * 1024; // tune this for performance // const BUF_SIZE: usize = 250 * 1024; // tune this for performance

View File

@@ -13,7 +13,7 @@ use strum::{EnumCount, EnumIter};
pub type EntryFn = fn(); 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); const _: () = assert!(ABI_CALL_TABLE_COUNT == CallTable::COUNT);
#[derive(Clone, Copy, EnumIter, EnumCount)] #[derive(Clone, Copy, EnumIter, EnumCount)]
@@ -24,13 +24,12 @@ pub enum CallTable {
PrintString = 2, PrintString = 2,
SleepMs = 3, SleepMs = 3,
GetMs = 4, GetMs = 4,
LockDisplay = 5, DrawIter = 5,
DrawIter = 6, GetKey = 6,
GetKey = 7, GenRand = 7,
GenRand = 8, ListDir = 8,
ListDir = 9, ReadFile = 9,
ReadFile = 10, FileLen = 10,
FileLen = 11,
} }
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
@@ -104,15 +103,6 @@ pub extern "C" fn get_ms() -> u64 {
f() 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)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct CPixel { pub struct CPixel {

View File

@@ -1,6 +1,6 @@
use abi_sys::{ use abi_sys::{
AllocAbi, CLayout, CPixel, DeallocAbi, DrawIterAbi, FileLen, GenRand, GetMsAbi, ListDir, 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 alloc::{string::ToString, vec::Vec};
use core::{alloc::GlobalAlloc, sync::atomic::Ordering}; use core::{alloc::GlobalAlloc, sync::atomic::Ordering};
@@ -73,11 +73,6 @@ pub extern "C" fn get_ms() -> u64 {
.as_millis() .as_millis()
} }
const _: LockDisplay = lock_display;
pub extern "C" fn lock_display(lock: bool) {
FB_PAUSED.store(lock, Ordering::Release);
}
const _: DrawIterAbi = draw_iter; const _: DrawIterAbi = draw_iter;
pub extern "C" fn draw_iter(cpixels: *const CPixel, len: usize) { pub extern "C" fn draw_iter(cpixels: *const CPixel, len: usize) {
// SAFETY: caller guarantees `ptr` is valid for `len` bytes // SAFETY: caller guarantees `ptr` is valid for `len` bytes

View File

@@ -201,7 +201,6 @@ fn patch_abi(
CallTable::PrintString => abi::print as usize, CallTable::PrintString => abi::print as usize,
CallTable::SleepMs => abi::sleep as usize, CallTable::SleepMs => abi::sleep as usize,
CallTable::GetMs => abi::get_ms as usize, CallTable::GetMs => abi::get_ms as usize,
CallTable::LockDisplay => abi::lock_display as usize,
CallTable::DrawIter => abi::draw_iter as usize, CallTable::DrawIter => abi::draw_iter as usize,
CallTable::GetKey => abi::get_key as usize, CallTable::GetKey => abi::get_key as usize,
CallTable::GenRand => abi::gen_rand as usize, CallTable::GenRand => abi::gen_rand as usize,

View File

@@ -3,7 +3,7 @@
extern crate alloc; extern crate alloc;
use abi::{ use abi::{
display::{Display, lock_display}, display::Display,
get_key, get_key,
keyboard::{KeyCode, KeyState}, keyboard::{KeyCode, KeyState},
print, print,
@@ -58,8 +58,6 @@ pub fn main() {
loop { loop {
if dirty { if dirty {
lock_display(true);
let style = PrimitiveStyle::with_fill(Rgb565::BLACK); let style = PrimitiveStyle::with_fill(Rgb565::BLACK);
if let Some(area) = last_area { if let Some(area) = last_area {
Rectangle::new(area.0.top_left, area.0.size) Rectangle::new(area.0.top_left, area.0.size)
@@ -103,7 +101,6 @@ pub fn main() {
eq_layout.draw(&mut display).unwrap(); eq_layout.draw(&mut display).unwrap();
dirty = false; dirty = false;
lock_display(false);
} }
let event = get_key(); let event = get_key();

View File

@@ -4,7 +4,7 @@
extern crate alloc; extern crate alloc;
use abi::{ use abi::{
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH, lock_display}, display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
fs::{list_dir, read_file}, fs::{list_dir, read_file},
get_key, get_key,
keyboard::{KeyCode, KeyState}, keyboard::{KeyCode, KeyState},
@@ -70,7 +70,6 @@ pub fn main() {
let x = cell_x + (cell_width - bmp_w) / 2; let x = cell_x + (cell_width - bmp_w) / 2;
let y = cell_y + 5; // 5px top margin let y = cell_y + 5; // 5px top margin
lock_display(true);
Image::new(&bmp, Point::new(x, y)) Image::new(&bmp, Point::new(x, y))
.draw(&mut display) .draw(&mut display)
.unwrap(); .unwrap();
@@ -85,8 +84,6 @@ pub fn main() {
.draw(&mut display) .draw(&mut display)
.unwrap(); .unwrap();
lock_display(false);
images_drawn += 1; images_drawn += 1;
} }
} }

View File

@@ -3,7 +3,7 @@
extern crate alloc; extern crate alloc;
use abi::{ use abi::{
display::{Display, lock_display}, display::Display,
fs::{file_len, read_file}, fs::{file_len, read_file},
get_key, get_ms, get_key, get_ms,
keyboard::{KeyCode, KeyState}, keyboard::{KeyCode, KeyState},
@@ -37,28 +37,24 @@ pub fn main() {
let gif = Gif::<Rgb565>::from_slice(&buf).unwrap(); let gif = Gif::<Rgb565>::from_slice(&buf).unwrap();
// let mut frame_num = 0; let mut frame_num = 0;
loop { loop {
for frame in gif.frames() { for frame in gif.frames() {
let start = get_ms(); let start = get_ms();
// lock_display(true);
frame.draw(&mut display).unwrap(); 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)); 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,
// _ => (),
// };
// };
// }
} }
} }
} }

View File

@@ -4,7 +4,7 @@
extern crate alloc; extern crate alloc;
use abi::{ use abi::{
Rng, Rng,
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH, lock_display}, display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
get_key, get_key,
keyboard::{KeyCode, KeyState}, keyboard::{KeyCode, KeyState},
print, sleep, print, sleep,
@@ -57,10 +57,8 @@ pub fn main() {
}; };
// ensure all draws show up at once // ensure all draws show up at once
lock_display(true);
game.pre_draw(&mut display); game.pre_draw(&mut display);
game.draw(&mut display); game.draw(&mut display);
lock_display(false);
sleep(15); sleep(15);
} }