mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add some useful messages on boot for the hosted mode users
This commit is contained in:
parent
69a22adee9
commit
2b5ba61552
4 changed files with 111 additions and 100 deletions
|
|
@ -574,6 +574,17 @@ fn xmain() -> ! {
|
|||
let mut powerdown_requested = false;
|
||||
let mut last_time: u64 = ticktimer.elapsed_ms();
|
||||
log::trace!("entering main loop");
|
||||
|
||||
#[cfg(not(target_os = "none"))]
|
||||
{
|
||||
log::info!("********************************************************************************");
|
||||
log::info!("USAGE:");
|
||||
log::info!(" `Home` key to bring up menu; arrow keys to go up/down; `Home` to select again");
|
||||
log::info!(" `F1`-`F4` to pick predictions; `F5` and `F6` generate test unicode characters");
|
||||
log::info!(" Otherwise type in the GUI window; `help` for the current command list");
|
||||
log::info!(" ^C in the console window (this window) to quit");
|
||||
log::info!("********************************************************************************");
|
||||
}
|
||||
loop {
|
||||
let mut msg = xous::receive_message(gam_sid).unwrap();
|
||||
log::trace!("Message: {:?}", msg);
|
||||
|
|
@ -888,3 +899,94 @@ fn xmain() -> ! {
|
|||
log::trace!("quitting");
|
||||
xous::terminate_process(0)
|
||||
}
|
||||
|
||||
|
||||
// this is the provider for the main menu, it's built into the GAM so we always have at least this
|
||||
// root-level menu available
|
||||
pub fn main_menu_thread() {
|
||||
let mut menu = Menu::new(crate::MAIN_MENU_NAME);
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let susres = susres::Susres::new_without_hook(&xns).unwrap();
|
||||
let com = com::Com::new(&xns).unwrap();
|
||||
|
||||
let blon_item = MenuItem {
|
||||
name: String::<64>::from_str("Backlight on"),
|
||||
action_conn: com.conn(),
|
||||
action_opcode: com.getop_backlight(),
|
||||
action_payload: MenuPayload::Scalar([191 >> 3, 191 >> 3, 0, 0]),
|
||||
close_on_select: true,
|
||||
};
|
||||
menu.add_item(blon_item);
|
||||
|
||||
let bloff_item = MenuItem {
|
||||
name: String::<64>::from_str("Backlight off"),
|
||||
action_conn: com.conn(),
|
||||
action_opcode: com.getop_backlight(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
};
|
||||
menu.add_item(bloff_item);
|
||||
|
||||
let sleep_item = MenuItem {
|
||||
name: String::<64>::from_str("Sleep now"),
|
||||
action_conn: susres.conn(),
|
||||
action_opcode: susres.getop_suspend(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
};
|
||||
menu.add_item(sleep_item);
|
||||
|
||||
let close_item = MenuItem {
|
||||
name: String::<64>::from_str("Close Menu"),
|
||||
action_conn: menu.gam.conn(),
|
||||
action_opcode: menu.gam.getop_revert_focus(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: false, // don't close because we're already closing
|
||||
};
|
||||
menu.add_item(close_item);
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ use gam::SetCanvasBoundsRequest;
|
|||
use xous_ipc::*;
|
||||
use graphics_server::*;
|
||||
use num_traits::*;
|
||||
use xous::msg_scalar_unpack;
|
||||
|
||||
const MAX_ITEMS: usize = 16;
|
||||
|
||||
|
|
@ -17,11 +16,11 @@ pub enum MenuPayload {
|
|||
}
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct MenuItem {
|
||||
name: String::<64>,
|
||||
action_conn: xous::CID,
|
||||
action_opcode: u32,
|
||||
action_payload: MenuPayload,
|
||||
close_on_select: bool,
|
||||
pub name: String::<64>,
|
||||
pub action_conn: xous::CID,
|
||||
pub action_opcode: u32,
|
||||
pub action_payload: MenuPayload,
|
||||
pub close_on_select: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -278,92 +277,3 @@ impl Menu {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////// strictly speaking this doesn't have to be in this file, but we make it part of this server so we are guaranteed to have a main menu at all times
|
||||
pub fn main_menu_thread() {
|
||||
let mut menu = Menu::new(crate::MAIN_MENU_NAME);
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let susres = susres::Susres::new_without_hook(&xns).unwrap();
|
||||
let com = com::Com::new(&xns).unwrap();
|
||||
|
||||
let blon_item = MenuItem {
|
||||
name: String::<64>::from_str("Backlight on"),
|
||||
action_conn: com.conn(),
|
||||
action_opcode: com.getop_backlight(),
|
||||
action_payload: MenuPayload::Scalar([191 >> 3, 191 >> 3, 0, 0]),
|
||||
close_on_select: true,
|
||||
};
|
||||
menu.add_item(blon_item);
|
||||
|
||||
let bloff_item = MenuItem {
|
||||
name: String::<64>::from_str("Backlight off"),
|
||||
action_conn: com.conn(),
|
||||
action_opcode: com.getop_backlight(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
};
|
||||
menu.add_item(bloff_item);
|
||||
|
||||
let sleep_item = MenuItem {
|
||||
name: String::<64>::from_str("Sleep now"),
|
||||
action_conn: susres.conn(),
|
||||
action_opcode: susres.getop_suspend(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
};
|
||||
menu.add_item(sleep_item);
|
||||
|
||||
let close_item = MenuItem {
|
||||
name: String::<64>::from_str("Close Menu"),
|
||||
action_conn: menu.gam.conn(),
|
||||
action_opcode: menu.gam.getop_revert_focus(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: false, // don't close because we're already closing
|
||||
};
|
||||
menu.add_item(close_item);
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
@ -174,8 +174,8 @@ impl XousKeyboardHandler {
|
|||
Key::Up => '↑',
|
||||
Key::Down => '↓',
|
||||
Key::Home => '∴',
|
||||
Key::Backspace => 0x8_u8.into(),
|
||||
Key::Delete => 0x8_u8.into(),
|
||||
Key::Backspace => '\u{0008}',
|
||||
Key::Delete => '\u{0008}',
|
||||
Key::Enter => 0xd_u8.into(),
|
||||
Key::Space => ' ',
|
||||
Key::Comma => ',',
|
||||
|
|
@ -231,8 +231,8 @@ impl XousKeyboardHandler {
|
|||
Key::Up => '↑',
|
||||
Key::Down => '↓',
|
||||
Key::Home => '∴',
|
||||
Key::Backspace => 0x8_u8.into(),
|
||||
Key::Delete => 0x8_u8.into(),
|
||||
Key::Backspace => '\u{0008}',
|
||||
Key::Delete => '\u{0008}',
|
||||
Key::Space => ' ',
|
||||
Key::Comma => '<',
|
||||
Key::Period => '>',
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ fn map_dvorak(code: RowCol) -> ScanCode {
|
|||
(8, 8) => ScanCode{key: Some('.'), shift: Some('😃'), hold: Some('😃'), alt: None},
|
||||
(8, 9) => ScanCode{key: Some(0xf_u8.into()), shift: Some(0xf_u8.into()), hold: Some(0xf_u8.into()), alt: Some(0xf_u8.into())}, // shift in (blue shift)
|
||||
|
||||
// these are all bugged: row values are swapped on PCB
|
||||
// the F0/tab key also doubles as a secondary power key (can't do UP5K UART rx at same time)
|
||||
(8, 0) => ScanCode{key: Some(0x11_u8.into()), shift: Some(0x11_u8.into()), hold: Some(0x11_u8.into()), alt: Some(0x11_u8.into())}, // DC1 (F1)
|
||||
(8, 1) => ScanCode{key: Some(0x12_u8.into()), shift: Some(0x12_u8.into()), hold: Some(0x12_u8.into()), alt: Some(0x12_u8.into())}, // DC2 (F2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue