From 39f7545cd5ef7a30bbd482f3579df7744c6b688d Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 7 Jul 2023 15:29:47 +1000 Subject: wire up the playing screen with some real data Includes implementing song duration calculation for CBR MP3 files --- src/system_fsm/booting.cpp | 7 +++++-- src/system_fsm/include/system_fsm.hpp | 3 +++ src/system_fsm/system_fsm.cpp | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/system_fsm') diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp index dcfefbab..48b027d2 100644 --- a/src/system_fsm/booting.cpp +++ b/src/system_fsm/booting.cpp @@ -17,6 +17,7 @@ #include "spi.hpp" #include "system_events.hpp" #include "system_fsm.hpp" +#include "track_queue.hpp" #include "ui_fsm.hpp" #include "i2c.hpp" @@ -48,8 +49,9 @@ auto Booting::entry() -> void { sGpios->set_listener(&sGpiosCallback); // Start bringing up LVGL now, since we have all of its prerequisites. + sTrackQueue.reset(new audio::TrackQueue()); ESP_LOGI(kTag, "starting ui"); - if (!ui::UiState::Init(sGpios.get())) { + if (!ui::UiState::Init(sGpios.get(), sTrackQueue.get())) { events::Dispatch( FatalError()); return; @@ -70,7 +72,7 @@ auto Booting::entry() -> void { // state machines and inform them that the system is ready. ESP_LOGI(kTag, "starting audio"); - if (!audio::AudioState::Init(sGpios.get(), sDatabase)) { + if (!audio::AudioState::Init(sGpios.get(), sDatabase, sTrackQueue.get())) { events::Dispatch( FatalError()); return; @@ -83,6 +85,7 @@ auto Booting::entry() -> void { auto Booting::exit() -> void { // TODO(jacqueline): Gate this on something. Debug flag? Flashing mode? sAppConsole = new console::AppConsole(); + sAppConsole->sTrackQueue = sTrackQueue.get(); sAppConsole->Launch(); } diff --git a/src/system_fsm/include/system_fsm.hpp b/src/system_fsm/include/system_fsm.hpp index f6a52019..3c3169d1 100644 --- a/src/system_fsm/include/system_fsm.hpp +++ b/src/system_fsm/include/system_fsm.hpp @@ -20,6 +20,7 @@ #include "touchwheel.hpp" #include "system_events.hpp" +#include "track_queue.hpp" namespace system_fsm { @@ -58,6 +59,8 @@ class SystemState : public tinyfsm::Fsm { static std::shared_ptr sDisplay; static std::shared_ptr sDatabase; + static std::shared_ptr sTrackQueue; + static console::AppConsole* sAppConsole; }; diff --git a/src/system_fsm/system_fsm.cpp b/src/system_fsm/system_fsm.cpp index 1b3aab51..769d5e4a 100644 --- a/src/system_fsm/system_fsm.cpp +++ b/src/system_fsm/system_fsm.cpp @@ -9,6 +9,7 @@ #include "event_queue.hpp" #include "relative_wheel.hpp" #include "system_events.hpp" +#include "track_queue.hpp" namespace system_fsm { @@ -22,6 +23,8 @@ std::shared_ptr SystemState::sStorage; std::shared_ptr SystemState::sDisplay; std::shared_ptr SystemState::sDatabase; +std::shared_ptr SystemState::sTrackQueue; + console::AppConsole* SystemState::sAppConsole; void SystemState::react(const FatalError& err) { -- cgit v1.2.3