Touch Interface

[中文]

Public header: #include "brookesia/hal_interface/display/touch.hpp"

Class: DisplayTouchIface

API Reference

Header File

Classes

class DisplayTouchIface : public esp_brookesia::hal::Interface

Touch-input interface paired with a display.

Public Types

enum class OperationMode : uint8_t

Supported event acquisition mode.

Values:

enumerator Polling

Read touch points by polling.

enumerator Interrupt

Read touch points by interrupt.

enumerator Max

Public Functions

inline DisplayTouchIface(Info info)

Construct a touch-input interface.

Parameters

info[in] Static touch capability information.

virtual ~DisplayTouchIface() = default

Virtual destructor for polymorphic touch interfaces.

virtual bool read_points(std::vector<Point> &points) = 0

Read current touch points.

Parameters

points[out] Output touch points.

Returns

true on success; otherwise false.

virtual bool register_interrupt_handler(InterruptHandler handler) = 0

Register an interrupt handler.

Parameters

handler[in] Interrupt handler. If nullptr, the interrupt handler will be unregistered.

Returns

true on success; otherwise false.

inline virtual bool get_driver_specific(DriverSpecific &specific)

Get the driver-specific data.

Parameters

specific[out] The driver-specific data.

Returns

true on success; otherwise false.

inline const Info &get_info() const

Get static touch capability information.

Returns

Touch information.

Public Static Attributes

static constexpr const char *NAME = "DisplayTouch"

Interface registry name.

struct DriverSpecific

Driver-specific data.

Public Members

void *io_handle = nullptr

Handle of the IO.

void *touch_handle = nullptr

Handle of the touch.

struct Info

Static touch capability information.

Public Members

uint16_t x_max = 0

Maximum X coordinate value.

uint16_t y_max = 0

Maximum Y coordinate value.

OperationMode operation_mode = OperationMode::Max

Supported acquisition mode.

struct Point

A single touch point sample.

Public Members

int16_t x

X coordinate.

int16_t y

Y coordinate.

uint16_t pressure

Pressure or strength value from controller.