diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-10-03 10:37:29 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-10-03 10:37:29 +1100 |
| commit | 7d5536e2abca61f503ed68521603bd30700a7e5e (patch) | |
| tree | fc8b191a5d248a86de08a00d814359f335423e95 /src/ui/include/encoder_input.hpp | |
| parent | f2bad894cdac88b94a358cebdb062f426b191d1b (diff) | |
| download | tangara-fw-7d5536e2abca61f503ed68521603bd30700a7e5e.tar.gz | |
Generalise the lvgl input driver in preparation for more input methods
Diffstat (limited to 'src/ui/include/encoder_input.hpp')
| -rw-r--r-- | src/ui/include/encoder_input.hpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/ui/include/encoder_input.hpp b/src/ui/include/encoder_input.hpp new file mode 100644 index 00000000..9c114e80 --- /dev/null +++ b/src/ui/include/encoder_input.hpp @@ -0,0 +1,47 @@ +/* + * Copyright 2023 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#pragma once + +#include <memory> + +#include "core/lv_group.h" +#include "gpios.hpp" +#include "hal/lv_hal_indev.h" + +#include "relative_wheel.hpp" +#include "touchwheel.hpp" + +namespace ui { + +/* + * Main input device abstracting that handles turning lower-level input device + * drivers into events and LVGL inputs. + * + * As far as LVGL is concerned, this class represents an ordinary rotary + * encoder, supporting only left and right ticks, and clicking. + */ +class EncoderInput { + public: + EncoderInput(drivers::IGpios& gpios, drivers::TouchWheel& wheel); + + auto Read(lv_indev_data_t* data) -> void; + auto registration() -> lv_indev_t* { return registration_; } + + auto lock(bool l) -> void { is_locked_ = l; } + + private: + lv_indev_drv_t driver_; + lv_indev_t* registration_; + + drivers::IGpios& gpios_; + drivers::TouchWheel& raw_wheel_; + std::unique_ptr<drivers::RelativeWheel> relative_wheel_; + + bool is_locked_; +}; + +} // namespace ui |
