Touch Interface

[中文]

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

Class: DisplayTouchIface

API Reference

Header File

Classes

class TouchIface : 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 TouchIface(Info info)

Construct a touch-input interface.

Parameters

info -- [in] Static touch capability information.

virtual ~TouchIface() = 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, void *ctx) = 0

Register an interrupt handler.

The handler is called from ISR context and must only do ISR-safe work.

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

  • ctx -- [in] User context passed to handler.

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.

uint8_t max_points = 1

Maximum number of simultaneous touch points.

OperationMode operation_mode = OperationMode::Max

Supported acquisition mode.

std::string group_id

Stable physical display group identifier.

struct Point

A single touch point sample.

Public Members

int16_t x = 0

X coordinate.

int16_t y = 0

Y coordinate.

uint16_t pressure = 0

Pressure or strength value from controller.

uint8_t track_id = 0

Hardware track identifier for multi-touch controllers.