mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
rework menu items and ordering
init for RTC shouldn't appear until keys are initialized and PDDB has been mounted.
This commit is contained in:
parent
2340686e80
commit
ee4511c35d
4 changed files with 43 additions and 32 deletions
|
|
@ -25,10 +25,16 @@
|
||||||
"en-tts": "Set Time"
|
"en-tts": "Set Time"
|
||||||
},
|
},
|
||||||
"stats.mount_pddb": {
|
"stats.mount_pddb": {
|
||||||
"ja": "ログイン?",
|
"ja": " ",
|
||||||
"en": "Login? ",
|
"en": " ",
|
||||||
"zh": "登录?",
|
"zh": " ",
|
||||||
"en-tts": "Login? "
|
"en-tts": " "
|
||||||
|
},
|
||||||
|
"stats.please_mount": {
|
||||||
|
"ja": "PDDBをマウントして、再試行してください。",
|
||||||
|
"en": "Please mount the PDDB and try again.",
|
||||||
|
"zh": "请挂载 PDDB 并重试。",
|
||||||
|
"en-tts": "Please mount the PDDB and try again."
|
||||||
},
|
},
|
||||||
"secnote.usb_unlock": {
|
"secnote.usb_unlock": {
|
||||||
"en": " USB unlocked",
|
"en": " USB unlocked",
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ fn xmain() -> ! {
|
||||||
// some RTC UX structures
|
// some RTC UX structures
|
||||||
let modals = modals::Modals::new(&xns).unwrap();
|
let modals = modals::Modals::new(&xns).unwrap();
|
||||||
let timeserver_cid = xous::connect(xous::SID::from_bytes(crate::time::TIME_SERVER_PUBLIC).unwrap()).unwrap();
|
let timeserver_cid = xous::connect(xous::SID::from_bytes(crate::time::TIME_SERVER_PUBLIC).unwrap()).unwrap();
|
||||||
let localtime = llio::LocalTime::new();
|
let mut localtime = llio::LocalTime::new();
|
||||||
let pddb_poller = pddb::PddbMountPoller::new();
|
let pddb_poller = pddb::PddbMountPoller::new();
|
||||||
|
|
||||||
log::debug!("subscribe to wifi updates");
|
log::debug!("subscribe to wifi updates");
|
||||||
|
|
@ -585,6 +585,10 @@ fn xmain() -> ! {
|
||||||
stats_phase = stats_phase.wrapping_add(1);
|
stats_phase = stats_phase.wrapping_add(1);
|
||||||
}
|
}
|
||||||
Some(StatusOpcode::UxSetTime) => msg_scalar_unpack!(msg, _, _, _, _, {
|
Some(StatusOpcode::UxSetTime) => msg_scalar_unpack!(msg, _, _, _, _, {
|
||||||
|
if !pddb_poller.is_mounted_nonblocking() {
|
||||||
|
modals.show_notification(t!("stats.please_mount", xous::LANG)).expect("couldn't show notification");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pump_run.store(false, Ordering::Relaxed); // stop status updates while we do this
|
pump_run.store(false, Ordering::Relaxed); // stop status updates while we do this
|
||||||
let secs: u8;
|
let secs: u8;
|
||||||
let mins: u8;
|
let mins: u8;
|
||||||
|
|
@ -651,6 +655,10 @@ fn xmain() -> ! {
|
||||||
pump_run.store(true, Ordering::Relaxed); // stop status updates while we do this
|
pump_run.store(true, Ordering::Relaxed); // stop status updates while we do this
|
||||||
}),
|
}),
|
||||||
Some(StatusOpcode::UxSetTimeZone) => {
|
Some(StatusOpcode::UxSetTimeZone) => {
|
||||||
|
if !pddb_poller.is_mounted_nonblocking() {
|
||||||
|
modals.show_notification(t!("stats.please_mount", xous::LANG)).expect("couldn't show notification");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pump_run.store(false, Ordering::Relaxed); // stop status updates while we do this
|
pump_run.store(false, Ordering::Relaxed); // stop status updates while we do this
|
||||||
let tz = modals.get_text(
|
let tz = modals.get_text(
|
||||||
t!("rtc.timezone", xous::LANG),
|
t!("rtc.timezone", xous::LANG),
|
||||||
|
|
@ -697,11 +705,11 @@ fn xmain() -> ! {
|
||||||
gam.raise_menu(gam::APP_MENU_NAME).expect("couldn't raise App submenu");
|
gam.raise_menu(gam::APP_MENU_NAME).expect("couldn't raise App submenu");
|
||||||
},
|
},
|
||||||
Some(StatusOpcode::SubmenuKbd) => {
|
Some(StatusOpcode::SubmenuKbd) => {
|
||||||
log::info!("getting keyboard map");
|
log::debug!("getting keyboard map");
|
||||||
let map = kbd.get_keymap().expect("couldn't get key mapping");
|
let map = kbd.get_keymap().expect("couldn't get key mapping");
|
||||||
log::info!("setting index to {:?}", map);
|
log::info!("setting keymap index to {:?}", map);
|
||||||
kbd_menumatic.set_index(map.into());
|
kbd_menumatic.set_index(map.into());
|
||||||
log::info!("raising keyboard menu");
|
log::debug!("raising keyboard menu");
|
||||||
ticktimer.sleep_ms(100).ok(); // yield for a moment to allow the previous menu to close
|
ticktimer.sleep_ms(100).ok(); // yield for a moment to allow the previous menu to close
|
||||||
gam.raise_menu(gam::KBD_MENU_NAME).expect("couldn't raise keyboard layout submenu");
|
gam.raise_menu(gam::KBD_MENU_NAME).expect("couldn't raise keyboard layout submenu");
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -73,22 +73,22 @@ pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, status_conn: xous::CID, com:
|
||||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||||
close_on_select: true,
|
close_on_select: true,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
menuitems.push(MenuItem {
|
menuitems.push(MenuItem {
|
||||||
name: String::from_str(t!("mainmenu.set_rtc", xous::LANG)),
|
name: String::from_str(t!("mainmenu.set_rtc", xous::LANG)),
|
||||||
action_conn: Some(status_conn),
|
action_conn: Some(status_conn),
|
||||||
action_opcode: StatusOpcode::UxSetTime.to_u32().unwrap(),
|
action_opcode: StatusOpcode::UxSetTime.to_u32().unwrap(),
|
||||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||||
close_on_select: true,
|
close_on_select: true,
|
||||||
});
|
});
|
||||||
menuitems.push(MenuItem {
|
menuitems.push(MenuItem {
|
||||||
name: String::from_str(t!("mainmenu.set_tz", xous::LANG)),
|
name: String::from_str(t!("mainmenu.set_tz", xous::LANG)),
|
||||||
action_conn: Some(status_conn),
|
action_conn: Some(status_conn),
|
||||||
action_opcode: StatusOpcode::UxSetTimeZone.to_u32().unwrap(),
|
action_opcode: StatusOpcode::UxSetTimeZone.to_u32().unwrap(),
|
||||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||||
close_on_select: true,
|
close_on_select: true,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
menuitems.push(MenuItem {
|
menuitems.push(MenuItem {
|
||||||
name: String::from_str(t!("mainmenu.reboot", xous::LANG)),
|
name: String::from_str(t!("mainmenu.reboot", xous::LANG)),
|
||||||
|
|
|
||||||
|
|
@ -33,10 +33,6 @@ use num_traits::*;
|
||||||
/// Even thought it is "public" nobody connects to it directly, they connect to it via `libstd`
|
/// Even thought it is "public" nobody connects to it directly, they connect to it via `libstd`
|
||||||
/// hence the scope of the name is private to this crate.
|
/// hence the scope of the name is private to this crate.
|
||||||
pub const TIME_SERVER_PUBLIC: &'static [u8; 16] = b"timeserverpublic";
|
pub const TIME_SERVER_PUBLIC: &'static [u8; 16] = b"timeserverpublic";
|
||||||
/// This is the registered name for a dedicated private API channel to the PDDB for doing the time reset
|
|
||||||
/// Even though nobody but the PDDB should connect to this, we have to share it publicly so the PDDB can
|
|
||||||
/// depend upon this constant.
|
|
||||||
pub const TIME_SERVER_PDDB: &'static str = "_dedicated pddb timeserver connection_";
|
|
||||||
|
|
||||||
/// Dictionary for RTC settings.
|
/// Dictionary for RTC settings.
|
||||||
const TIME_SERVER_DICT: &'static str = "sys.rtc";
|
const TIME_SERVER_DICT: &'static str = "sys.rtc";
|
||||||
|
|
@ -89,7 +85,7 @@ pub fn start_time_server() {
|
||||||
|
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
// we expect exactly one connection from the PDDB
|
// we expect exactly one connection from the PDDB
|
||||||
let priv_sid = xns.register_name(TIME_SERVER_PDDB, Some(1)).expect("can't register server");
|
let priv_sid = xns.register_name(pddb::TIME_SERVER_PDDB, Some(1)).expect("can't register server");
|
||||||
let mut i2c = llio::I2c::new(&xns);
|
let mut i2c = llio::I2c::new(&xns);
|
||||||
let trng = trng::Trng::new(&xns).unwrap();
|
let trng = trng::Trng::new(&xns).unwrap();
|
||||||
let llio = llio::Llio::new(&xns);
|
let llio = llio::Llio::new(&xns);
|
||||||
|
|
@ -209,10 +205,10 @@ pub fn start_time_server() {
|
||||||
if tz_key.read(&mut tz_buf).unwrap_or(0) == 8 {
|
if tz_key.read(&mut tz_buf).unwrap_or(0) == 8 {
|
||||||
tz_offset_ms = i64::from_le_bytes(tz_buf);
|
tz_offset_ms = i64::from_le_bytes(tz_buf);
|
||||||
}
|
}
|
||||||
log::info!("offset_key: {}", utc_offset_ms);
|
log::debug!("offset_key: {}", utc_offset_ms);
|
||||||
log::info!("tz_key: {}", tz_offset_ms);
|
log::debug!("tz_key: {}", tz_offset_ms);
|
||||||
log::info!("start_rtc_secs: {}", start_rtc_secs);
|
log::debug!("start_rtc_secs: {}", start_rtc_secs);
|
||||||
log::info!("start_tt_ms: {}", start_tt_ms);
|
log::debug!("start_tt_ms: {}", start_tt_ms);
|
||||||
loop {
|
loop {
|
||||||
let msg = xous::receive_message(pub_sid).unwrap();
|
let msg = xous::receive_message(pub_sid).unwrap();
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
|
|
@ -339,6 +335,7 @@ pub fn start_time_server() {
|
||||||
let msg = xous::receive_message(priv_sid).unwrap();
|
let msg = xous::receive_message(priv_sid).unwrap();
|
||||||
match FromPrimitive::from_usize(msg.body.id()) {
|
match FromPrimitive::from_usize(msg.body.id()) {
|
||||||
Some(PrivTimeOp::ResetRtc) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
Some(PrivTimeOp::ResetRtc) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||||
|
log::warn!("RTC time reset command received.");
|
||||||
settings[CTL3] = (Control3::BATT_STD_BL_EN).bits();
|
settings[CTL3] = (Control3::BATT_STD_BL_EN).bits();
|
||||||
let mut start_time = trng.get_u64().unwrap();
|
let mut start_time = trng.get_u64().unwrap();
|
||||||
// set the clock to a random start time from 1 to 10 years into its maximum range of 100 years
|
// set the clock to a random start time from 1 to 10 years into its maximum range of 100 years
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue