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 time;
mod ecup; mod ecup;
mod wifi; mod wifi;
mod preferences;
use com::api::*; use com::api::*;
use root_keys::api::{BackupOp, BackupKeyboardLayout}; use root_keys::api::{BackupOp, BackupKeyboardLayout};
@ -92,6 +93,9 @@ pub(crate) enum StatusOpcode {
/// Raise the wifi menu /// Raise the wifi menu
WifiMenu, WifiMenu,
/// Raise the preferences menu
Preferences,
Quit, Quit,
} }
@ -365,6 +369,7 @@ fn wrapped_main() -> ! {
let thread_conn = xous::connect(status_sid).unwrap(); let thread_conn = xous::connect(status_sid).unwrap();
wifi::start_background_thread(); wifi::start_background_thread();
preferences::start_background_thread();
// load system preferences // load system preferences
let prefs = Arc::new(Mutex::new(userprefs::Manager::new())); let prefs = Arc::new(Mutex::new(userprefs::Manager::new()));
@ -862,6 +867,10 @@ fn wrapped_main() -> ! {
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::WIFI_MENU_NAME).unwrap(); 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) => { Some(StatusOpcode::Pump) => {
let elapsed_time = ticktimer.elapsed_ms(); let elapsed_time = ticktimer.elapsed_ms();
{ // update the CPU load bar { // 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, 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 { menuitems.push(MenuItem {
name: String::from_str(t!("mainmenu.lockdevice", xous::LANG)), name: String::from_str(t!("mainmenu.lockdevice", xous::LANG)),
action_conn: Some(status_conn), action_conn: Some(status_conn),