EMF_Camp_Badge/mass_storage/main.py

29 lines
1.0 KiB
Python
Raw Normal View History

2018-08-29 08:06:54 -04:00
"""Enables mass storage mode in a safe way"""
2018-09-03 09:59:37 -04:00
___title___ = "Mass Storage Enabler"
2018-08-29 08:06:54 -04:00
___license___ = "MIT"
___dependencies___ = ["dialogs", "ugfx_helper"]
___categories___ = ["EMF"]
___bootstrapped___ = True
import ugfx, tilda, ugfx_helper, dialogs, app, time
2018-08-29 08:06:54 -04:00
ugfx_helper.init()
ugfx.clear()
2018-09-03 18:43:00 -04:00
user_agreed = dialogs.prompt_boolean("Note: enabling mass storage is slightly risky, as the badge may end up factory "
"resetting even if you safely eject it. Do you want to continue?")
if user_agreed:
print("enabling USB storage...")
tilda.storage_enable_usb()
time.sleep(1)
2018-08-29 08:06:54 -04:00
print("DONE")
2018-09-03 18:43:00 -04:00
with dialogs.WaitingMessage(title="Mass Storage Enabled", text="You can now use the badge like a USB key.\nPlease safely eject afterwards. This app will close automatically."):
print("Waiting for USB mass storage to be unmounted...")
tilda.storage_disable_usb()
print("DONE")
app.restart_to_default()
else:
app.restart_to_default()