From ed82063af5f83530afa5cfb5bf5bd516f3d05f2a Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 10 Apr 2024 16:56:10 +1000 Subject: WIP decompose our giant LVGL driver into smaller classes --- src/input/include/input_touch_wheel.hpp | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/input/include/input_touch_wheel.hpp (limited to 'src/input/include/input_touch_wheel.hpp') diff --git a/src/input/include/input_touch_wheel.hpp b/src/input/include/input_touch_wheel.hpp new file mode 100644 index 00000000..a4923f21 --- /dev/null +++ b/src/input/include/input_touch_wheel.hpp @@ -0,0 +1,37 @@ +/* + * Copyright 2024 jacqueline + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include + +#include "hal/lv_hal_indev.h" + +#include "haptics.hpp" +#include "input_device.hpp" +#include "touchwheel.hpp" + +namespace input { + +class TouchWheel : public IInputDevice { + public: + TouchWheel(drivers::TouchWheel&); + + auto read(lv_indev_data_t* data) -> void override; + + private: + auto calculate_ticks(const drivers::TouchWheelData& data) -> int8_t; + + drivers::TouchWheel& wheel_; + + bool is_scrolling_; + uint8_t sensitivity_; + uint8_t threshold_; + bool is_first_read_; + uint8_t last_angle_; +}; + +} // namespace input -- cgit v1.2.3 From 33919e9e3f419e13318fa6b8217d8c8dcd86c1eb Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 11 Apr 2024 15:16:35 +1000 Subject: Migrate all existing control schemes to the cool new world --- src/input/include/input_touch_wheel.hpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/input/include/input_touch_wheel.hpp') diff --git a/src/input/include/input_touch_wheel.hpp b/src/input/include/input_touch_wheel.hpp index a4923f21..c81cbb1a 100644 --- a/src/input/include/input_touch_wheel.hpp +++ b/src/input/include/input_touch_wheel.hpp @@ -6,29 +6,43 @@ #pragma once +#include #include #include "hal/lv_hal_indev.h" #include "haptics.hpp" #include "input_device.hpp" +#include "input_trigger.hpp" +#include "nvs.hpp" +#include "property.hpp" #include "touchwheel.hpp" namespace input { class TouchWheel : public IInputDevice { public: - TouchWheel(drivers::TouchWheel&); + TouchWheel(drivers::NvsStorage&, drivers::TouchWheel&); auto read(lv_indev_data_t* data) -> void override; + auto sensitivity() -> lua::Property&; + private: - auto calculate_ticks(const drivers::TouchWheelData& data) -> int8_t; + auto calculateTicks(const drivers::TouchWheelData& data) -> int8_t; + auto calculateThreshold(uint8_t sensitivity) -> uint8_t; + drivers::NvsStorage& nvs_; drivers::TouchWheel& wheel_; + lua::Property sensitivity_; + + Trigger up_; + Trigger right_; + Trigger down_; + Trigger left_; + bool is_scrolling_; - uint8_t sensitivity_; uint8_t threshold_; bool is_first_read_; uint8_t last_angle_; -- cgit v1.2.3