From 27d116f9e05ea9f384356a14bb30f32903d023dc Mon Sep 17 00:00:00 2001 From: arthomnix Date: Tue, 4 Nov 2025 20:43:44 +0000 Subject: [PATCH] eepy-launcher: display slot number in info page; fix build --- eepy-launcher/src/ui/page/app_info.rs | 18 ++++++++++++++---- eepy-sys/src/critical_section_impl.rs | 22 +++++++++++++--------- eepy/src/flash.rs | 6 +++--- launcher.x | 4 ++-- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/eepy-launcher/src/ui/page/app_info.rs b/eepy-launcher/src/ui/page/app_info.rs index 0b60663..bb97c99 100644 --- a/eepy-launcher/src/ui/page/app_info.rs +++ b/eepy-launcher/src/ui/page/app_info.rs @@ -1,3 +1,4 @@ +use core::fmt::Write; use eepy_gui::element::button::Button; use embedded_graphics::prelude::*; use embedded_graphics::primitives::Rectangle; @@ -30,9 +31,9 @@ impl AppInfoPage { Self { slot, back_button: Button::with_default_style_auto_sized(Point::new(10, 386), "Back", true), - delete_button: Button::with_default_style_auto_sized(Point::new(10, 60), "Delete program", true), + delete_button: Button::with_default_style_auto_sized(Point::new(10, 80), "Delete program", true), autostart_button: Button::with_default_style( - Rectangle::new(Point::new(10, 90), Size::new((10 * "Disable autostart".len() + 5) as u32, 20)), + Rectangle::new(Point::new(10, 110), Size::new((10 * "Disable autostart".len() + 5) as u32, 20)), Self::autostart_label(slot), true ), @@ -46,7 +47,7 @@ impl Gui for AppInfoPage { fn draw_init(&self, target: &mut EpdDrawTarget) { let header = unsafe { slot(self.slot) }; - Text::new("Program: ", Point::new(10, 20), DEFAULT_TEXT_STYLE) + Text::new("Program:", Point::new(10, 20), DEFAULT_TEXT_STYLE) .draw(target) .unwrap(); @@ -61,7 +62,7 @@ impl Gui for AppInfoPage { } - Text::new("Version: ", Point::new(10, 40), DEFAULT_TEXT_STYLE) + Text::new("Version:", Point::new(10, 40), DEFAULT_TEXT_STYLE) .draw(target) .unwrap(); @@ -75,6 +76,15 @@ impl Gui for AppInfoPage { .unwrap(); } + Text::new("Slot:", Point::new(10, 60), DEFAULT_TEXT_STYLE) + .draw(target) + .unwrap(); + let mut slot_s = heapless::String::<2>::new(); + write!(slot_s, "{}", self.slot).unwrap(); + Text::new(&slot_s, Point::new(120, 60), DEFAULT_TEXT_STYLE) + .draw(target) + .unwrap(); + self.back_button.draw_init(target); self.delete_button.draw_init(target); self.autostart_button.draw_init(target); diff --git a/eepy-sys/src/critical_section_impl.rs b/eepy-sys/src/critical_section_impl.rs index a8a19c2..8f46e02 100644 --- a/eepy-sys/src/critical_section_impl.rs +++ b/eepy-sys/src/critical_section_impl.rs @@ -8,18 +8,22 @@ critical_section::set_impl!(EepyCs); unsafe impl critical_section::Impl for EepyCs { unsafe fn acquire() -> bool { let mut state: usize; - syscall!( - SyscallNumber::CriticalSection, - out state in CsSyscall::Acquire, - ); + unsafe { + syscall!( + SyscallNumber::CriticalSection, + out state in CsSyscall::Acquire, + ); + } state != 0 } unsafe fn release(state: bool) { - syscall!( - SyscallNumber::CriticalSection, - in CsSyscall::Release, - in state, - ); + unsafe { + syscall!( + SyscallNumber::CriticalSection, + in CsSyscall::Release, + in state, + ); + } } } \ No newline at end of file diff --git a/eepy/src/flash.rs b/eepy/src/flash.rs index eb4409e..852d45c 100644 --- a/eepy/src/flash.rs +++ b/eepy/src/flash.rs @@ -30,9 +30,9 @@ fn flush_cache_range(start_addr: u32, len: u32) { unsafe { let start_ptr: *mut u32 = XIP_BASE.add(start_addr as usize).cast_mut().cast(); - let words = len / 4; - for _ in 0..words { - start_ptr.add(words as usize).write_volatile(0); + let words = len / size_of::() as u32; + for word in 0..words { + start_ptr.add(word as usize).write_volatile(0); } } } diff --git a/launcher.x b/launcher.x index e2f7001..914dfa1 100644 --- a/launcher.x +++ b/launcher.x @@ -2,8 +2,8 @@ EXTERN(entry); ENTRY(entry); MEMORY { - RAM : ORIGIN = 0x20020000, LENGTH = 136K - SLOT: ORIGIN = 0x10000000 + 128K, LENGTH = 128K + RAM : ORIGIN = 0x20020000, LENGTH = 136K + SLOT : ORIGIN = 0x10000000 + 128K, LENGTH = 128K } SECTIONS { -- 2.51.2