mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
disallow sleep while charging
This commit is contained in:
parent
77f4356620
commit
700975ec63
3 changed files with 16 additions and 3 deletions
|
|
@ -73,5 +73,10 @@
|
|||
"en": "Close menu",
|
||||
"zh": "关闭功能表",
|
||||
"en-audio": "Close menu"
|
||||
},
|
||||
"mainmenu.cant_sleep": {
|
||||
"en": "Can't sleep while charging",
|
||||
"zh": "充电时睡不着",
|
||||
"en-audio": "Can't sleep while charging"
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,8 @@ enum StatusOpcode {
|
|||
UxSetTime,
|
||||
/// Initiates a reboot
|
||||
Reboot,
|
||||
/// Suspend handler from the main menu
|
||||
TrySuspend,
|
||||
Quit,
|
||||
}
|
||||
|
||||
|
|
@ -623,6 +625,13 @@ fn xmain() -> ! {
|
|||
panic!("system did not reboot");
|
||||
}
|
||||
}
|
||||
Some(StatusOpcode::TrySuspend) => {
|
||||
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 {
|
||||
susres.initiate_suspend().expect("couldn't initiate suspend op");
|
||||
}
|
||||
},
|
||||
Some(StatusOpcode::Quit) => {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ pub fn main_menu_thread(keys: Arc<Mutex<RootKeys>>, status_sid: xous::SID) {
|
|||
let mut menu = Menu::new(gam::api::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 {
|
||||
|
|
@ -38,8 +37,8 @@ pub fn main_menu_thread(keys: Arc<Mutex<RootKeys>>, status_sid: xous::SID) {
|
|||
|
||||
let sleep_item = MenuItem {
|
||||
name: String::<64>::from_str(t!("mainmenu.sleep", xous::LANG)),
|
||||
action_conn: susres.conn(),
|
||||
action_opcode: susres.getop_suspend(),
|
||||
action_conn: status_conn,
|
||||
action_opcode: StatusOpcode::TrySuspend.to_u32().unwrap(),
|
||||
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
|
||||
close_on_select: true,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue