diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-04-08 13:50:35 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-04-08 13:50:35 +1000 |
| commit | 5f1a6507d8f7a0f9ecea179f94aeb182eac77cfe (patch) | |
| tree | 42220c19c5511902ef032ec0453a5d3b5cc2d39c /lua | |
| parent | 251c0ba96dadf8d28406095ec2189466b631f7f8 (diff) | |
| download | tangara-fw-5f1a6507d8f7a0f9ecea179f94aeb182eac77cfe.tar.gz | |
Warn and block MSC disable if the sd card is busy
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/settings.lua | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lua/settings.lua b/lua/settings.lua index 1e2debea..1a306dcf 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -282,10 +282,10 @@ local MassStorageSettings = screen:new { createUi = function(self) self.menu = SettingsScreen("USB Storage") local version = require("version").samd() - if tonumber(version) < 2 then + if tonumber(version) < 3 then self.menu.content:Label { w = lvgl.PCT(100), - text = "Usb Mass Storage requires a SAMD21 firmware version >=2." + text = "Usb Mass Storage requires a SAMD21 firmware version >=3." } return end @@ -304,6 +304,12 @@ local MassStorageSettings = screen:new { enable_container:Label { text = "Enable", flex_grow = 1 } local enable_sw = enable_container:Switch {} + local busy_text = self.menu.content:Label { + w = lvgl.PCT(100), + text = "USB is currently busy. Do not unplug or remove the SD card.", + long_mode = lvgl.LABEL.LONG_WRAP, + } + local bind_switch = function() if usb.msc_enabled:get() then enable_sw:add_state(lvgl.STATE.CHECKED) @@ -313,12 +319,21 @@ local MassStorageSettings = screen:new { end enable_sw:onevent(lvgl.EVENT.VALUE_CHANGED, function() - usb.msc_enabled:set(enable_sw:enabled()) + if not usb.msc_busy:get() then + usb.msc_enabled:set(enable_sw:enabled()) + end bind_switch() end) self.bindings = { usb.msc_enabled:bind(bind_switch), + usb.msc_busy:bind(function(busy) + if busy then + busy_text:clear_flag(lvgl.FLAG.HIDDEN) + else + busy_text:add_flag(lvgl.FLAG.HIDDEN) + end + end) } end, canPop = function() |
