show a message if the sd card is unmounted

custom
jacqueline 10 months ago
parent 624e4555ad
commit 9204b585ae
  1. 51
      lua/main_menu.lua
  2. 1
      src/tangara/system_fsm/running.cpp
  3. 3
      src/tangara/ui/lvgl_task.cpp

@ -90,26 +90,41 @@ return widgets.MenuScreen:new {
-- a list of all available database indexes, but could also be the contents -- a list of all available database indexes, but could also be the contents
-- of the SD card root. -- of the SD card root.
local list = lvgl.List(self.root, { if require("sd_card").mounted:get() then
w = lvgl.PCT(100), local list = lvgl.List(self.root, {
h = lvgl.PCT(100), w = lvgl.PCT(100),
flex_grow = 1, h = lvgl.PCT(100),
}) flex_grow = 1,
})
local indexes = database.indexes() local indexes = database.indexes()
for _, idx in ipairs(indexes) do for _, idx in ipairs(indexes) do
local btn = list:add_btn(nil, tostring(idx)) local btn = list:add_btn(nil, tostring(idx))
btn:onClicked(function() btn:onClicked(function()
backstack.push(browser:new { backstack.push(browser:new {
title = tostring(idx), title = tostring(idx),
iterator = idx:iter(), iterator = idx:iter(),
}) })
end) end)
btn:add_style(styles.list_item) btn:add_style(styles.list_item)
if not has_focus then if not has_focus then
has_focus = true has_focus = true
btn:focus() btn:focus()
end
end end
else
local container = self.root:Object {
w = lvgl.PCT(100),
flex_grow = 1,
}
container:Label {
w = lvgl.PCT(100),
h = lvgl.SIZE_CONTENT,
text_align = 2,
long_mode = 0,
margin_all = 4,
text = "SD Card is not inserted or could not be opened.",
}:center();
end end
-- Finally, the bottom bar with icon buttons for other device features. -- Finally, the bottom bar with icon buttons for other device features.

@ -75,6 +75,7 @@ void Running::react(const SdDetectChanged& ev) {
} }
if (ev.has_sd_card && !sStorage) { if (ev.has_sd_card && !sStorage) {
vTaskDelay(pdMS_TO_TICKS(500));
mountStorage(); mountStorage();
} }

@ -55,7 +55,8 @@ auto UiTask::Main() -> void {
current_screen_ = screen; current_screen_ = screen;
} }
if (input_ && current_screen_->group() != current_group) { if (input_ && current_screen_ &&
current_screen_->group() != current_group) {
current_group = current_screen_->group(); current_group = current_screen_->group();
input_->setGroup(current_group); input_->setGroup(current_group);
} }

Loading…
Cancel
Save