idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
touch.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Chris Leishman
3
4#pragma once
5
13#include <idfxx/gpio>
14
15#include <cstdint>
16#include <functional>
17
18struct esp_lcd_touch_s;
19typedef struct esp_lcd_touch_s esp_lcd_touch_t;
21
26namespace idfxx::lcd {
27
32class touch {
33public:
38 typedef std::move_only_function<
39 void(uint16_t* x, uint16_t* y, uint16_t* strength, uint8_t* point_num, uint8_t max_point_num)>
41
46 struct config {
47 uint16_t x_max;
48 uint16_t y_max;
49
52
53 struct {
54 unsigned int reset : 1 = 0;
55 unsigned int interrupt : 1 = 0;
56 } levels = {};
57
58 struct {
59 unsigned int swap_xy : 1 = 0;
60 unsigned int mirror_x : 1 = 0;
61 unsigned int mirror_y : 1 = 0;
62 } flags = {};
63
66 };
67
68 virtual ~touch() = default;
69
71 [[nodiscard]] virtual esp_lcd_touch_handle_t idf_handle() const = 0;
72};
73
74} // namespace idfxx::lcd
Type-safe set of flags from a scoped enum.
Definition flags.hpp:88
A GPIO pin.
Definition gpio.hpp:58
static constexpr gpio nc()
Returns a GPIO representing "not connected".
Definition gpio.hpp:248
Abstract base class for touch controllers.
Definition touch.hpp:32
virtual ~touch()=default
virtual esp_lcd_touch_handle_t idf_handle() const =0
Returns the underlying ESP-IDF handle.
std::move_only_function< void(uint16_t *x, uint16_t *y, uint16_t *strength, uint8_t *point_num, uint8_t max_point_num)> process_coordinates_callback
Callback type for processing touch coordinates.
Definition touch.hpp:40
LCD driver classes.
Definition color.hpp:19
Configuration structure for touch controllers.
Definition touch.hpp:46
unsigned int mirror_y
Mirror Y after read coordinates.
Definition touch.hpp:61
process_coordinates_callback process_coordinates
Definition touch.hpp:65
struct idfxx::lcd::touch::config::@2 levels
uint16_t y_max
Y coordinates max (for mirroring)
Definition touch.hpp:48
unsigned int interrupt
Active Level of interrupt pin.
Definition touch.hpp:55
unsigned int reset
Level of reset pin in reset.
Definition touch.hpp:54
uint16_t x_max
X coordinates max (for mirroring)
Definition touch.hpp:47
unsigned int swap_xy
Swap X and Y after read coordinates.
Definition touch.hpp:59
gpio rst_gpio
GPIO number of reset pin.
Definition touch.hpp:50
unsigned int mirror_x
Mirror X after read coordinates.
Definition touch.hpp:60
gpio int_gpio
GPIO number of interrupt pin.
Definition touch.hpp:51
struct esp_lcd_touch_s esp_lcd_touch_t
Definition touch.hpp:19
esp_lcd_touch_t * esp_lcd_touch_handle_t
Definition touch.hpp:20