From 344a46d0664eb75d232eacea91a4957a25e071f6 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 3 May 2024 16:40:39 +1000 Subject: Respond to sd card mounts and unmounts within lua Includes no longer blocking the main menu on an sd card being inserted!! --- src/tangara/audio/audio_fsm.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/tangara/audio/audio_fsm.cpp') 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([]() { 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(); + } +} + } // namespace states } // namespace audio -- cgit v1.2.3