mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-22 09:23:16 +00:00
Merge branch 'bunnie-dev' into main
This commit is contained in:
commit
837b2d5e9b
9 changed files with 203 additions and 59 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1978,6 +1978,7 @@ dependencies = [
|
||||||
"llio",
|
"llio",
|
||||||
"log",
|
"log",
|
||||||
"log-server",
|
"log-server",
|
||||||
|
"modals",
|
||||||
"net",
|
"net",
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ use xous_ipc::String;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// if you add more UxContexts, and you want them authorized by the GAM, add their names here.
|
// if you add more UxContexts, and you want them authorized by the GAM, add their names here.
|
||||||
const TOKEN_SLOTS: usize = 9;
|
const TOKEN_SLOTS: usize = 8;
|
||||||
const EXPECTED_BOOT_CONTEXTS: [&'static str; TOKEN_SLOTS] = [
|
const EXPECTED_BOOT_CONTEXTS: [&'static str; TOKEN_SLOTS] = [
|
||||||
"shellchat",
|
"shellchat",
|
||||||
"main menu",
|
"main menu",
|
||||||
|
|
@ -20,7 +20,6 @@ const EXPECTED_BOOT_CONTEXTS: [&'static str; TOKEN_SLOTS] = [
|
||||||
"emoji menu",
|
"emoji menu",
|
||||||
"rootkeys modal",
|
"rootkeys modal",
|
||||||
"rootkeys menu",
|
"rootkeys menu",
|
||||||
"test modal",
|
|
||||||
"pddb modal",
|
"pddb modal",
|
||||||
"shared modal",
|
"shared modal",
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,16 @@ pub struct ManagedProgress {
|
||||||
pub current_work: u32,
|
pub current_work: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This isn't a terribly useful notification -- it's basically read-only, no interactivity,
|
||||||
|
/// but you can animate the text. Mainly used for testing routines. Might be modifiable
|
||||||
|
/// into something more useful with a bit of thought, but for now, MVP.
|
||||||
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
||||||
|
pub struct DynamicNotification {
|
||||||
|
pub token: [u32; 4],
|
||||||
|
pub title: Option<xous_ipc::String::<1024>>,
|
||||||
|
pub text: Option<xous_ipc::String::<2048>>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||||
pub(crate) enum Opcode {
|
pub(crate) enum Opcode {
|
||||||
// these are blocking calls
|
// these are blocking calls
|
||||||
|
|
@ -62,10 +72,12 @@ pub(crate) enum Opcode {
|
||||||
PromptWithTextResponse,
|
PromptWithTextResponse,
|
||||||
/// simple notification
|
/// simple notification
|
||||||
Notification,
|
Notification,
|
||||||
|
/// dynamic notification - a simple non-interactive notification that allows its text to be dynamically updated
|
||||||
|
DynamicNotification,
|
||||||
|
|
||||||
// these are non-blocking calls
|
// these are non-blocking calls
|
||||||
/// add an item to the radio box or check box. Note that all added items
|
/// add an item to the radio box or check box. Note that all added items
|
||||||
/// are cleared after the relevant "action" call happens (PrmoptWith[Fixed,Multi]Response)
|
/// are cleared after the relevant "action" call happens (PromptWith[Fixed,Multi]Response)
|
||||||
AddModalItem,
|
AddModalItem,
|
||||||
/// raise a progress bar
|
/// raise a progress bar
|
||||||
StartProgress,
|
StartProgress,
|
||||||
|
|
@ -73,6 +85,10 @@ pub(crate) enum Opcode {
|
||||||
UpdateProgress,
|
UpdateProgress,
|
||||||
/// lower a progress bar
|
/// lower a progress bar
|
||||||
StopProgress,
|
StopProgress,
|
||||||
|
/// update a dynamic notification's text
|
||||||
|
UpdateDynamicNotification,
|
||||||
|
/// close dynamic notification
|
||||||
|
CloseDynamicNotification,
|
||||||
|
|
||||||
GetMutex,
|
GetMutex,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,40 @@ impl Modals {
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dynamic_notification(&self, title: Option<&str>, text: Option<&str>) -> Result<(), xous::Error> {
|
||||||
|
self.lock();
|
||||||
|
let spec = DynamicNotification {
|
||||||
|
token: self.token,
|
||||||
|
title: if let Some(t) = title {Some(xous_ipc::String::from_str(t))} else {None},
|
||||||
|
text: if let Some(t) = text {Some(xous_ipc::String::from_str(t))} else {None},
|
||||||
|
};
|
||||||
|
let buf = Buffer::into_buf(spec).or(Err(xous::Error::InternalError))?;
|
||||||
|
buf.lend(self.conn, Opcode::DynamicNotification.to_u32().unwrap()).or(Err(xous::Error::InternalError))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
pub fn dynamic_notification_update(&self, title: Option<&str>, text: Option<&str>) -> Result<(), xous::Error> {
|
||||||
|
let spec = DynamicNotification {
|
||||||
|
token: self.token,
|
||||||
|
title: if let Some(t) = title {Some(xous_ipc::String::from_str(t))} else {None},
|
||||||
|
text: if let Some(t) = text {Some(xous_ipc::String::from_str(t))} else {None},
|
||||||
|
};
|
||||||
|
let buf = Buffer::into_buf(spec).or(Err(xous::Error::InternalError))?;
|
||||||
|
buf.lend(self.conn, Opcode::UpdateDynamicNotification.to_u32().unwrap()).or(Err(xous::Error::InternalError))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
pub fn dynamic_notification_close(&self) -> Result<(), xous::Error> {
|
||||||
|
self.lock();
|
||||||
|
send_message(self.conn,
|
||||||
|
Message::new_scalar(Opcode::CloseDynamicNotification.to_usize().unwrap(),
|
||||||
|
self.token[0] as usize,
|
||||||
|
self.token[1] as usize,
|
||||||
|
self.token[2] as usize,
|
||||||
|
self.token[3] as usize,
|
||||||
|
)
|
||||||
|
).expect("couldn't stop progress");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// busy-wait until we have acquired a mutex on the Modals server
|
/// busy-wait until we have acquired a mutex on the Modals server
|
||||||
fn lock(&self) {
|
fn lock(&self) {
|
||||||
while !self.try_get_mutex() {
|
while !self.try_get_mutex() {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ enum RendererState {
|
||||||
ResponseText(TextEntryPayload),
|
ResponseText(TextEntryPayload),
|
||||||
ResponseRadio(ItemName),
|
ResponseRadio(ItemName),
|
||||||
ResponseCheckBox(CheckBoxPayload),
|
ResponseCheckBox(CheckBoxPayload),
|
||||||
|
RunDynamicNotification(DynamicNotification),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||||
|
|
@ -45,10 +46,14 @@ pub(crate) enum RendererOp {
|
||||||
|
|
||||||
AddModalItem,
|
AddModalItem,
|
||||||
|
|
||||||
|
UpdateDynamicNotification,
|
||||||
|
CloseDynamicNotification,
|
||||||
|
|
||||||
ModalRedraw,
|
ModalRedraw,
|
||||||
ModalKeypress,
|
ModalKeypress,
|
||||||
ModalDrop,
|
ModalDrop,
|
||||||
Quit,
|
Quit,
|
||||||
|
Gutter,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[xous::xous_main]
|
#[xous::xous_main]
|
||||||
|
|
@ -85,6 +90,11 @@ fn xmain() -> ! {
|
||||||
renderer_cid,
|
renderer_cid,
|
||||||
RendererOp::NotificationReturn.to_u32().unwrap()
|
RendererOp::NotificationReturn.to_u32().unwrap()
|
||||||
);
|
);
|
||||||
|
let mut gutter = gam::modal::Notification::new(
|
||||||
|
renderer_cid,
|
||||||
|
RendererOp::Gutter.to_u32().unwrap()
|
||||||
|
);
|
||||||
|
gutter.set_manual_dismiss(false);
|
||||||
let mut progress_action = Slider::new(renderer_cid, RendererOp::NotificationReturn.to_u32().unwrap(),
|
let mut progress_action = Slider::new(renderer_cid, RendererOp::NotificationReturn.to_u32().unwrap(),
|
||||||
0, 100, 1, Some("%"), 0, true, true
|
0, 100, 1, Some("%"), 0, true, true
|
||||||
);
|
);
|
||||||
|
|
@ -111,18 +121,18 @@ fn xmain() -> ! {
|
||||||
log::debug!("renderer message: {:?}", msg);
|
log::debug!("renderer message: {:?}", msg);
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(RendererOp::InitiateOp) => {
|
Some(RendererOp::InitiateOp) => {
|
||||||
log::info!("InitiateOp called");
|
log::debug!("InitiateOp called");
|
||||||
let mutex_op = op.lock().unwrap();
|
let mutex_op = op.lock().unwrap();
|
||||||
match *mutex_op {
|
match *mutex_op {
|
||||||
RendererState::RunText(config) => {
|
RendererState::RunText(config) => {
|
||||||
log::info!("initiating text entry modal");
|
log::debug!("initiating text entry modal");
|
||||||
renderer_modal.modify(
|
renderer_modal.modify(
|
||||||
Some(ActionType::TextEntry(text_action)),
|
Some(ActionType::TextEntry(text_action)),
|
||||||
Some(config.prompt.as_str().unwrap()), false,
|
Some(config.prompt.as_str().unwrap()), false,
|
||||||
None, true, None
|
None, true, None
|
||||||
);
|
);
|
||||||
renderer_modal.activate();
|
renderer_modal.activate();
|
||||||
log::info!("should be active!");
|
log::debug!("should be active!");
|
||||||
},
|
},
|
||||||
RendererState::RunNotification(config) => {
|
RendererState::RunNotification(config) => {
|
||||||
renderer_modal.modify(
|
renderer_modal.modify(
|
||||||
|
|
@ -137,7 +147,7 @@ fn xmain() -> ! {
|
||||||
end_work = config.end_work;
|
end_work = config.end_work;
|
||||||
last_percentage = compute_checked_percentage(
|
last_percentage = compute_checked_percentage(
|
||||||
config.current_work, start_work, end_work);
|
config.current_work, start_work, end_work);
|
||||||
log::info!("init percentage: {}, current: {}, start: {}, end: {}", last_percentage, config.current_work, start_work, end_work);
|
log::debug!("init percentage: {}, current: {}, start: {}, end: {}", last_percentage, config.current_work, start_work, end_work);
|
||||||
progress_action.set_state(last_percentage);
|
progress_action.set_state(last_percentage);
|
||||||
|
|
||||||
renderer_modal.modify(
|
renderer_modal.modify(
|
||||||
|
|
@ -179,6 +189,23 @@ fn xmain() -> ! {
|
||||||
);
|
);
|
||||||
renderer_modal.activate();
|
renderer_modal.activate();
|
||||||
},
|
},
|
||||||
|
RendererState::RunDynamicNotification(config) => {
|
||||||
|
let mut top_text = String::new();
|
||||||
|
if let Some(title) = config.title {
|
||||||
|
top_text.push_str(title.as_str().unwrap());
|
||||||
|
}
|
||||||
|
let mut bot_text = String::new();
|
||||||
|
if let Some(text) = config.text {
|
||||||
|
bot_text.push_str(text.as_str().unwrap());
|
||||||
|
}
|
||||||
|
renderer_modal.modify(
|
||||||
|
Some(ActionType::Notification(gutter)),
|
||||||
|
Some(&top_text), config.title.is_none(),
|
||||||
|
Some(&bot_text), config.text.is_none(),
|
||||||
|
None
|
||||||
|
);
|
||||||
|
renderer_modal.activate();
|
||||||
|
},
|
||||||
RendererState::None => {
|
RendererState::None => {
|
||||||
log::error!("Operation initiated with no argument specified. Ignoring request.");
|
log::error!("Operation initiated with no argument specified. Ignoring request.");
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -209,6 +236,35 @@ fn xmain() -> ! {
|
||||||
Some(RendererOp::FinishProgress) => {
|
Some(RendererOp::FinishProgress) => {
|
||||||
renderer_modal.gam.relinquish_focus().unwrap();
|
renderer_modal.gam.relinquish_focus().unwrap();
|
||||||
},
|
},
|
||||||
|
Some(RendererOp::UpdateDynamicNotification) => {
|
||||||
|
let mutex_op = op.lock().unwrap();
|
||||||
|
match *mutex_op {
|
||||||
|
RendererState::RunDynamicNotification(config) => {
|
||||||
|
let mut top_text = String::new();
|
||||||
|
if let Some(title) = config.title {
|
||||||
|
top_text.push_str(title.as_str().unwrap());
|
||||||
|
}
|
||||||
|
let mut bot_text = String::new();
|
||||||
|
if let Some(text) = config.text {
|
||||||
|
bot_text.push_str(text.as_str().unwrap());
|
||||||
|
}
|
||||||
|
renderer_modal.modify(
|
||||||
|
None,
|
||||||
|
Some(&top_text), config.title.is_none(),
|
||||||
|
Some(&bot_text), config.text.is_none(),
|
||||||
|
None
|
||||||
|
);
|
||||||
|
renderer_modal.redraw();
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
log::error!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
|
||||||
|
panic!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Some(RendererOp::CloseDynamicNotification) => {
|
||||||
|
renderer_modal.gam.relinquish_focus().unwrap();
|
||||||
|
},
|
||||||
Some(RendererOp::TextEntryReturn) => {
|
Some(RendererOp::TextEntryReturn) => {
|
||||||
let mut mutex_op = op.lock().unwrap();
|
let mut mutex_op = op.lock().unwrap();
|
||||||
match *mutex_op {
|
match *mutex_op {
|
||||||
|
|
@ -258,6 +314,9 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Some(RendererOp::Gutter) => {
|
||||||
|
log::info!("gutter op, doing nothing");
|
||||||
|
},
|
||||||
Some(RendererOp::AddModalItem) => {
|
Some(RendererOp::AddModalItem) => {
|
||||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||||
let item = buffer.to_original::<ItemName, _>().unwrap();
|
let item = buffer.to_original::<ItemName, _>().unwrap();
|
||||||
|
|
@ -499,6 +558,44 @@ fn xmain() -> ! {
|
||||||
let fwd_buf = Buffer::into_buf(manageditem.item).unwrap();
|
let fwd_buf = Buffer::into_buf(manageditem.item).unwrap();
|
||||||
fwd_buf.lend(renderer_cid, RendererOp::AddModalItem.to_u32().unwrap()).expect("couldn't add item");
|
fwd_buf.lend(renderer_cid, RendererOp::AddModalItem.to_u32().unwrap()).expect("couldn't add item");
|
||||||
}
|
}
|
||||||
|
Some(Opcode::DynamicNotification) => {
|
||||||
|
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||||
|
let spec = buffer.to_original::<DynamicNotification, _>().unwrap();
|
||||||
|
if spec.token != token_lock.unwrap_or(default_nonce) {
|
||||||
|
log::warn!("Attempt to access modals without a mutex lock. Ignoring.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*op.lock().unwrap() = RendererState::RunDynamicNotification(spec);
|
||||||
|
send_message(
|
||||||
|
renderer_cid,
|
||||||
|
Message::new_scalar(RendererOp::InitiateOp.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
).expect("couldn't initiate UX op");
|
||||||
|
},
|
||||||
|
Some(Opcode::UpdateDynamicNotification) => {
|
||||||
|
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||||
|
let spec = buffer.to_original::<DynamicNotification, _>().unwrap();
|
||||||
|
if spec.token != token_lock.unwrap_or(default_nonce) {
|
||||||
|
log::warn!("Attempt to access modals without a mutex lock. Ignoring.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*op.lock().unwrap() = RendererState::RunDynamicNotification(spec);
|
||||||
|
send_message(
|
||||||
|
renderer_cid,
|
||||||
|
Message::new_scalar(RendererOp::UpdateDynamicNotification.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
).expect("couldn't initiate UX op");
|
||||||
|
},
|
||||||
|
Some(Opcode::CloseDynamicNotification) => msg_scalar_unpack!(msg, t0, t1, t2, t3, {
|
||||||
|
let token = [t0 as u32, t1 as u32, t2 as u32, t3 as u32];
|
||||||
|
if token != token_lock.unwrap_or(default_nonce) {
|
||||||
|
log::warn!("Attempt to access modals without a mutex lock. Ignoring.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
send_message(
|
||||||
|
renderer_cid,
|
||||||
|
Message::new_scalar(RendererOp::CloseDynamicNotification.to_usize().unwrap(), 0, 0, 0, 0)
|
||||||
|
).expect("couldn't close dynamic notification");
|
||||||
|
token_lock = None;
|
||||||
|
}),
|
||||||
Some(Opcode::Quit) => {
|
Some(Opcode::Quit) => {
|
||||||
log::warn!("Shared modal UX handler exiting.");
|
log::warn!("Shared modal UX handler exiting.");
|
||||||
break
|
break
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ jtag = {path="../jtag"}
|
||||||
net = {path="../net"}
|
net = {path="../net"}
|
||||||
dns = {path="../dns"}
|
dns = {path="../dns"}
|
||||||
pddb = {path="../pddb"}
|
pddb = {path="../pddb"}
|
||||||
|
modals = {path="../modals"}
|
||||||
|
|
||||||
trng = {path = "../trng"}
|
trng = {path = "../trng"}
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ utralib = {path = "../../utralib"}
|
||||||
debugprint = []
|
debugprint = []
|
||||||
spinortest = [] # for spinor testing. contra-indicated with PDDB, as it steals memory from the PDDB.
|
spinortest = [] # for spinor testing. contra-indicated with PDDB, as it steals memory from the PDDB.
|
||||||
benchmarks = [] # adds the benchmark routines. Left off normally to free up code and memory space.
|
benchmarks = [] # adds the benchmark routines. Left off normally to free up code and memory space.
|
||||||
default = ["benchmarks"] # "debugprint"
|
default = [] # "debugprint"
|
||||||
|
|
||||||
[target.'cfg(any(windows,unix))'.dependencies]
|
[target.'cfg(any(windows,unix))'.dependencies]
|
||||||
debug-here = "*"
|
debug-here = "*"
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ mod echo; use echo::*;
|
||||||
mod test; use test::*;
|
mod test; use test::*;
|
||||||
mod sleep; use sleep::*;
|
mod sleep; use sleep::*;
|
||||||
mod sensors; use sensors::*;
|
mod sensors; use sensors::*;
|
||||||
mod callback; use callback::*;
|
// mod callback; use callback::*;
|
||||||
mod rtc_cmd; use rtc_cmd::*;
|
mod rtc_cmd; use rtc_cmd::*;
|
||||||
mod vibe; use vibe::*;
|
mod vibe; use vibe::*;
|
||||||
mod ssid; use ssid::*;
|
mod ssid; use ssid::*;
|
||||||
|
|
@ -92,10 +92,8 @@ mod ver; use ver::*;
|
||||||
//mod audio; use audio::*; // this command is currently contra-indicated with PDDB, as the test audio currently overlaps the PDDB space. We'll fix this eventually, but for now, let's switch to PDDB mode.
|
//mod audio; use audio::*; // this command is currently contra-indicated with PDDB, as the test audio currently overlaps the PDDB space. We'll fix this eventually, but for now, let's switch to PDDB mode.
|
||||||
mod backlight; use backlight::*;
|
mod backlight; use backlight::*;
|
||||||
mod accel; use accel::*;
|
mod accel; use accel::*;
|
||||||
mod sha; use sha::*;
|
|
||||||
mod ecup; use ecup::*;
|
mod ecup; use ecup::*;
|
||||||
mod trng_cmd; use trng_cmd::*;
|
mod trng_cmd; use trng_cmd::*;
|
||||||
mod engine; use engine::*;
|
|
||||||
mod console; use console::*;
|
mod console; use console::*;
|
||||||
//mod memtest; use memtest::*;
|
//mod memtest; use memtest::*;
|
||||||
mod keys; use keys::*;
|
mod keys; use keys::*;
|
||||||
|
|
@ -104,6 +102,14 @@ mod jtag_cmd; use jtag_cmd::*;
|
||||||
mod net_cmd; use net_cmd::*;
|
mod net_cmd; use net_cmd::*;
|
||||||
mod pddb_cmd; use pddb_cmd::*;
|
mod pddb_cmd; use pddb_cmd::*;
|
||||||
|
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
mod engine;
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
use engine::*;
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
mod sha;
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
use sha::*;
|
||||||
#[cfg(feature="benchmarks")]
|
#[cfg(feature="benchmarks")]
|
||||||
mod aes_cmd;
|
mod aes_cmd;
|
||||||
#[cfg(feature="benchmarks")]
|
#[cfg(feature="benchmarks")]
|
||||||
|
|
@ -118,16 +124,13 @@ pub struct CmdEnv {
|
||||||
test_cmd: Test,
|
test_cmd: Test,
|
||||||
sleep_cmd: Sleep,
|
sleep_cmd: Sleep,
|
||||||
sensors_cmd: Sensors,
|
sensors_cmd: Sensors,
|
||||||
callback_cmd: CallBack,
|
//callback_cmd: CallBack,
|
||||||
rtc_cmd: RtcCmd,
|
rtc_cmd: RtcCmd,
|
||||||
vibe_cmd: Vibe,
|
vibe_cmd: Vibe,
|
||||||
ssid_cmd: Ssid,
|
ssid_cmd: Ssid,
|
||||||
//audio_cmd: Audio,
|
//audio_cmd: Audio,
|
||||||
sha_cmd: Sha,
|
|
||||||
ecup_cmd: EcUpdate,
|
ecup_cmd: EcUpdate,
|
||||||
aes_cmd: Aes,
|
|
||||||
trng_cmd: TrngCmd,
|
trng_cmd: TrngCmd,
|
||||||
engine_cmd: Engine,
|
|
||||||
//memtest_cmd: Memtest,
|
//memtest_cmd: Memtest,
|
||||||
keys_cmd: Keys,
|
keys_cmd: Keys,
|
||||||
jtag_cmd: JtagCmd,
|
jtag_cmd: JtagCmd,
|
||||||
|
|
@ -135,6 +138,12 @@ pub struct CmdEnv {
|
||||||
pddb_cmd: PddbCmd,
|
pddb_cmd: PddbCmd,
|
||||||
wlan_cmd: Wlan,
|
wlan_cmd: Wlan,
|
||||||
|
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
sha_cmd: Sha,
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
aes_cmd: Aes,
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
engine_cmd: Engine,
|
||||||
//fcc_cmd: Fcc,
|
//fcc_cmd: Fcc,
|
||||||
}
|
}
|
||||||
impl CmdEnv {
|
impl CmdEnv {
|
||||||
|
|
@ -152,10 +161,13 @@ impl CmdEnv {
|
||||||
xns: xous_names::XousNames::new().unwrap(),
|
xns: xous_names::XousNames::new().unwrap(),
|
||||||
};
|
};
|
||||||
//let fcc = Fcc::new(&mut common);
|
//let fcc = Fcc::new(&mut common);
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
let sha = Sha::new(&xns, &mut common);
|
let sha = Sha::new(&xns, &mut common);
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
let aes = Aes::new(&xns, &mut common);
|
let aes = Aes::new(&xns, &mut common);
|
||||||
let ecup = EcUpdate::new(&mut common);
|
#[cfg(feature="benchmarks")]
|
||||||
let engine = Engine::new(&xns, &mut common);
|
let engine = Engine::new(&xns, &mut common);
|
||||||
|
let ecup = EcUpdate::new(&mut common);
|
||||||
//let memtest = Memtest::new(&xns, &mut common);
|
//let memtest = Memtest::new(&xns, &mut common);
|
||||||
|
|
||||||
// print our version info
|
// print our version info
|
||||||
|
|
@ -175,16 +187,13 @@ impl CmdEnv {
|
||||||
test_cmd: Test::new(&xns),
|
test_cmd: Test::new(&xns),
|
||||||
sleep_cmd: Sleep::new(&xns),
|
sleep_cmd: Sleep::new(&xns),
|
||||||
sensors_cmd: Sensors::new(),
|
sensors_cmd: Sensors::new(),
|
||||||
callback_cmd: CallBack::new(),
|
//callback_cmd: CallBack::new(),
|
||||||
rtc_cmd: RtcCmd::new(&xns),
|
rtc_cmd: RtcCmd::new(&xns),
|
||||||
vibe_cmd: Vibe::new(),
|
vibe_cmd: Vibe::new(),
|
||||||
ssid_cmd: Ssid::new(),
|
ssid_cmd: Ssid::new(),
|
||||||
//audio_cmd: Audio::new(&xns),
|
//audio_cmd: Audio::new(&xns),
|
||||||
sha_cmd: sha,
|
|
||||||
ecup_cmd: ecup,
|
ecup_cmd: ecup,
|
||||||
aes_cmd: aes,
|
|
||||||
trng_cmd: TrngCmd::new(),
|
trng_cmd: TrngCmd::new(),
|
||||||
engine_cmd: engine,
|
|
||||||
//memtest_cmd: memtest,
|
//memtest_cmd: memtest,
|
||||||
keys_cmd: Keys::new(&xns),
|
keys_cmd: Keys::new(&xns),
|
||||||
jtag_cmd: JtagCmd::new(&xns),
|
jtag_cmd: JtagCmd::new(&xns),
|
||||||
|
|
@ -192,6 +201,12 @@ impl CmdEnv {
|
||||||
pddb_cmd: PddbCmd::new(&xns),
|
pddb_cmd: PddbCmd::new(&xns),
|
||||||
wlan_cmd: Wlan::new(),
|
wlan_cmd: Wlan::new(),
|
||||||
|
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
sha_cmd: sha,
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
aes_cmd: aes,
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
engine_cmd: engine,
|
||||||
//fcc_cmd: fcc,
|
//fcc_cmd: fcc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +225,7 @@ impl CmdEnv {
|
||||||
&mut self.test_cmd,
|
&mut self.test_cmd,
|
||||||
&mut self.sleep_cmd,
|
&mut self.sleep_cmd,
|
||||||
&mut self.sensors_cmd,
|
&mut self.sensors_cmd,
|
||||||
&mut self.callback_cmd,
|
//&mut self.callback_cmd,
|
||||||
&mut self.rtc_cmd,
|
&mut self.rtc_cmd,
|
||||||
&mut self.vibe_cmd,
|
&mut self.vibe_cmd,
|
||||||
&mut self.ssid_cmd,
|
&mut self.ssid_cmd,
|
||||||
|
|
@ -218,11 +233,8 @@ impl CmdEnv {
|
||||||
//&mut self.audio_cmd,
|
//&mut self.audio_cmd,
|
||||||
&mut backlight_cmd,
|
&mut backlight_cmd,
|
||||||
&mut accel_cmd,
|
&mut accel_cmd,
|
||||||
&mut self.sha_cmd,
|
|
||||||
&mut self.ecup_cmd,
|
&mut self.ecup_cmd,
|
||||||
&mut self.aes_cmd,
|
|
||||||
&mut self.trng_cmd,
|
&mut self.trng_cmd,
|
||||||
&mut self.engine_cmd,
|
|
||||||
&mut console_cmd,
|
&mut console_cmd,
|
||||||
// &mut self.memtest_cmd,
|
// &mut self.memtest_cmd,
|
||||||
&mut self.keys_cmd,
|
&mut self.keys_cmd,
|
||||||
|
|
@ -231,6 +243,12 @@ impl CmdEnv {
|
||||||
&mut self.net_cmd,
|
&mut self.net_cmd,
|
||||||
&mut self.pddb_cmd,
|
&mut self.pddb_cmd,
|
||||||
|
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
&mut self.sha_cmd,
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
&mut self.aes_cmd,
|
||||||
|
#[cfg(feature="benchmarks")]
|
||||||
|
&mut self.engine_cmd,
|
||||||
//&mut self.fcc_cmd,
|
//&mut self.fcc_cmd,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ pub struct Test {
|
||||||
start_elapsed: Option<u64>,
|
start_elapsed: Option<u64>,
|
||||||
end_elapsed: Option<u64>,
|
end_elapsed: Option<u64>,
|
||||||
oqc_cid: Option<xous::CID>,
|
oqc_cid: Option<xous::CID>,
|
||||||
|
kbd: Option<keyboard::Keyboard>,
|
||||||
oqc_start: u64,
|
oqc_start: u64,
|
||||||
#[cfg(any(target_os = "none", target_os = "xous"))]
|
#[cfg(any(target_os = "none", target_os = "xous"))]
|
||||||
jtag: jtag::Jtag,
|
jtag: jtag::Jtag,
|
||||||
|
|
@ -70,6 +71,7 @@ impl Test {
|
||||||
start_elapsed: None,
|
start_elapsed: None,
|
||||||
end_elapsed: None,
|
end_elapsed: None,
|
||||||
oqc_cid: None,
|
oqc_cid: None,
|
||||||
|
kbd: Some(keyboard::Keyboard::new(&xns).unwrap()), // allocate and save for use in the oqc_tester, so that the xous_names table is fully allocated
|
||||||
oqc_start: 0,
|
oqc_start: 0,
|
||||||
#[cfg(any(target_os = "none", target_os = "xous"))]
|
#[cfg(any(target_os = "none", target_os = "xous"))]
|
||||||
jtag: jtag::Jtag::new(&xns).unwrap(),
|
jtag: jtag::Jtag::new(&xns).unwrap(),
|
||||||
|
|
@ -411,11 +413,12 @@ impl<'a> ShellCmdApi<'a> for Test {
|
||||||
oc
|
oc
|
||||||
} else {
|
} else {
|
||||||
let oqc_cid = Arc::new(AtomicU32::new(0));
|
let oqc_cid = Arc::new(AtomicU32::new(0));
|
||||||
|
let kbd = self.kbd.take().expect("someone took the keyboard server before we could use it!");
|
||||||
// start the OQC thread
|
// start the OQC thread
|
||||||
let _ = std::thread::spawn({
|
let _ = std::thread::spawn({
|
||||||
let oqc_cid = oqc_cid.clone();
|
let oqc_cid = oqc_cid.clone();
|
||||||
move || {
|
move || {
|
||||||
crate::oqc_test::oqc_test(oqc_cid);
|
crate::oqc_test::oqc_test(oqc_cid, kbd);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// wait until the OQC thread has connected itself
|
// wait until the OQC thread has connected itself
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
use gam::modal::*;
|
|
||||||
use keyboard::{RowCol, KeyRawStates};
|
use keyboard::{RowCol, KeyRawStates};
|
||||||
use core::sync::atomic::{AtomicU32, Ordering, AtomicBool};
|
use core::sync::atomic::{AtomicU32, Ordering, AtomicBool};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
@ -19,7 +18,7 @@ pub(crate) enum OqcOp {
|
||||||
}
|
}
|
||||||
|
|
||||||
static SERVER_STARTED: AtomicBool = AtomicBool::new(false);
|
static SERVER_STARTED: AtomicBool = AtomicBool::new(false);
|
||||||
pub(crate) fn oqc_test(oqc_cid: Arc<AtomicU32>) {
|
pub(crate) fn oqc_test(oqc_cid: Arc<AtomicU32>, kbd: keyboard::Keyboard) {
|
||||||
// only start the server once!
|
// only start the server once!
|
||||||
if SERVER_STARTED.load(Ordering::SeqCst) {
|
if SERVER_STARTED.load(Ordering::SeqCst) {
|
||||||
return
|
return
|
||||||
|
|
@ -31,28 +30,16 @@ pub(crate) fn oqc_test(oqc_cid: Arc<AtomicU32>) {
|
||||||
let oqc_sid = xns.register_name(SERVER_NAME_OQC, None).expect("can't register server");
|
let oqc_sid = xns.register_name(SERVER_NAME_OQC, None).expect("can't register server");
|
||||||
|
|
||||||
let ticktimer = ticktimer_server::Ticktimer::new().unwrap();
|
let ticktimer = ticktimer_server::Ticktimer::new().unwrap();
|
||||||
let kbd = keyboard::Keyboard::new(&xns).unwrap();
|
//let kbd = keyboard::Keyboard::new(&xns).unwrap();
|
||||||
kbd.register_raw_listener(
|
kbd.register_raw_listener(
|
||||||
SERVER_NAME_OQC,
|
SERVER_NAME_OQC,
|
||||||
OqcOp::KeyCode.to_usize().unwrap()
|
OqcOp::KeyCode.to_usize().unwrap()
|
||||||
);
|
);
|
||||||
let com = com::Com::new(&xns).unwrap();
|
let com = com::Com::new(&xns).unwrap();
|
||||||
let llio = llio::Llio::new(&xns);
|
let llio = llio::Llio::new(&xns);
|
||||||
|
let gam = gam::Gam::new(&xns).unwrap();
|
||||||
|
|
||||||
let test_cid = xous::connect(oqc_sid).unwrap();
|
let modal = modals::Modals::new(&xns).unwrap();
|
||||||
let mut test_action = Notification::new(
|
|
||||||
test_cid,
|
|
||||||
OqcOp::UxGutter.to_u32().unwrap()
|
|
||||||
);
|
|
||||||
test_action.manual_dismiss = false;
|
|
||||||
let mut test_modal = Modal::new(
|
|
||||||
"test modal",
|
|
||||||
ActionType::Notification(test_action),
|
|
||||||
None,
|
|
||||||
Some("Initializing..."),
|
|
||||||
GlyphStyle::Small,
|
|
||||||
8
|
|
||||||
);
|
|
||||||
let mut test_run = false;
|
let mut test_run = false;
|
||||||
let mut remaining = populate_vectors();
|
let mut remaining = populate_vectors();
|
||||||
let mut bot_str = String::new();
|
let mut bot_str = String::new();
|
||||||
|
|
@ -69,15 +56,9 @@ pub(crate) fn oqc_test(oqc_cid: Arc<AtomicU32>) {
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(OqcOp::Trigger) => xous::msg_blocking_scalar_unpack!(msg, timeout_set, _, _, _, {
|
Some(OqcOp::Trigger) => xous::msg_blocking_scalar_unpack!(msg, timeout_set, _, _, _, {
|
||||||
if !test_run {
|
if !test_run {
|
||||||
test_modal.spawn_helper(oqc_sid, test_modal.sid,
|
|
||||||
OqcOp::ModalRedraw.to_u32().unwrap(),
|
|
||||||
OqcOp::ModalKeys.to_u32().unwrap(),
|
|
||||||
OqcOp::ModalDrop.to_u32().unwrap(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// test the screen
|
// test the screen
|
||||||
com.set_backlight(255, 255).unwrap();
|
com.set_backlight(255, 255).unwrap();
|
||||||
test_modal.gam.selftest(8_000); // 12_000 by default
|
gam.selftest(8_000); // 12_000 by default
|
||||||
|
|
||||||
// now start the keyboard test
|
// now start the keyboard test
|
||||||
timeout = if timeout_set > 120_000 {
|
timeout = if timeout_set > 120_000 {
|
||||||
|
|
@ -89,11 +70,7 @@ pub(crate) fn oqc_test(oqc_cid: Arc<AtomicU32>) {
|
||||||
last_redraw_time = start_time;
|
last_redraw_time = start_time;
|
||||||
log::info!("raising modal");
|
log::info!("raising modal");
|
||||||
render_string(&mut bot_str, &remaining, timeout - (ticktimer.elapsed_ms() - start_time));
|
render_string(&mut bot_str, &remaining, timeout - (ticktimer.elapsed_ms() - start_time));
|
||||||
test_modal.modify(None, None, false,
|
modal.dynamic_notification(None, Some(bot_str.as_str())).expect("couldn't raise test modal");
|
||||||
Some(bot_str.as_str()), false, None);
|
|
||||||
test_modal.activate();
|
|
||||||
test_modal.redraw();
|
|
||||||
test_modal.gam.set_vibe(true).unwrap();
|
|
||||||
|
|
||||||
// start a thread that advances the timer when not hitting keys
|
// start a thread that advances the timer when not hitting keys
|
||||||
xous::create_thread_2(ping_thread, xous::connect(oqc_sid).unwrap() as usize, timeout as usize).unwrap();
|
xous::create_thread_2(ping_thread, xous::connect(oqc_sid).unwrap() as usize, timeout as usize).unwrap();
|
||||||
|
|
@ -137,9 +114,7 @@ pub(crate) fn oqc_test(oqc_cid: Arc<AtomicU32>) {
|
||||||
}
|
}
|
||||||
if elapsed - last_redraw_time > 100 { // rate limit redraws to 10Hz
|
if elapsed - last_redraw_time > 100 { // rate limit redraws to 10Hz
|
||||||
render_string(&mut bot_str, &remaining, timeout - (elapsed - start_time));
|
render_string(&mut bot_str, &remaining, timeout - (elapsed - start_time));
|
||||||
test_modal.modify(None, None, false,
|
modal.dynamic_notification_update(None, Some(bot_str.as_str())).expect("couldn't update test modal");
|
||||||
Some(bot_str.as_str()), false, None);
|
|
||||||
test_modal.redraw();
|
|
||||||
last_redraw_time = elapsed;
|
last_redraw_time = elapsed;
|
||||||
llio.vibe(llio::VibePattern::Short).unwrap();
|
llio.vibe(llio::VibePattern::Short).unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +131,7 @@ pub(crate) fn oqc_test(oqc_cid: Arc<AtomicU32>) {
|
||||||
if finished {
|
if finished {
|
||||||
passing = Some(true);
|
passing = Some(true);
|
||||||
com.set_backlight(0, 0).unwrap();
|
com.set_backlight(0, 0).unwrap();
|
||||||
test_modal.gam.relinquish_focus().unwrap();
|
modal.dynamic_notification_close().unwrap();
|
||||||
log::info!("all keys hit, exiting");
|
log::info!("all keys hit, exiting");
|
||||||
test_finished = true;
|
test_finished = true;
|
||||||
}
|
}
|
||||||
|
|
@ -164,7 +139,7 @@ pub(crate) fn oqc_test(oqc_cid: Arc<AtomicU32>) {
|
||||||
// timeout
|
// timeout
|
||||||
passing = Some(false);
|
passing = Some(false);
|
||||||
com.set_backlight(0, 0).unwrap();
|
com.set_backlight(0, 0).unwrap();
|
||||||
test_modal.gam.relinquish_focus().unwrap();
|
modal.dynamic_notification_close().unwrap();
|
||||||
log::info!("test done, relinquishing focus");
|
log::info!("test done, relinquishing focus");
|
||||||
test_finished = true;
|
test_finished = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue