mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add a submenu for PDDB operations
This commit is contained in:
parent
80bf673731
commit
2c711036a9
10 changed files with 49 additions and 54 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -2540,6 +2540,7 @@ dependencies = [
|
|||
"modals",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"pddb",
|
||||
"rkyv",
|
||||
"root-keys",
|
||||
"susres",
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use gam::modal::*;
|
|||
|
||||
use num_traits::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum RendererState {
|
||||
/// idle state
|
||||
None,
|
||||
|
|
@ -309,7 +310,7 @@ fn xmain() -> ! {
|
|||
match *mutex_op {
|
||||
RendererState::RunNotification(_) => *mutex_op = RendererState::None,
|
||||
_ => {
|
||||
log::error!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
|
||||
log::error!("UX return opcode does not match our current operation in flight: {:?}", mutex_op);
|
||||
panic!("UX return opcode does not match our current operation in flight. This is a serious internal error.");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,5 +98,10 @@
|
|||
"en": "List unlocked bases",
|
||||
"zh": "基础列表",
|
||||
"en-audio": "List unlocked bases"
|
||||
},
|
||||
"pddb.menu.listbasis_response": {
|
||||
"en": "Unlocked bases:\n",
|
||||
"zh": "透露列表:\n",
|
||||
"en-audio": "Unlocked bases:"
|
||||
}
|
||||
}
|
||||
|
|
@ -72,6 +72,8 @@ pub(crate) const BCRYPT_COST: u32 = 7; // 10 is the minimum recommended by OWA
|
|||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) const PDDB_MODAL_NAME: &'static str = "pddb modal";
|
||||
#[allow(dead_code)]
|
||||
pub const PDDB_MENU_NAME: &'static str = "pddb menu";
|
||||
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
pub(crate) enum Opcode {
|
||||
|
|
|
|||
|
|
@ -1022,7 +1022,12 @@ fn xmain() -> ! {
|
|||
};
|
||||
}),
|
||||
Some(Opcode::MenuListBasis) => {
|
||||
unimplemented!();
|
||||
let bases = basis_cache.basis_list();
|
||||
let mut note = String::from(t!("pddb.menu.listbasis_response", xous::LANG));
|
||||
for basis in bases.iter() {
|
||||
note.push_str(basis);
|
||||
}
|
||||
modals.show_notification(¬e).expect("couldn't show basis list");
|
||||
},
|
||||
Some(Opcode::Quit) => {
|
||||
log::warn!("quitting the PDDB server");
|
||||
|
|
|
|||
|
|
@ -1,17 +1,13 @@
|
|||
use xous::msg_scalar_unpack;
|
||||
use gam::*;
|
||||
use num_traits::*;
|
||||
use xous_ipc::String;
|
||||
use locales::t;
|
||||
use crate::api::*;
|
||||
|
||||
use gam::*;
|
||||
|
||||
pub(crate) const PDDB_MENU_NAME: &'static str = "pddb menu";
|
||||
use xous_ipc::String;
|
||||
|
||||
pub(crate) fn pddb_menu(conn: xous::CID) {
|
||||
let mut menu = Menu::new(PDDB_MENU_NAME);
|
||||
let mut menu_items = Vec::<MenuItem>::new();
|
||||
|
||||
menu.add_item(
|
||||
menu_items.push(
|
||||
MenuItem {
|
||||
name: String::from_str(t!("pddb.menu.listbasis", xous::LANG)),
|
||||
action_conn: Some(conn),
|
||||
|
|
@ -20,47 +16,13 @@ pub(crate) fn pddb_menu(conn: xous::CID) {
|
|||
close_on_select: true,
|
||||
}
|
||||
);
|
||||
loop {
|
||||
let msg = xous::receive_message(menu.sid).unwrap();
|
||||
log::trace!("message: {:?}", msg);
|
||||
match FromPrimitive::from_usize(msg.body.id()) {
|
||||
Some(MenuOpcode::Redraw) => {
|
||||
menu.redraw();
|
||||
},
|
||||
Some(MenuOpcode::Rawkeys) => msg_scalar_unpack!(msg, k1, k2, k3, k4, {
|
||||
let keys = [
|
||||
if let Some(a) = core::char::from_u32(k1 as u32) {
|
||||
a
|
||||
} else {
|
||||
'\u{0000}'
|
||||
},
|
||||
if let Some(a) = core::char::from_u32(k2 as u32) {
|
||||
a
|
||||
} else {
|
||||
'\u{0000}'
|
||||
},
|
||||
if let Some(a) = core::char::from_u32(k3 as u32) {
|
||||
a
|
||||
} else {
|
||||
'\u{0000}'
|
||||
},
|
||||
if let Some(a) = core::char::from_u32(k4 as u32) {
|
||||
a
|
||||
} else {
|
||||
'\u{0000}'
|
||||
},
|
||||
];
|
||||
menu.key_event(keys);
|
||||
}),
|
||||
Some(MenuOpcode::Quit) => {
|
||||
break;
|
||||
},
|
||||
None => {
|
||||
log::error!("unknown opcode {:?}", msg.body.id());
|
||||
}
|
||||
}
|
||||
}
|
||||
log::trace!("menu thread exit, destroying servers");
|
||||
// do we want to add a deregister_ux call to the system?
|
||||
xous::destroy_server(menu.sid).unwrap();
|
||||
menu_items.push(MenuItem {
|
||||
name: String::from_str(t!("mainmenu.closemenu", xous::LANG)),
|
||||
action_conn: None,
|
||||
action_opcode: 0,
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
});
|
||||
|
||||
menu_matic(menu_items, PDDB_MENU_NAME, None);
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ locales = {path = "../../locales"}
|
|||
susres = {path = "../susres"}
|
||||
root-keys = {path = "../root-keys"}
|
||||
modals = {path = "../modals"}
|
||||
pddb = {path = "../pddb"}
|
||||
|
||||
num-derive = {version = "0.3.3", default-features = false}
|
||||
num-traits = {version = "0.2.14", default-features = false}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,11 @@
|
|||
"zh": "设置时间",
|
||||
"en-audio": "Set time"
|
||||
},
|
||||
"mainmenu.pddb": {
|
||||
"en": "PDDB Submenu",
|
||||
"zh": "PDDB子菜单",
|
||||
"en-audio": "PDDB submenu"
|
||||
},
|
||||
"mainmenu.reboot": {
|
||||
"en": "Reboot",
|
||||
"zh": "重启",
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ enum StatusOpcode {
|
|||
UxSetTime,
|
||||
/// Initiates a reboot
|
||||
Reboot,
|
||||
/// Raise the PDDB menu
|
||||
SubmenuPddb,
|
||||
/// Suspend handler from the main menu
|
||||
TrySuspend,
|
||||
Quit,
|
||||
|
|
@ -620,6 +622,9 @@ fn xmain() -> ! {
|
|||
panic!("system did not reboot");
|
||||
}
|
||||
}
|
||||
Some(StatusOpcode::SubmenuPddb) => {
|
||||
gam.raise_menu(pddb::PDDB_MENU_NAME).expect("couldn't raise PDDB submenu");
|
||||
},
|
||||
Some(StatusOpcode::TrySuspend) => {
|
||||
if ((llio.adc_vbus().unwrap() as f64) * 0.005033) > 1.5 {
|
||||
modals.show_notification(t!("mainmenu.cant_sleep", xous::LANG)).expect("couldn't notify that power is plugged in");
|
||||
|
|
|
|||
|
|
@ -79,12 +79,20 @@ pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, status_conn: xous::CID, com:
|
|||
close_on_select: true,
|
||||
});
|
||||
|
||||
menuitems.push(MenuItem {
|
||||
name: String::from_str(t!("mainmenu.pddb", xous::LANG)),
|
||||
action_conn: Some(status_conn),
|
||||
action_opcode: StatusOpcode::SubmenuPddb.to_u32().unwrap(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
});
|
||||
|
||||
menuitems.push(MenuItem {
|
||||
name: String::from_str(t!("mainmenu.closemenu", xous::LANG)),
|
||||
action_conn: None,
|
||||
action_opcode: 0,
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true, // don't close because we're already closing
|
||||
close_on_select: true,
|
||||
});
|
||||
|
||||
menu_matic(menuitems, MAIN_MENU_NAME, None);
|
||||
|
|
|
|||
Loading…
Reference in a new issue