SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
Loading...
Searching...
No Matches
TouchPoints Class Reference

Container for touch point data and optional gesture information. More...

#include <TouchPoints.hpp>

Public Member Functions

 TouchPoints ()
 Constructs an empty TouchPoints object.
 
 ~TouchPoints ()=default
 
void clear ()
 Clears all stored touch points and gesture.
 
bool addPoint (uint16_t x, uint16_t y, uint16_t pressure=0, uint8_t id=0, uint8_t event=0)
 Adds a touch point to the container.
 
void setGesture (Gesture g)
 Sets the gesture for this touch event.
 
uint8_t getPointCount () const
 Returns the number of stored touch points.
 
TouchPointgetPoint (uint8_t index)
 Gets a reference to a touch point at the specified index.
 
const TouchPointgetPoint (uint8_t index) const
 Gets a constant reference to a touch point at the specified index.
 
bool hasPoints () const
 Checks whether any touch points are stored.
 
bool hasGesture () const
 Checks whether a gesture is stored.
 
Gesture getGesture () const
 Returns the stored gesture.
 
TouchPointoperator[] (uint8_t index)
 
const TouchPointoperator[] (uint8_t index) const
 
TouchPointbegin ()
 
TouchPointend ()
 
const TouchPointbegin () const
 
const TouchPointend () const
 

Static Public Attributes

static constexpr uint8_t MAX_POINTS = 5
 Maximum number of touch points supported.
 

Detailed Description

Container for touch point data and optional gesture information.

This class holds up to MAX_POINTS touch points and an optional gesture. It is designed to be filled by a touch driver and consumed by the application.

Definition at line 66 of file TouchPoints.hpp.

Constructor & Destructor Documentation

◆ TouchPoints()

TouchPoints::TouchPoints ( )

Constructs an empty TouchPoints object.

Definition at line 36 of file TouchPoints.cpp.

◆ ~TouchPoints()

TouchPoints::~TouchPoints ( )
default

Member Function Documentation

◆ addPoint()

bool TouchPoints::addPoint ( uint16_t  x,
uint16_t  y,
uint16_t  pressure = 0,
uint8_t  id = 0,
uint8_t  event = 0 
)

Adds a touch point to the container.

Parameters
xX coordinate of the touch point.
yY coordinate of the touch point.
pressurePressure value (default 0).
idTouch point ID (default 0).
eventEvent type (default 0).
Returns
true if the point was added successfully, false if the container is full.

Definition at line 45 of file TouchPoints.cpp.

References TouchPoint::event, TouchPoint::id, MAX_POINTS, pressure(), TouchPoint::pressure, x, TouchPoint::x, y, and TouchPoint::y.

Referenced by TouchDrvCHSC5816::getTouchPoints(), TouchDrvCST226::getTouchPoints(), TouchDrvCST3530::getTouchPoints(), TouchDrvCST816::getTouchPoints(), TouchDrvCST92xx::getTouchPoints(), TouchDrvFT6X36::getTouchPoints(), TouchDrvGT911::getTouchPoints(), TouchDrvGT9895::getTouchPoints(), and TouchDrvHI8561::getTouchPoints().

◆ begin() [1/2]

TouchPoint * TouchPoints::begin ( )
inline

Definition at line 158 of file TouchPoints.hpp.

◆ begin() [2/2]

const TouchPoint * TouchPoints::begin ( ) const
inline

Definition at line 166 of file TouchPoints.hpp.

◆ clear()

◆ end() [1/2]

TouchPoint * TouchPoints::end ( )
inline

Definition at line 162 of file TouchPoints.hpp.

◆ end() [2/2]

const TouchPoint * TouchPoints::end ( ) const
inline

Definition at line 170 of file TouchPoints.hpp.

◆ getGesture()

Gesture TouchPoints::getGesture ( ) const

Returns the stored gesture.

Returns
The gesture value. Valid only if hasGesture() returns true.

Definition at line 93 of file TouchPoints.cpp.

◆ getPoint() [1/2]

TouchPoint & TouchPoints::getPoint ( uint8_t  index)

Gets a reference to a touch point at the specified index.

Note
The index must be valid (0 to getPointCount()-1).
Parameters
indexThe index of the touch point to retrieve.
Return values
Areference to the touch point at the specified index.

Definition at line 68 of file TouchPoints.cpp.

References SENSORLIB_LOG_E.

Referenced by TouchDrvInterface::getPoint(), TouchDrvCST92xx::getTouchPoints(), loop(), operator[](), operator[](), touch_drv_isr_handler(), and TouchDrvInterface::updateXY().

◆ getPoint() [2/2]

const TouchPoint & TouchPoints::getPoint ( uint8_t  index) const

Gets a constant reference to a touch point at the specified index.

Note
The index must be valid (0 to getPointCount()-1).
Parameters
indexThe index of the touch point to retrieve.
Return values
Aconstant reference to the touch point at the specified index.

Definition at line 75 of file TouchPoints.cpp.

References SENSORLIB_LOG_E.

◆ getPointCount()

uint8_t TouchPoints::getPointCount ( ) const

Returns the number of stored touch points.

Returns
Number of valid touch points.

Definition at line 63 of file TouchPoints.cpp.

Referenced by TouchDrvInterface::getPoint(), loop(), touch_drv_isr_handler(), and TouchDrvInterface::updateXY().

◆ hasGesture()

bool TouchPoints::hasGesture ( ) const

Checks whether a gesture is stored.

Returns
true if a valid gesture is present, false otherwise.

Definition at line 88 of file TouchPoints.cpp.

◆ hasPoints()

bool TouchPoints::hasPoints ( ) const

Checks whether any touch points are stored.

Returns
true if at least one touch point is present, false otherwise.

Definition at line 82 of file TouchPoints.cpp.

Referenced by TouchDrvInterface::getPoint(), TouchDrvInterface::isPressed(), loop(), and touch_drv_isr_handler().

◆ operator[]() [1/2]

TouchPoint & TouchPoints::operator[] ( uint8_t  index)
inline

Definition at line 149 of file TouchPoints.hpp.

References getPoint().

◆ operator[]() [2/2]

const TouchPoint & TouchPoints::operator[] ( uint8_t  index) const
inline

Definition at line 153 of file TouchPoints.hpp.

References getPoint().

◆ setGesture()

void TouchPoints::setGesture ( Gesture  g)

Sets the gesture for this touch event.

Parameters
gThe gesture to set.

Definition at line 57 of file TouchPoints.cpp.

Member Data Documentation

◆ MAX_POINTS

constexpr uint8_t TouchPoints::MAX_POINTS = 5
staticconstexpr

Maximum number of touch points supported.

Definition at line 70 of file TouchPoints.hpp.

Referenced by addPoint().


The documentation for this class was generated from the following files: