summaryrefslogtreecommitdiff
path: root/src/ui/lvgl_task.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-06-01 15:28:32 +1000
committerjacqueline <me@jacqueline.id.au>2023-06-01 15:28:54 +1000
commit6fd588e970470b15936187980829916d0dbe77bb (patch)
tree1b1e73ef52bef2e41499ee5ceadc45efd408050b /src/ui/lvgl_task.cpp
parentdb2e29a72d9b934e7b58f1d20ac3768eae484ab5 (diff)
downloadtangara-fw-6fd588e970470b15936187980829916d0dbe77bb.tar.gz
Add touchwheel -> encoder adapter
Diffstat (limited to 'src/ui/lvgl_task.cpp')
-rw-r--r--src/ui/lvgl_task.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/ui/lvgl_task.cpp b/src/ui/lvgl_task.cpp
index f2f7c67c..1ce7fd40 100644
--- a/src/ui/lvgl_task.cpp
+++ b/src/ui/lvgl_task.cpp
@@ -15,6 +15,8 @@
#include <memory>
#include "core/lv_disp.h"
+#include "core/lv_group.h"
+#include "core/lv_indev.h"
#include "core/lv_obj.h"
#include "core/lv_obj_pos.h"
#include "core/lv_obj_tree.h"
@@ -25,15 +27,18 @@
#include "freertos/projdefs.h"
#include "freertos/timers.h"
#include "hal/gpio_types.h"
+#include "hal/lv_hal_indev.h"
#include "hal/spi_types.h"
#include "lv_api_map.h"
#include "lvgl/lvgl.h"
#include "misc/lv_color.h"
#include "misc/lv_style.h"
#include "misc/lv_timer.h"
+#include "relative_wheel.hpp"
#include "tasks.hpp"
#include "touchwheel.hpp"
#include "ui_fsm.hpp"
+#include "wheel_encoder.hpp"
#include "widgets/lv_label.h"
#include "display.hpp"
@@ -43,11 +48,16 @@ namespace ui {
static const char* kTag = "lv_task";
-void LvglMain(std::weak_ptr<drivers::TouchWheel> weak_touch_wheel,
+void LvglMain(std::weak_ptr<drivers::RelativeWheel> weak_touch_wheel,
std::weak_ptr<drivers::Display> weak_display) {
ESP_LOGI(kTag, "init lvgl");
lv_init();
+ TouchWheelEncoder encoder(weak_touch_wheel);
+ lv_group_t *nav_group = lv_group_create();
+ lv_group_set_default(nav_group);
+ lv_indev_set_group(encoder.registration(), nav_group);
+
std::shared_ptr<Screen> current_screen;
auto& events = events::EventQueue::GetInstance();
while (1) {
@@ -65,10 +75,12 @@ void LvglMain(std::weak_ptr<drivers::TouchWheel> weak_touch_wheel,
// 30 FPS
// TODO(jacqueline): make this dynamic
vTaskDelay(pdMS_TO_TICKS(33));
+ lv_indev_data_t d;
+ encoder.Read(&d);
}
}
-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 {
tasks::StartPersistent<tasks::Type::kUi>(
[=]() { LvglMain(touch_wheel, display); });