summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drivers/include/samd.hpp4
-rw-r--r--src/drivers/samd.cpp2
-rw-r--r--src/system_fsm/include/system_events.hpp4
-rw-r--r--src/system_fsm/system_fsm.cpp2
-rw-r--r--src/ui/include/ui_fsm.hpp2
-rw-r--r--src/ui/ui_fsm.cpp9
6 files changed, 19 insertions, 4 deletions
diff --git a/src/drivers/include/samd.hpp b/src/drivers/include/samd.hpp
index ac265950..55ea513c 100644
--- a/src/drivers/include/samd.hpp
+++ b/src/drivers/include/samd.hpp
@@ -48,8 +48,8 @@ class Samd {
// There is a compatible usb host attached, but USB MSC is not currently
// in use by the SAMD.
kAttachedIdle,
- // The SAMD is currently exposing the SD card via USB MSC.
- kAttachedMounted,
+ // The SAMD is currently writing to the SD card via USB MSC.
+ kAttachedBusy,
};
auto GetUsbStatus() -> UsbStatus;
diff --git a/src/drivers/samd.cpp b/src/drivers/samd.cpp
index b631b4fb..e47d9cfe 100644
--- a/src/drivers/samd.cpp
+++ b/src/drivers/samd.cpp
@@ -113,7 +113,7 @@ auto Samd::UpdateUsbStatus() -> void {
usb_status_ = UsbStatus::kDetached;
}
usb_status_ =
- (raw_res & 0b10) ? UsbStatus::kAttachedMounted : UsbStatus::kAttachedIdle;
+ (raw_res & 0b10) ? UsbStatus::kAttachedBusy : UsbStatus::kAttachedIdle;
}
auto Samd::ResetToFlashSamd() -> void {
diff --git a/src/system_fsm/include/system_events.hpp b/src/system_fsm/include/system_events.hpp
index 1be03f82..f9ab9e11 100644
--- a/src/system_fsm/include/system_events.hpp
+++ b/src/system_fsm/include/system_events.hpp
@@ -12,6 +12,7 @@
#include "bluetooth_types.hpp"
#include "database.hpp"
#include "haptics.hpp"
+#include "samd.hpp"
#include "service_locator.hpp"
#include "tinyfsm.hpp"
@@ -56,6 +57,9 @@ struct SdDetectChanged : tinyfsm::Event {
struct SamdUsbMscChanged : tinyfsm::Event {
bool en;
};
+struct SamdUsbStatusChanged : tinyfsm::Event {
+ drivers::Samd::UsbStatus new_status;
+};
struct BatteryStateChanged : tinyfsm::Event {
battery::Battery::BatteryState new_state;
diff --git a/src/system_fsm/system_fsm.cpp b/src/system_fsm/system_fsm.cpp
index 5a1ccf8c..f502b49a 100644
--- a/src/system_fsm/system_fsm.cpp
+++ b/src/system_fsm/system_fsm.cpp
@@ -88,7 +88,7 @@ void SystemState::react(const internal::SamdInterrupt&) {
sServices->battery().Update();
}
if (usb_status != prev_usb_status) {
- ESP_LOGI(kTag, "usb status changed");
+ events::Ui().Dispatch(SamdUsbStatusChanged{.new_status = usb_status});
}
}
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());