Loading...
Searching...
No Matches
Touch device generic API

Define the generic API of a touch device. More...

Detailed Description

Define the generic API of a touch device.

Warning
This feature is experimental!
This API is experimental and in an early state - expect changes!
Author
Alexandre Abadie alexa.nosp@m.ndre.nosp@m..abad.nosp@m.ie@i.nosp@m.nria..nosp@m.fr

Data Structures

struct  touch_t
 Touch coordinates. More...
 
struct  touch_dev_driver_t
 Generic type for a touch driver. More...
 
struct  touch_dev
 Generic type for a touch device. More...
 
struct  touch_dev_reg
 Touch dev registry entry. More...
 

Macros

#define TOUCH_DEV_VALUE_INVALID   ((touch_t){ UINT16_MAX, UINT16_MAX })
 Invalid touch value.
 

Typedefs

typedef struct touch_dev touch_dev_t
 Forward declaration for touch device struct.
 
typedef void(* touch_event_cb_t) (void *arg)
 Signature of touch event callback triggered from interrupt.
 
typedef struct touch_dev_reg touch_dev_reg_t
 Touch dev registry entry.
 

Functions

int touch_dev_reg_add (touch_dev_reg_t *dev)
 Add pointer to a touch device item to the list of touch items.
 
touch_dev_reg_ttouch_dev_reg_find_screen (uint8_t screen_id)
 Find the touch device that is attached to a given screen.
 
uint16_t touch_dev_height (const touch_dev_t *dev)
 Get the height of the touch device.
 
uint16_t touch_dev_width (const touch_dev_t *dev)
 Get the width of the touch device.
 
static uint8_t touch_dev_max_numof (const touch_dev_t *dev)
 Get the maximum number of touches the touch device supports.
 
uint8_t touch_dev_touches (const touch_dev_t *dev, touch_t *touches, size_t len)
 Get the current touches on the touch device.
 
void touch_dev_set_touch_event_callback (const touch_dev_t *dev, touch_event_cb_t cb, void *arg)
 Set and configure the touch event callback.
 

Variables

touch_dev_reg_ttouch_dev_reg
 Export the touch device registry as global variable.
 

Macro Definition Documentation

◆ TOUCH_DEV_VALUE_INVALID

#define TOUCH_DEV_VALUE_INVALID   ((touch_t){ UINT16_MAX, UINT16_MAX })

Invalid touch value.

Definition at line 34 of file touch_dev.h.

Typedef Documentation

◆ touch_dev_t

typedef struct touch_dev touch_dev_t

Forward declaration for touch device struct.

Definition at line 39 of file touch_dev.h.

◆ touch_event_cb_t

typedef void(* touch_event_cb_t) (void *arg)

Signature of touch event callback triggered from interrupt.

Parameters
[in]argoptional context for the callback

Definition at line 54 of file touch_dev.h.

Function Documentation

◆ touch_dev_height()

uint16_t touch_dev_height ( const touch_dev_t dev)

Get the height of the touch device.

Parameters
[in]devPointer to the touch device
Returns
Height in points

◆ touch_dev_max_numof()

static uint8_t touch_dev_max_numof ( const touch_dev_t dev)
inlinestatic

Get the maximum number of touches the touch device supports.

Parameters
[in]devPointer to the touch device
Returns
number of touches

Definition at line 179 of file touch_dev.h.

◆ touch_dev_reg_add()

int touch_dev_reg_add ( touch_dev_reg_t dev)

Add pointer to a touch device item to the list of touch items.

Parameters
[in]devPointer to the touch device
Returns
0 on success
-ENODEV on invalid entry

◆ touch_dev_reg_find_screen()

touch_dev_reg_t * touch_dev_reg_find_screen ( uint8_t  screen_id)

Find the touch device that is attached to a given screen.

Parameters
[in]screen_idIdentifier (number) of the screen
Returns
pointer to the touch device in the registry
NULL if there's no match

◆ touch_dev_set_touch_event_callback()

void touch_dev_set_touch_event_callback ( const touch_dev_t dev,
touch_event_cb_t  cb,
void *  arg 
)

Set and configure the touch event callback.

Parameters
[in]devPointer to the touch device
[in]cbThe callback function
[in]argContext argument

◆ touch_dev_touches()

uint8_t touch_dev_touches ( const touch_dev_t dev,
touch_t touches,
size_t  len 
)

Get the current touches on the touch device.

If touches is NULL, this function only returns the number of touches.

Touch position coordinates use the top left corner as origin.

Parameters
[in]devPointer to the touch device
[out]touchesThe array of touches
[in]lenThe touches array len
Returns
number of touch positions, 0 means no touch

◆ touch_dev_width()

uint16_t touch_dev_width ( const touch_dev_t dev)

Get the width of the touch device.

Parameters
[in]devPointer to the touch device
Returns
Width in points