diff options
Diffstat (limited to 'src/ui/include')
| -rw-r--r-- | src/ui/include/lvgl_task.hpp | 3 | ||||
| -rw-r--r-- | src/ui/include/screen.hpp | 28 | ||||
| -rw-r--r-- | src/ui/include/screen_menu.hpp | 29 | ||||
| -rw-r--r-- | src/ui/include/screen_splash.hpp | 30 | ||||
| -rw-r--r-- | src/ui/include/ui_fsm.hpp | 10 | ||||
| -rw-r--r-- | src/ui/include/ui_tick.hpp | 11 | ||||
| -rw-r--r-- | src/ui/include/wheel_encoder.hpp | 30 |
7 files changed, 134 insertions, 7 deletions
diff --git a/src/ui/include/lvgl_task.hpp b/src/ui/include/lvgl_task.hpp index 25e7dd14..8e387683 100644 --- a/src/ui/include/lvgl_task.hpp +++ b/src/ui/include/lvgl_task.hpp @@ -14,11 +14,12 @@ #include "freertos/task.h" #include "display.hpp" +#include "relative_wheel.hpp" #include "touchwheel.hpp" namespace ui { -auto StartLvgl(std::weak_ptr<drivers::TouchWheel> touch_wheel, +auto StartLvgl(std::weak_ptr<drivers::RelativeWheel> touch_wheel, std::weak_ptr<drivers::Display> display) -> void; } // namespace ui diff --git a/src/ui/include/screen.hpp b/src/ui/include/screen.hpp new file mode 100644 index 00000000..87a0d9b8 --- /dev/null +++ b/src/ui/include/screen.hpp @@ -0,0 +1,28 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include <memory> + +#include "core/lv_obj.h" +#include "core/lv_obj_tree.h" +#include "lvgl.h" + +namespace ui { + +class Screen { + public: + Screen() : root_(lv_obj_create(NULL)) {} + virtual ~Screen() { lv_obj_del(root_); } + + auto root() -> lv_obj_t* { return root_; } + + protected: + lv_obj_t* const root_; +}; + +} // namespace ui diff --git a/src/ui/include/screen_menu.hpp b/src/ui/include/screen_menu.hpp new file mode 100644 index 00000000..a0b07b9e --- /dev/null +++ b/src/ui/include/screen_menu.hpp @@ -0,0 +1,29 @@ +/* + * 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 Menu : public Screen { + public: + Menu(); + ~Menu(); + + private: + lv_obj_t* container_; + lv_obj_t* label_; +}; + +} // namespace screens +} // namespace ui diff --git a/src/ui/include/screen_splash.hpp b/src/ui/include/screen_splash.hpp new file mode 100644 index 00000000..1ee7dd89 --- /dev/null +++ b/src/ui/include/screen_splash.hpp @@ -0,0 +1,30 @@ +/* + * 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(); + + private: + lv_obj_t* container_; + lv_obj_t* label_; + lv_obj_t* spinner_; +}; + +} // namespace screens +} // namespace ui diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp index 2afcfa86..d4d23bb0 100644 --- a/src/ui/include/ui_fsm.hpp +++ b/src/ui/include/ui_fsm.hpp @@ -8,9 +8,9 @@ #include <memory> +#include "relative_wheel.hpp" #include "tinyfsm.hpp" -#include "database.hpp" #include "display.hpp" #include "screen.hpp" #include "storage.hpp" @@ -22,9 +22,8 @@ namespace ui { class UiState : public tinyfsm::Fsm<UiState> { public: static auto Init(drivers::GpioExpander* gpio_expander, - std::weak_ptr<drivers::TouchWheel> touchwheel, - std::weak_ptr<drivers::Display> display, - std::weak_ptr<database::Database> database) -> void; + std::weak_ptr<drivers::RelativeWheel> touchwheel, + std::weak_ptr<drivers::Display> display) -> void; virtual ~UiState() {} @@ -43,9 +42,8 @@ class UiState : public tinyfsm::Fsm<UiState> { protected: static drivers::GpioExpander* sGpioExpander; - static std::weak_ptr<drivers::TouchWheel> sTouchWheel; + static std::weak_ptr<drivers::RelativeWheel> sTouchWheel; static std::weak_ptr<drivers::Display> sDisplay; - static std::weak_ptr<database::Database> sDatabase; static std::shared_ptr<Screen> sCurrentScreen; }; diff --git a/src/ui/include/ui_tick.hpp b/src/ui/include/ui_tick.hpp new file mode 100644 index 00000000..37f8a8bd --- /dev/null +++ b/src/ui/include/ui_tick.hpp @@ -0,0 +1,11 @@ +/* + * 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) diff --git a/src/ui/include/wheel_encoder.hpp b/src/ui/include/wheel_encoder.hpp new file mode 100644 index 00000000..0651ce0b --- /dev/null +++ b/src/ui/include/wheel_encoder.hpp @@ -0,0 +1,30 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include <memory> + +#include "hal/lv_hal_indev.h" + +#include "relative_wheel.hpp" + +namespace ui { + +class TouchWheelEncoder { + public: + explicit TouchWheelEncoder(std::weak_ptr<drivers::RelativeWheel> wheel); + + auto Read(lv_indev_data_t *data) -> void; + auto registration() -> lv_indev_t* { return registration_; } + + private: + lv_indev_drv_t driver_; + lv_indev_t *registration_; + std::weak_ptr<drivers::RelativeWheel> wheel_; +}; + +} // namespace ui |
