summaryrefslogtreecommitdiff
path: root/src/ui/include/ui_fsm.hpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-05-02 19:12:26 +1000
committerjacqueline <me@jacqueline.id.au>2024-05-02 19:12:26 +1000
commit1573a8c4cde1cd9528b422b2dcc598e37ffe94a7 (patch)
treed162822b8fd7054f81bace0c7a65ab4d5e6f93ef /src/ui/include/ui_fsm.hpp
parenta231fd1c8afedbeb14b0bc77d76bad61db986059 (diff)
downloadtangara-fw-1573a8c4cde1cd9528b422b2dcc598e37ffe94a7.tar.gz
WIP merge cyclically dependent components into one big component
Diffstat (limited to 'src/ui/include/ui_fsm.hpp')
-rw-r--r--src/ui/include/ui_fsm.hpp186
1 files changed, 0 insertions, 186 deletions
diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp
deleted file mode 100644
index 325aea8f..00000000
--- a/src/ui/include/ui_fsm.hpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <cstdint>
-#include <memory>
-#include <stack>
-
-#include "audio_events.hpp"
-#include "battery.hpp"
-#include "db_events.hpp"
-#include "device_factory.hpp"
-#include "display.hpp"
-#include "feedback_haptics.hpp"
-#include "gpios.hpp"
-#include "input_touch_wheel.hpp"
-#include "input_volume_buttons.hpp"
-#include "lua_thread.hpp"
-#include "lvgl_input_driver.hpp"
-#include "lvgl_task.hpp"
-#include "modal.hpp"
-#include "nvs.hpp"
-#include "property.hpp"
-#include "screen.hpp"
-#include "service_locator.hpp"
-#include "storage.hpp"
-#include "system_events.hpp"
-#include "tinyfsm.hpp"
-#include "touchwheel.hpp"
-#include "track.hpp"
-#include "track_queue.hpp"
-#include "ui_events.hpp"
-
-namespace ui {
-
-class UiState : public tinyfsm::Fsm<UiState> {
- public:
- static auto InitBootSplash(drivers::IGpios&, drivers::NvsStorage&) -> bool;
-
- virtual ~UiState() {}
-
- static auto current_screen() -> std::shared_ptr<Screen> {
- return sCurrentScreen;
- }
-
- virtual void entry() {}
- virtual void exit() {}
-
- /* Fallback event handler. Does nothing. */
- void react(const tinyfsm::Event& ev) {}
-
- virtual void react(const OnLuaError&) {}
- virtual void react(const DumpLuaStack&) {}
- virtual void react(const internal::BackPressed&) {}
- virtual void react(const system_fsm::BootComplete&) {}
- virtual void react(const system_fsm::StorageMounted&) {}
-
- void react(const system_fsm::BatteryStateChanged&);
- void react(const audio::PlaybackUpdate&);
- void react(const audio::QueueUpdate&);
-
- void react(const audio::VolumeChanged&);
- void react(const audio::VolumeBalanceChanged&);
- void react(const audio::VolumeLimitChanged&);
-
- void react(const system_fsm::KeyLockChanged&);
- void react(const system_fsm::SamdUsbStatusChanged&);
-
- void react(const internal::InitDisplay&);
- void react(const internal::DismissAlerts&);
-
- void react(const database::event::UpdateStarted&);
- void react(const database::event::UpdateProgress&){};
- void react(const database::event::UpdateFinished&);
-
- void react(const system_fsm::BluetoothEvent&);
-
- virtual void react(const internal::ModalCancelPressed&) {
- sCurrentModal.reset();
- }
- virtual void react(const internal::ModalConfirmPressed&) {
- sCurrentModal.reset();
- }
-
- void react(const internal::ReindexDatabase&){};
-
- protected:
- void PushScreen(std::shared_ptr<Screen>);
- int PopScreen();
-
- static std::unique_ptr<UiTask> sTask;
- static std::shared_ptr<system_fsm::ServiceLocator> sServices;
- static std::unique_ptr<drivers::Display> sDisplay;
-
- static std::shared_ptr<input::LvglInputDriver> sInput;
- static std::unique_ptr<input::DeviceFactory> sDeviceFactory;
-
- static std::stack<std::shared_ptr<Screen>> sScreens;
- static std::shared_ptr<Screen> sCurrentScreen;
- static std::shared_ptr<Modal> sCurrentModal;
- static std::shared_ptr<lua::LuaThread> sLua;
-
- static lua::Property sBatteryPct;
- static lua::Property sBatteryMv;
- static lua::Property sBatteryCharging;
-
- static lua::Property sBluetoothEnabled;
- static lua::Property sBluetoothConnected;
- static lua::Property sBluetoothPairedDevice;
- static lua::Property sBluetoothDevices;
-
- static lua::Property sPlaybackPlaying;
-
- static lua::Property sPlaybackTrack;
- static lua::Property sPlaybackPosition;
-
- static lua::Property sQueuePosition;
- static lua::Property sQueueSize;
- static lua::Property sQueueReplay;
- static lua::Property sQueueRepeat;
- static lua::Property sQueueRandom;
-
- static lua::Property sVolumeCurrentPct;
- static lua::Property sVolumeCurrentDb;
- static lua::Property sVolumeLeftBias;
- static lua::Property sVolumeLimit;
-
- static lua::Property sDisplayBrightness;
-
- static lua::Property sLockSwitch;
-
- static lua::Property sDatabaseUpdating;
- static lua::Property sDatabaseAutoUpdate;
-
- static lua::Property sUsbMassStorageEnabled;
- static lua::Property sUsbMassStorageBusy;
-};
-
-namespace states {
-
-class Splash : public UiState {
- public:
- void exit() override;
-
- void react(const system_fsm::BootComplete&) override;
- void react(const system_fsm::StorageMounted&) override;
-
- using UiState::react;
-};
-
-class Lua : public UiState {
- public:
- void entry() override;
- void exit() override;
-
- void react(const OnLuaError&) override;
- void react(const DumpLuaStack&) override;
- void react(const internal::BackPressed&) override;
-
- using UiState::react;
-
- private:
- auto PushLuaScreen(lua_State*) -> int;
- auto PopLuaScreen(lua_State*) -> int;
-
- auto ShowAlert(lua_State*) -> int;
- auto HideAlert(lua_State*) -> int;
-
- auto Ticks(lua_State*) -> int;
-
- auto SetPlaying(const lua::LuaValue&) -> bool;
- auto SetRandom(const lua::LuaValue&) -> bool;
- auto SetRepeat(const lua::LuaValue&) -> bool;
- auto SetReplay(const lua::LuaValue&) -> bool;
-
- auto QueueNext(lua_State*) -> int;
- auto QueuePrevious(lua_State*) -> int;
-};
-
-} // namespace states
-
-} // namespace ui