summaryrefslogtreecommitdiff
path: root/src/ui/include
diff options
context:
space:
mode:
authorcooljqln <cooljqln@noreply.codeberg.org>2024-05-03 04:48:17 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2024-05-03 04:48:17 +0000
commit3ceb8025ee4330c177101ed30ec17dfb0002f41e (patch)
tree58350210f15df7d00d967cac6f30eeceeb031a3c /src/ui/include
parent964da15a0b84f8e5f00e8abac2f7dfda0bf60488 (diff)
parent9fafd797a5504f458b5fcae4a1d28a68da936315 (diff)
downloadtangara-fw-3ceb8025ee4330c177101ed30ec17dfb0002f41e.tar.gz
Merge pull request 'Break dependency cycles with our components by merging co-dependent components together' (#68) from jqln/component-merge into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/68
Diffstat (limited to 'src/ui/include')
-rw-r--r--src/ui/include/fonts.hpp13
-rw-r--r--src/ui/include/lvgl_task.hpp41
-rw-r--r--src/ui/include/modal.hpp36
-rw-r--r--src/ui/include/screen.hpp58
-rw-r--r--src/ui/include/screen_lua.hpp40
-rw-r--r--src/ui/include/screen_splash.hpp32
-rw-r--r--src/ui/include/themes.hpp38
-rw-r--r--src/ui/include/ui_events.hpp54
-rw-r--r--src/ui/include/ui_fsm.hpp186
-rw-r--r--src/ui/include/ui_tick.hpp11
10 files changed, 0 insertions, 509 deletions
diff --git a/src/ui/include/fonts.hpp b/src/ui/include/fonts.hpp
deleted file mode 100644
index e4a8e139..00000000
--- a/src/ui/include/fonts.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include "font/lv_font.h"
-
-LV_FONT_DECLARE(font_fusion_12);
-LV_FONT_DECLARE(font_fusion_10);
-LV_FONT_DECLARE(font_fusion_8);
diff --git a/src/ui/include/lvgl_task.hpp b/src/ui/include/lvgl_task.hpp
deleted file mode 100644
index 8efcbf35..00000000
--- a/src/ui/include/lvgl_task.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <atomic>
-#include <cstdbool>
-#include <memory>
-
-#include "freertos/FreeRTOS.h"
-#include "freertos/task.h"
-#include "freertos/timers.h"
-
-#include "display.hpp"
-#include "lvgl_input_driver.hpp"
-#include "screen.hpp"
-#include "themes.hpp"
-#include "touchwheel.hpp"
-
-namespace ui {
-
-class UiTask {
- public:
- static auto Start() -> UiTask*;
- ~UiTask();
-
- auto input(std::shared_ptr<input::LvglInputDriver> input) -> void;
-
- private:
- UiTask();
-
- auto Main() -> void;
-
- std::shared_ptr<input::LvglInputDriver> input_;
- std::shared_ptr<Screen> current_screen_;
-};
-
-} // namespace ui
diff --git a/src/ui/include/modal.hpp b/src/ui/include/modal.hpp
deleted file mode 100644
index 6b7e792e..00000000
--- a/src/ui/include/modal.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <memory>
-
-#include "core/lv_group.h"
-#include "core/lv_obj.h"
-#include "core/lv_obj_tree.h"
-#include "lvgl.h"
-
-#include "screen.hpp"
-
-namespace ui {
-
-class Modal {
- public:
- Modal(Screen* host);
- virtual ~Modal();
-
- auto root() -> lv_obj_t* { return root_; }
- auto group() -> lv_group_t* { return group_; }
-
- protected:
- lv_obj_t* const root_;
- lv_group_t* const group_;
-
- private:
- Screen* host_;
-};
-
-} // namespace ui
diff --git a/src/ui/include/screen.hpp b/src/ui/include/screen.hpp
deleted file mode 100644
index 40284fda..00000000
--- a/src/ui/include/screen.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <memory>
-#include <optional>
-#include <vector>
-
-#include "core/lv_group.h"
-#include "core/lv_obj.h"
-#include "core/lv_obj_tree.h"
-#include "lvgl.h"
-
-namespace ui {
-
-/*
- * Base class for ever discrete screen in the app. Provides a consistent
- * interface that can be used for transitioning between screens, adding them to
- * back stacks, etc.
- */
-class Screen {
- public:
- Screen();
- virtual ~Screen();
-
- virtual auto onShown() -> void {}
- virtual auto onHidden() -> void {}
-
- auto root() -> lv_obj_t* { return root_; }
- auto content() -> lv_obj_t* { return content_; }
- auto alert() -> lv_obj_t* { return alert_; }
-
- auto modal_content() -> lv_obj_t* { return modal_content_; }
- auto modal_group(lv_group_t* g) -> void { modal_group_ = g; }
- auto group() -> lv_group_t* {
- if (modal_group_) {
- return modal_group_;
- }
- return group_;
- }
-
- virtual auto canPop() -> bool = 0;
-
- protected:
- lv_obj_t* const root_;
- lv_obj_t* content_;
- lv_obj_t* modal_content_;
- lv_obj_t* alert_;
-
- lv_group_t* const group_;
- lv_group_t* modal_group_;
-};
-
-} // namespace ui
diff --git a/src/ui/include/screen_lua.hpp b/src/ui/include/screen_lua.hpp
deleted file mode 100644
index 8a463bad..00000000
--- a/src/ui/include/screen_lua.hpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include "lua.hpp"
-
-#include "property.hpp"
-#include "screen.hpp"
-
-namespace ui {
-namespace screens {
-
-class Lua : public Screen {
- public:
- Lua();
- ~Lua();
-
- auto onShown() -> void override;
- auto onHidden() -> void override;
-
- auto canPop() -> bool override;
-
- auto SetObjRef(lua_State*) -> void;
-
- private:
- /* Invokes a method on this screen's Lua counterpart. */
- auto callMethod(std::string name) -> void;
- /* Applies fn to each binding in this screen's `bindings` field. */
- auto forEachBinding(std::function<void(lua::Binding*)> fn) -> void;
-
- lua_State* s_;
- std::optional<int> obj_ref_;
-};
-
-} // namespace screens
-} // namespace ui
diff --git a/src/ui/include/screen_splash.hpp b/src/ui/include/screen_splash.hpp
deleted file mode 100644
index 6e746345..00000000
--- a/src/ui/include/screen_splash.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <memory>
-
-#include "lvgl.h"
-
-#include "screen.hpp"
-
-namespace ui {
-namespace screens {
-
-class Splash : public Screen {
- public:
- Splash();
- ~Splash();
-
- auto canPop() -> bool override { return false; }
-
- private:
- lv_obj_t* container_;
- lv_obj_t* label_;
- lv_obj_t* spinner_;
-};
-
-} // namespace screens
-} // namespace ui
diff --git a/src/ui/include/themes.hpp b/src/ui/include/themes.hpp
deleted file mode 100644
index 09b9cdce..00000000
--- a/src/ui/include/themes.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-
-#include <string>
-#include <map>
-#include <vector>
-#include "lvgl.h"
-
-namespace ui {
-namespace themes {
-
-enum class Style {
- kMenuItem,
- kMenuSubheadFirst,
- kMenuSubhead,
- kTopBar,
- kPopup,
- kTab,
- kButtonPrimary,
-};
-
-class Theme {
- public:
- void Apply(void);
- void Callback(lv_obj_t* obj);
- void ApplyStyle(lv_obj_t* obj, std::string style_key);
-
- void AddStyle(std::string key, int selector, lv_style_t* style);
-
- static auto instance() -> Theme*;
-
- private:
- Theme();
- std::map<std::string, std::vector<std::pair<int, lv_style_t*>>> style_map;
- lv_theme_t theme_;
-
-};
-} // namespace themes
-} // namespace ui
diff --git a/src/ui/include/ui_events.hpp b/src/ui/include/ui_events.hpp
deleted file mode 100644
index 3d794edc..00000000
--- a/src/ui/include/ui_events.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include <memory>
-#include "database.hpp"
-#include "gpios.hpp"
-#include "index.hpp"
-#include "nvs.hpp"
-#include "screen.hpp"
-#include "tinyfsm.hpp"
-
-namespace ui {
-
-// TODO(jacqueline): is this needed? is this good?
-/*
- * Event emitted by the main task on heartbeat.
- */
-struct OnStorageChange : tinyfsm::Event {
- bool is_mounted;
-};
-
-struct OnSystemError : tinyfsm::Event {};
-
-struct OnLuaError : tinyfsm::Event {
- std::string message;
-};
-
-struct DumpLuaStack : tinyfsm::Event {};
-
-namespace internal {
-
-struct InitDisplay : tinyfsm::Event {
- drivers::IGpios& gpios;
- drivers::NvsStorage& nvs;
-};
-
-struct ReindexDatabase : tinyfsm::Event {};
-
-struct BackPressed : tinyfsm::Event {};
-struct ShowNowPlaying : tinyfsm::Event {};
-
-struct ModalConfirmPressed : tinyfsm::Event {};
-struct ModalCancelPressed : tinyfsm::Event {};
-
-struct DismissAlerts : tinyfsm::Event {};
-
-} // namespace internal
-
-} // namespace ui
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
diff --git a/src/ui/include/ui_tick.hpp b/src/ui/include/ui_tick.hpp
deleted file mode 100644
index 37f8a8bd..00000000
--- a/src/ui/include/ui_tick.hpp
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Copyright 2023 jacqueline <me@jacqueline.id.au>
- *
- * SPDX-License-Identifier: GPL-3.0-only
- */
-
-#pragma once
-
-#include "esp_timer.h"
-
-#define LV_TICK_CUSTOM_SYS_TIME_EXPR (esp_timer_get_time() / 1000)