From 2f16d230025c3173cfbecc58b38d6a52b6b0f5f2 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 5 Jul 2023 20:09:03 +1000 Subject: Start on wiring up playback screen to real data --- src/ui/include/ui_fsm.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/ui/include/ui_fsm.hpp') diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp index 32275fab..cd1ec492 100644 --- a/src/ui/include/ui_fsm.hpp +++ b/src/ui/include/ui_fsm.hpp @@ -9,7 +9,9 @@ #include #include +#include "audio_events.hpp" #include "relative_wheel.hpp" +#include "screen_playing.hpp" #include "tinyfsm.hpp" #include "display.hpp" @@ -37,6 +39,8 @@ class UiState : public tinyfsm::Fsm { /* Fallback event handler. Does nothing. */ void react(const tinyfsm::Event& ev) {} + virtual void react(const audio::PlaybackUpdate){}; + virtual void react(const system_fsm::KeyLockChanged&){}; virtual void react(const internal::RecordSelected&){}; @@ -57,6 +61,7 @@ class UiState : public tinyfsm::Fsm { static std::stack> sScreens; static std::shared_ptr sCurrentScreen; + static std::unique_ptr sPlayingScreen; }; namespace states { @@ -68,7 +73,7 @@ class Splash : public UiState { using UiState::react; }; -class Interactive : public UiState { +class Browse : public UiState { void entry() override; void react(const internal::RecordSelected&) override; @@ -78,6 +83,12 @@ class Interactive : public UiState { void react(const system_fsm::StorageMounted&) override; }; +class Playing : public UiState { + void entry() override; + + void react(const audio::PlaybackUpdate) override; +}; + class FatalError : public UiState {}; } // namespace states -- cgit v1.2.3 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/ui/include/ui_fsm.hpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/ui/include/ui_fsm.hpp') diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp index cd1ec492..2fc6db4e 100644 --- a/src/ui/include/ui_fsm.hpp +++ b/src/ui/include/ui_fsm.hpp @@ -19,13 +19,14 @@ #include "storage.hpp" #include "system_events.hpp" #include "touchwheel.hpp" +#include "track_queue.hpp" #include "ui_events.hpp" namespace ui { class UiState : public tinyfsm::Fsm { public: - static auto Init(drivers::IGpios* gpio_expander) -> bool; + static auto Init(drivers::IGpios*, audio::TrackQueue*) -> bool; virtual ~UiState() {} @@ -39,12 +40,14 @@ class UiState : public tinyfsm::Fsm { /* Fallback event handler. Does nothing. */ void react(const tinyfsm::Event& ev) {} - virtual void react(const audio::PlaybackUpdate){}; + virtual void react(const audio::PlaybackStarted&) {} + virtual void react(const audio::PlaybackUpdate&) {} + virtual void react(const audio::QueueUpdate&) {} - virtual void react(const system_fsm::KeyLockChanged&){}; + virtual void react(const system_fsm::KeyLockChanged&) {} - virtual void react(const internal::RecordSelected&){}; - virtual void react(const internal::IndexSelected&){}; + virtual void react(const internal::RecordSelected&) {} + virtual void react(const internal::IndexSelected&) {} virtual void react(const system_fsm::DisplayReady&) {} virtual void react(const system_fsm::BootComplete&) {} @@ -52,8 +55,11 @@ class UiState : public tinyfsm::Fsm { protected: void PushScreen(std::shared_ptr); + void PopScreen(); static drivers::IGpios* sIGpios; + static audio::TrackQueue* sQueue; + static std::shared_ptr sTouchWheel; static std::shared_ptr sRelativeWheel; static std::shared_ptr sDisplay; @@ -61,7 +67,6 @@ class UiState : public tinyfsm::Fsm { static std::stack> sScreens; static std::shared_ptr sCurrentScreen; - static std::unique_ptr sPlayingScreen; }; namespace states { @@ -81,12 +86,17 @@ class Browse : public UiState { void react(const system_fsm::KeyLockChanged&) override; void react(const system_fsm::StorageMounted&) override; + using UiState::react; }; class Playing : public UiState { void entry() override; + void exit() override; - void react(const audio::PlaybackUpdate) override; + void react(const audio::PlaybackStarted&) override; + void react(const audio::PlaybackUpdate&) override; + void react(const audio::QueueUpdate&) override; + using UiState::react; }; class FatalError : public UiState {}; -- cgit v1.2.3