From fe646f52c1db5a67597bc5bf26ca260aebccffcb Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 21 May 2023 18:25:27 +0800 Subject: [PATCH] fix #382 this should fix the issue on #382. The behavior is now: *device not plugged in* 1. select "Lock device (reboot)" 2. device reboots 3. device goes to sleep 4. user wakes up the device 5. user is challenged with the unlock PIN *device is plugged in* 1. select "Lock device (reboot)" 2. device reboots 3. user is challenged with the unlock PIN I think this should be the "least surprising" outcome given the description of the menu item. --- services/status/src/main.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/services/status/src/main.rs b/services/status/src/main.rs index c7c6c161c..1f1c418e0 100644 --- a/services/status/src/main.rs +++ b/services/status/src/main.rs @@ -634,18 +634,16 @@ fn wrapped_main() -> ! { // reset it for good measure early_settings.set_early_sleep(false).unwrap(); - while ((llio.adc_vbus().unwrap() as u32) * 503) > 150_000 { - modals.show_notification(t!("mainmenu.cant_sleep", xous::LANG), None).expect("couldn't notify that power is plugged in"); - } - - match susres.initiate_suspend() { - Ok(_) => {}, - Err(xous::Error::Timeout) => { - // TODO: maybe this branch needs a different log message/flow? - modals.show_notification(t!("suspend.fail", xous::LANG), None).unwrap(); - } - Err(_e) => { - panic!("Unhandled error on suspend request"); + if ((llio.adc_vbus().unwrap() as u32) * 503) <= 150_000 { + match susres.initiate_suspend() { + Ok(_) => {}, + Err(xous::Error::Timeout) => { + // TODO: maybe this branch needs a different log message/flow? + modals.show_notification(t!("suspend.fail", xous::LANG), None).unwrap(); + } + Err(_e) => { + panic!("Unhandled error on suspend request"); + } } } }