summaryrefslogtreecommitdiff
path: root/src/tangara/audio/audio_fsm.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-05-03 16:40:39 +1000
committerjacqueline <me@jacqueline.id.au>2024-05-03 16:40:39 +1000
commit344a46d0664eb75d232eacea91a4957a25e071f6 (patch)
treee6ee54d9c8060af3d3bb94ec4b79e9d505b270e5 /src/tangara/audio/audio_fsm.cpp
parent3ceb8025ee4330c177101ed30ec17dfb0002f41e (diff)
downloadtangara-fw-344a46d0664eb75d232eacea91a4957a25e071f6.tar.gz
Respond to sd card mounts and unmounts within lua
Includes no longer blocking the main menu on an sd card being inserted!!
Diffstat (limited to 'src/tangara/audio/audio_fsm.cpp')
-rw-r--r--src/tangara/audio/audio_fsm.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/tangara/audio/audio_fsm.cpp b/src/tangara/audio/audio_fsm.cpp
index f504da2e..7e74b706 100644
--- a/src/tangara/audio/audio_fsm.cpp
+++ b/src/tangara/audio/audio_fsm.cpp
@@ -15,6 +15,7 @@
#include "cppbor.h"
#include "cppbor_parse.h"
#include "drivers/bluetooth_types.hpp"
+#include "drivers/storage.hpp"
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
@@ -500,7 +501,11 @@ void Standby::react(const system_fsm::KeyLockChanged& ev) {
});
}
-void Standby::react(const system_fsm::StorageMounted& ev) {
+void Standby::react(const system_fsm::SdStateChanged& ev) {
+ auto state = sServices->sd();
+ if (state != drivers::SdState::kMounted) {
+ return;
+ }
sServices->bg_worker().Dispatch<void>([]() {
auto db = sServices->database().lock();
if (!db) {
@@ -568,6 +573,12 @@ void Playback::exit() {
events::Ui().Dispatch(event);
}
+void Playback::react(const system_fsm::SdStateChanged& ev) {
+ if (sServices->sd() != drivers::SdState::kMounted) {
+ transit<Standby>();
+ }
+}
+
} // namespace states
} // namespace audio