summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-04-08 13:50:35 +1000
committerjacqueline <me@jacqueline.id.au>2024-04-08 13:50:35 +1000
commit5f1a6507d8f7a0f9ecea179f94aeb182eac77cfe (patch)
tree42220c19c5511902ef032ec0453a5d3b5cc2d39c /src/ui
parent251c0ba96dadf8d28406095ec2189466b631f7f8 (diff)
downloadtangara-fw-5f1a6507d8f7a0f9ecea179f94aeb182eac77cfe.tar.gz
Warn and block MSC disable if the sd card is busy
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/include/ui_fsm.hpp2
-rw-r--r--src/ui/ui_fsm.cpp9
2 files changed, 11 insertions, 0 deletions
diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp
index 9f9aa9b9..2bab487d 100644
--- a/src/ui/include/ui_fsm.hpp
+++ b/src/ui/include/ui_fsm.hpp
@@ -65,6 +65,7 @@ class UiState : public tinyfsm::Fsm<UiState> {
void react(const audio::VolumeLimitChanged&);
void react(const system_fsm::KeyLockChanged&);
+ void react(const system_fsm::SamdUsbStatusChanged&);
void react(const internal::DismissAlerts&);
void react(const internal::ControlSchemeChanged&);
@@ -133,6 +134,7 @@ class UiState : public tinyfsm::Fsm<UiState> {
static lua::Property sDatabaseAutoUpdate;
static lua::Property sUsbMassStorageEnabled;
+ static lua::Property sUsbMassStorageBusy;
};
namespace states {
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp
index bb1503b2..28733123 100644
--- a/src/ui/ui_fsm.cpp
+++ b/src/ui/ui_fsm.cpp
@@ -43,6 +43,7 @@
#include "nvs.hpp"
#include "property.hpp"
#include "relative_wheel.hpp"
+#include "samd.hpp"
#include "screen.hpp"
#include "screen_lua.hpp"
#include "screen_splash.hpp"
@@ -302,6 +303,8 @@ lua::Property UiState::sUsbMassStorageEnabled{
return true;
}};
+lua::Property UiState::sUsbMassStorageBusy{false};
+
auto UiState::InitBootSplash(drivers::IGpios& gpios, drivers::NvsStorage& nvs)
-> bool {
// Init LVGL first, since the display driver registers itself with LVGL.
@@ -360,6 +363,11 @@ void UiState::react(const system_fsm::KeyLockChanged& ev) {
sLockSwitch.Update(ev.locking);
}
+void UiState::react(const system_fsm::SamdUsbStatusChanged& ev) {
+ sUsbMassStorageBusy.Update(ev.new_status ==
+ drivers::Samd::UsbStatus::kAttachedBusy);
+}
+
void UiState::react(const internal::ControlSchemeChanged&) {
if (!sInput) {
return;
@@ -573,6 +581,7 @@ void Lua::entry() {
registry.AddPropertyModule("usb",
{
{"msc_enabled", &sUsbMassStorageEnabled},
+ {"msc_busy", &sUsbMassStorageBusy},
});
sDatabaseAutoUpdate.Update(sServices->nvs().DbAutoIndex());