feat: wire up Preferences menu in status

This commit is contained in:
Gianguido Sorà 2022-10-27 15:12:59 +02:00
parent a3a94ad50a
commit 17b7ba2ad0
2 changed files with 19 additions and 2 deletions

View file

@ -12,6 +12,7 @@ mod app_autogen;
mod time;
mod ecup;
mod wifi;
mod preferences;
use com::api::*;
use root_keys::api::{BackupOp, BackupKeyboardLayout};
@ -92,6 +93,9 @@ pub(crate) enum StatusOpcode {
/// Raise the wifi menu
WifiMenu,
/// Raise the preferences menu
Preferences,
Quit,
}
@ -365,6 +369,7 @@ fn wrapped_main() -> ! {
let thread_conn = xous::connect(status_sid).unwrap();
wifi::start_background_thread();
preferences::start_background_thread();
// load system preferences
let prefs = Arc::new(Mutex::new(userprefs::Manager::new()));
@ -401,14 +406,14 @@ fn wrapped_main() -> ! {
}.unwrap_or_else(|error| {
log::error!("cannot set radio status: {:?}", error)
});
match all_prefs.connect_known_networks_on_boot {
true => netmgr.connection_manager_run(),
false => netmgr.connection_manager_stop(),
}.unwrap_or_else(|error| {
log::error!("cannot start connection manager: {:?}", error)
});
match all_prefs.autobacklight_on_boot {
true => send_message(status_cid, Message::new_scalar(
StatusOpcode::EnableAutomaticBacklight.to_usize().unwrap(), 0,0,0,0)),
@ -862,6 +867,10 @@ fn wrapped_main() -> ! {
ticktimer.sleep_ms(100).ok(); // yield for a moment to allow the previous menu to close
gam.raise_menu(gam::WIFI_MENU_NAME).unwrap();
},
Some(StatusOpcode::Preferences) => {
ticktimer.sleep_ms(100).ok(); // yield for a moment to allow the previous menu to close
gam.raise_menu(gam::PREFERENCES_MENU_NAME).unwrap();
},
Some(StatusOpcode::Pump) => {
let elapsed_time = ticktimer.elapsed_ms();
{ // update the CPU load bar

View file

@ -141,6 +141,14 @@ pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, menu_management_sid: xous::S
close_on_select: true,
});
menuitems.push(MenuItem {
name: String::from_str(t!("mainmenu.preferences", xous::LANG)),
action_conn: Some(status_conn),
action_opcode: StatusOpcode::Preferences.to_u32().unwrap(),
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
close_on_select: true,
});
menuitems.push(MenuItem {
name: String::from_str(t!("mainmenu.lockdevice", xous::LANG)),
action_conn: Some(status_conn),