From cf49e627772af614a5cf662f674298358274ec8d Mon Sep 17 00:00:00 2001
From: Rahix <rahix@rahix.de>
Date: Sun, 4 Apr 2021 15:30:32 +0200
Subject: [PATCH] feat(menu): Return from USB once the host ejects the device

Automatically exit the "USB storage mode" once the connected USB host
ejects card10.
---
 preload/menu.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/preload/menu.py b/preload/menu.py
index 44238f52..8e1eb4a9 100644
--- a/preload/menu.py
+++ b/preload/menu.py
@@ -82,7 +82,7 @@ def usb_mode(disp):
         pass
 
     # Wait for any button to be pressed and disable USB storage again
-    while buttons.read() == 0:
+    while buttons.read() == 0 and not os.fs_is_attached():
         pass
 
     os.usbconfig(os.USB_SERIAL)
-- 
GitLab