mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
fix status bar so that it redraws out of suspend/resume
the bootloader modifies the screen, so all elements must be redrawn regardless of the pervious state change!
This commit is contained in:
parent
b31ff527a3
commit
84a2e9f768
6 changed files with 68 additions and 13 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -505,7 +505,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "3.1.0"
|
||||
source = "git+https://github.com/betrusted-io/curve25519-dalek.git?branch=main#b8f968b6e45816d3f5148eb3fb9e10803fedd3f9"
|
||||
source = "git+https://github.com/betrusted-io/curve25519-dalek.git?branch=main#c0ee5bf18c606b51bbffb02fde5801ac129b4e7d"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"digest",
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ lazy_static = "1.4.0"
|
|||
[features]
|
||||
debug-print = []
|
||||
earlyprintk = []
|
||||
default = ["debug-print"]
|
||||
#default = []
|
||||
#default = ["debug-print"]
|
||||
default = []
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1 # 1 better optimizations
|
||||
|
|
|
|||
|
|
@ -131,7 +131,8 @@ pub fn status_thread(canvas_gid_0: usize, canvas_gid_1: usize, canvas_gid_2: usi
|
|||
let llio = llio::Llio::new(&xns).unwrap();
|
||||
|
||||
log::debug!("usb unlock notice...");
|
||||
let mut debug_unlocked = llio.debug_usb_unlocked().unwrap();
|
||||
let (dl, _) = llio.debug_usb(None).unwrap();
|
||||
let mut debug_locked = dl;
|
||||
// build security status textview
|
||||
let mut security_tv = TextView::new(status_gid,
|
||||
TextBounds::BoundingBox(Rectangle::new(Point::new(0,screensize.y / 2),
|
||||
|
|
@ -182,13 +183,14 @@ pub fn status_thread(canvas_gid_0: usize, canvas_gid_1: usize, canvas_gid_2: usi
|
|||
needs_redraw = true;
|
||||
}),
|
||||
Some(StatusOpcode::Pump) => {
|
||||
if debug_unlocked != llio.debug_usb_unlocked().unwrap() {
|
||||
debug_unlocked = llio.debug_usb_unlocked().unwrap();
|
||||
let (is_locked, force_update) = llio.debug_usb(None).unwrap();
|
||||
if (debug_locked != is_locked) || force_update {
|
||||
debug_locked = is_locked;
|
||||
security_tv.clear_str();
|
||||
if debug_unlocked {
|
||||
write!(&mut security_tv, " USB unlocked").unwrap();
|
||||
} else {
|
||||
if debug_locked {
|
||||
write!(&mut security_tv, " USB secured").unwrap();
|
||||
} else {
|
||||
write!(&mut security_tv, " USB unlocked").unwrap();
|
||||
}
|
||||
// only post the view if something has actually changed
|
||||
gam.post_textview(&mut security_tv).unwrap();
|
||||
|
|
|
|||
|
|
@ -171,13 +171,13 @@ pub(crate) enum Opcode {
|
|||
GpioIntAsFalling, //(u32),
|
||||
GpioIntPending,
|
||||
GpioIntEna, //(u32),
|
||||
GpioIntSubscribe, //(String<64>), // TODO
|
||||
GpioIntSubscribe, //(String<64>), //
|
||||
GpioIntHappened,
|
||||
|
||||
/// set UART mux
|
||||
UartMux, //(UartType),
|
||||
|
||||
//TODO InfoLitexId, //(String<64>), // TODO: returns the ASCII string baked into the FPGA that describes the FPGA build, inside Registration
|
||||
// InfoLitexId, //(String<64>), // TODO: returns the ASCII string baked into the FPGA that describes the FPGA build, inside Registration
|
||||
InfoDna,
|
||||
InfoGit,
|
||||
InfoPlatform,
|
||||
|
|
@ -226,6 +226,9 @@ pub(crate) enum Opcode {
|
|||
EventRtcHappened,
|
||||
EventUsbHappened,
|
||||
|
||||
/// debug USB status
|
||||
DebugUsbOp,
|
||||
|
||||
/// SuspendResume callback
|
||||
SuspendResume,
|
||||
|
||||
|
|
|
|||
|
|
@ -523,8 +523,33 @@ impl Llio {
|
|||
Err(xous::Error::InternalError)
|
||||
}
|
||||
}
|
||||
pub fn debug_usb_unlocked(&self) -> Result<bool, xous::Error> {
|
||||
Ok(true) // for now, always return true, because we don't have the hardware yet to lock out debug USB
|
||||
// if do_lock is Some(), set the debug USB lock status to locked if true, unlocked if false
|
||||
// returns a tuple of (bool, bool) -> (is_locked, force_update)
|
||||
// needs_update is so that the polling function knows to redraw the UX after a resume-from-suspend
|
||||
pub fn debug_usb(&self, do_lock: Option<bool>) -> Result<(bool, bool), xous::Error> {
|
||||
// arg1 indicates if an update to the state is requested
|
||||
// arg2 is the new state update
|
||||
let (arg1, arg2) = if let Some(lock) = do_lock {
|
||||
if lock {
|
||||
(1, 1)
|
||||
} else {
|
||||
(1, 0)
|
||||
}
|
||||
} else {
|
||||
(0, 0)
|
||||
};
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::DebugUsbOp.to_usize().unwrap(), arg1, arg2, 0, 0))?;
|
||||
if let xous::Result::Scalar2(is_locked, force_update) = response {
|
||||
let il = if is_locked != 0 {true} else {false};
|
||||
let fu = if force_update != 0 {true} else {false};
|
||||
Ok(
|
||||
(il, fu)
|
||||
)
|
||||
} else {
|
||||
log::error!("LLIO: unexpected return value: {:#?}", response);
|
||||
Err(xous::Error::InternalError)
|
||||
}
|
||||
}
|
||||
pub fn set_uart_mux(&self, setting: UartType) -> Result<(), xous::Error> {
|
||||
if setting == UartType::Application {
|
||||
|
|
|
|||
|
|
@ -643,6 +643,8 @@ fn xmain() -> ! {
|
|||
let mut rtc_cb_conns: [Option<ScalarCallback>; 32] = [None; 32];
|
||||
let mut gpio_cb_conns: [Option<ScalarCallback>; 32] = [None; 32];
|
||||
|
||||
let mut lockstatus_force_update = true; // some state to track if we've been through a susupend/resume, to help out the status thread with its UX update after a restart-from-cold
|
||||
|
||||
log::trace!("starting main loop");
|
||||
loop {
|
||||
let msg = xous::receive_message(llio_sid).unwrap();
|
||||
|
|
@ -652,6 +654,7 @@ fn xmain() -> ! {
|
|||
llio.suspend();
|
||||
susres.suspend_until_resume(token).expect("couldn't execute suspend/resume");
|
||||
llio.resume();
|
||||
lockstatus_force_update = true; // notify the status bar that yes, it does need to redraw the lock status, even if the value hasn't changed since the last read
|
||||
}),
|
||||
Some(Opcode::CrgMode) => msg_scalar_unpack!(msg, _mode, _, _, _, {
|
||||
todo!("CrgMode opcode not yet implemented.");
|
||||
|
|
@ -858,6 +861,28 @@ fn xmain() -> ! {
|
|||
log::debug!("activity/period: {}/{}, {:.2}%", latest_activity, period, (latest_activity as f32 / period as f32) * 100.0);
|
||||
xous::return_scalar2(msg.sender, latest_activity as usize, period as usize).expect("couldn't return activity");
|
||||
}),
|
||||
Some(Opcode::DebugUsbOp) => msg_blocking_scalar_unpack!(msg, update_req, _new_state, _, _, {
|
||||
if update_req != 0 {
|
||||
// do something with new_state: this has yet to be implemented
|
||||
// if new_state is true, then try to lock the USB port
|
||||
// if false, try to unlock the USB port
|
||||
}
|
||||
// at this point, *read back* the new state -- don't assume it "took". The readback is always based on
|
||||
// a real hardware value and not the requested value. for now, always false.
|
||||
let is_locked = 0; // for now, always 0
|
||||
|
||||
// this is a performance optimization. we could always redraw the status, but, instead we only redraw when
|
||||
// the status has changed. However, there is an edge case: on a resume from suspend, the status needs a redraw,
|
||||
// even if nothing has changed. Thus, we have this separate boolean we send back to force an update in the
|
||||
// case that we have just come out of a suspend.
|
||||
let force_update = if lockstatus_force_update {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
xous::return_scalar2(msg.sender, is_locked, force_update).expect("couldn't return status");
|
||||
lockstatus_force_update = false;
|
||||
}),
|
||||
Some(Opcode::Quit) => {
|
||||
log::info!("Received quit opcode, exiting.");
|
||||
let dropconn = xous::connect(i2c_sid).unwrap();
|
||||
|
|
|
|||
Loading…
Reference in a new issue