can load & reload programs

This commit is contained in:
2025-09-18 16:25:24 -06:00
parent 1cd0d292fe
commit 39abe19fd3
2 changed files with 18 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ mod utils;
use core::sync::atomic::{AtomicBool, Ordering}; use core::sync::atomic::{AtomicBool, Ordering};
use crate::{ use crate::{
display::{clear_fb, display_handler, init_display}, display::{FRAMEBUFFER, clear_fb, display_handler, init_display},
peripherals::{ peripherals::{
conf_peripherals, conf_peripherals,
keyboard::{KeyState, read_keyboard_fifo}, keyboard::{KeyState, read_keyboard_fifo},
@@ -31,7 +31,8 @@ use crate::{
ui::{SELECTIONS, clear_selection, ui_handler}, ui::{SELECTIONS, clear_selection, ui_handler},
usb::usb_handler, usb::usb_handler,
}; };
use abi_sys::EntryFn; use abi_sys::{EntryFn, Rgb565, RgbColor};
use embedded_graphics::prelude::DrawTarget;
use {defmt_rtt as _, panic_probe as _}; use {defmt_rtt as _, panic_probe as _};
@@ -149,10 +150,15 @@ async fn userland_task() {
defmt::info!("Executing Binary"); defmt::info!("Executing Binary");
entry(); entry();
defmt::info!("Putting kernel back in UI mode");
// enable kernel ui // enable kernel ui
{ {
ENABLE_UI.store(true, Ordering::Release); ENABLE_UI.store(true, Ordering::Release);
UI_CHANGE.signal(()); UI_CHANGE.signal(());
unsafe { FRAMEBUFFER.clear(Rgb565::BLACK).unwrap() };
let mut selections = SELECTIONS.lock().await;
selections.set_changed(true);
} }
} }
} }
@@ -239,11 +245,11 @@ async fn kernel_task(
loop { loop {
let ui_enabled = ENABLE_UI.load(Ordering::Relaxed); let ui_enabled = ENABLE_UI.load(Ordering::Relaxed);
defmt::info!("ui enabled? {:?}", ui_enabled);
if ui_enabled { if ui_enabled {
let ui_fut = ui_handler(); defmt::info!("starting ui");
let binary_search_fut = prog_search_handler();
select(join(ui_fut, binary_search_fut), UI_CHANGE.wait()).await; select(join(ui_handler(), prog_search_handler()), UI_CHANGE.wait()).await;
} else { } else {
select(key_handler(), UI_CHANGE.wait()).await; select(key_handler(), UI_CHANGE.wait()).await;
} }

View File

@@ -3,6 +3,7 @@ use crate::{
}; };
use alloc::{str::FromStr, string::String, vec::Vec}; use alloc::{str::FromStr, string::String, vec::Vec};
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex}; use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, mutex::Mutex};
use embassy_time::Timer;
use embedded_graphics::{ use embedded_graphics::{
Drawable, Drawable,
mono_font::{MonoTextStyle, ascii::FONT_9X15}, mono_font::{MonoTextStyle, ascii::FONT_9X15},
@@ -55,6 +56,8 @@ pub async fn ui_handler() {
clear_selection().await; clear_selection().await;
draw_selection().await; draw_selection().await;
} }
Timer::after_millis(50).await;
} }
} }
@@ -146,6 +149,10 @@ impl SelectionList {
} }
} }
pub fn set_changed(&mut self, changed: bool) {
self.changed = changed
}
pub fn update_selections(&mut self, selections: Vec<FileName>) { pub fn update_selections(&mut self, selections: Vec<FileName>) {
self.selections = selections; self.selections = selections;
self.changed = true; self.changed = true;