mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add a battery disconnect option to the main menu
this will disconnect the battery and put the device in a very low power state, and you can only power it back on again by plugging it into a power source briefly.
This commit is contained in:
parent
dd9d56507c
commit
19b9b817a4
3 changed files with 27 additions and 0 deletions
|
|
@ -114,6 +114,12 @@
|
|||
"zh": "键盘布局...",
|
||||
"en-tts": "Keyboard layout submenu"
|
||||
},
|
||||
"mainmenu.battery_disconnect": {
|
||||
"en": "Disconnect battery",
|
||||
"ja": "バッテリーを外します",
|
||||
"zh": "断开电池",
|
||||
"en-tts": "Disconnect battery"
|
||||
},
|
||||
"mainmenu.reboot": {
|
||||
"en": "Reboot",
|
||||
"ja": "リブート",
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ pub(crate) enum StatusOpcode {
|
|||
|
||||
/// Suspend handler from the main menu
|
||||
TrySuspend,
|
||||
/// Ship mode handler for the main menu
|
||||
BatteryDisconnect,
|
||||
/// for returning wifi stats
|
||||
WifiStats,
|
||||
Quit,
|
||||
|
|
@ -756,6 +758,18 @@ fn xmain() -> ! {
|
|||
susres.initiate_suspend().expect("couldn't initiate suspend op");
|
||||
}
|
||||
},
|
||||
Some(StatusOpcode::BatteryDisconnect) => {
|
||||
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");
|
||||
} else {
|
||||
gam.shipmode_blank_request().ok();
|
||||
ticktimer.sleep_ms(500).unwrap();
|
||||
llio.allow_ec_snoop(true).unwrap();
|
||||
llio.allow_power_off(true).unwrap();
|
||||
com.ship_mode().unwrap();
|
||||
com.power_off_soc().unwrap();
|
||||
}
|
||||
},
|
||||
Some(StatusOpcode::Quit) => {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,13 @@ pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, status_conn: xous::CID, com:
|
|||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
});
|
||||
menuitems.push(MenuItem {
|
||||
name: String::from_str(t!("mainmenu.battery_disconnect", xous::LANG)),
|
||||
action_conn: Some(status_conn),
|
||||
action_opcode: StatusOpcode::BatteryDisconnect.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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue