ft5x06.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
24 #ifndef FT5X06_H
25 #define FT5X06_H
26 
27 #include <stdint.h>
28 
29 #include "periph/gpio.h"
30 #include "periph/i2c.h"
31 
32 #include "ft5x06_constants.h"
33 
34 #ifdef MODULE_TOUCH_DEV
35 #include "touch_dev.h"
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
45 typedef struct {
46  uint16_t x;
47  uint16_t y;
49 
53 typedef enum {
62 
66 typedef enum {
79 
93 typedef enum {
94  FT5X06_NO_CONV = 0x00,
95  FT5X06_MIRROR_X = 0x01,
96  FT5X06_MIRROR_Y = 0x02,
97  FT5X06_SWAP_XY = 0x04,
99 
105 typedef void (*ft5x06_event_cb_t)(void *arg);
106 
114 typedef struct {
116  uint8_t addr;
117  gpio_t int_pin;
118  uint16_t xmax;
119  uint16_t ymax;
124 
128 typedef struct {
129 #ifdef MODULE_TOUCH_DEV
130  touch_dev_t *dev;
131 #endif
133 } ft5x06_t;
134 
147 int ft5x06_init(ft5x06_t *dev, const ft5x06_params_t *params,
148  ft5x06_event_cb_t cb, void *arg);
149 
160 int ft5x06_read_touch_positions(const ft5x06_t *dev, ft5x06_touch_position_t *positions, size_t len);
161 
171 int ft5x06_read_touch_count(const ft5x06_t *dev, uint8_t *count);
172 
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 #endif /* FT5X06_H */
Low-level GPIO peripheral driver interface definitions.
Internal register addresses, bitfields and constants.
ft5x06_touch_conv_t
Touch screen coordinate conversions.
Definition: ft5x06.h:93
int ft5x06_read_touch_gesture(const ft5x06_t *dev, ft5x06_touch_gesture_t *gesture)
Read the gesture detected.
ft5x06_type_t
Device type.
Definition: ft5x06.h:66
void(* ft5x06_event_cb_t)(void *arg)
Signature of the touch event callback triggered from interrupt.
Definition: ft5x06.h:105
int ft5x06_read_touch_positions(const ft5x06_t *dev, ft5x06_touch_position_t *positions, size_t len)
Read the touch positions.
int ft5x06_read_touch_count(const ft5x06_t *dev, uint8_t *count)
Read the number of touch.
int ft5x06_init(ft5x06_t *dev, const ft5x06_params_t *params, ft5x06_event_cb_t cb, void *arg)
Initialize the given device.
ft5x06_touch_gesture_t
Touch gesture.
Definition: ft5x06.h:53
@ FT5X06_SWAP_XY
Swap XY, applied before optional mirroring.
Definition: ft5x06.h:97
@ FT5X06_MIRROR_X
Mirror X, applied after optional swapping.
Definition: ft5x06.h:95
@ FT5X06_NO_CONV
No conversion.
Definition: ft5x06.h:94
@ FT5X06_MIRROR_Y
Mirror Y, applied after optional swapping.
Definition: ft5x06.h:96
@ FT5X06_TYPE_FT5X06
FT5X06.
Definition: ft5x06.h:67
@ FT5X06_TYPE_FT5X46
FT5X46.
Definition: ft5x06.h:77
@ FT5X06_TYPE_FT3316
FT3316.
Definition: ft5x06.h:74
@ FT5X06_TYPE_FT6X36
FT6X36.
Definition: ft5x06.h:71
@ FT5X06_TYPE_FT5606
FT5606.
Definition: ft5x06.h:68
@ FT5X06_TYPE_FT5336
FT5336.
Definition: ft5x06.h:73
@ FT5X06_TYPE_FT6X06
FT6X06.
Definition: ft5x06.h:70
@ FT5X06_TYPE_FT5X16
FT5X16.
Definition: ft5x06.h:69
@ FT5X06_TYPE_FT5436I
FT5436I.
Definition: ft5x06.h:75
@ FT5X06_TYPE_FT5X06I
FT5X06I.
Definition: ft5x06.h:72
@ FT5X06_TYPE_FT5336I
FT5336I.
Definition: ft5x06.h:76
@ FT5X06_TOUCH_ZOOM_OUT
Zoom out gesture detected.
Definition: ft5x06.h:60
@ FT5X06_TOUCH_MOVE_RIGHT
Move right gesture detected.
Definition: ft5x06.h:58
@ FT5X06_TOUCH_MOVE_LEFT
Move left gesture detected.
Definition: ft5x06.h:56
@ FT5X06_TOUCH_NO_GESTURE
No gesture detected.
Definition: ft5x06.h:54
@ FT5X06_TOUCH_ZOOM_IN
Zoom int gesture detected.
Definition: ft5x06.h:59
@ FT5X06_TOUCH_MOVE_DOWN
Move down gesture detected.
Definition: ft5x06.h:57
@ FT5X06_TOUCH_MOVE_UP
Move up gesture detected.
Definition: ft5x06.h:55
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition: i2c.h:145
Low-level I2C peripheral driver interface definition.
Device initialization parameters.
Definition: ft5x06.h:114
uint16_t ymax
Touch screen max Y position.
Definition: ft5x06.h:119
ft5x06_type_t type
Device type.
Definition: ft5x06.h:122
uint8_t addr
Device I2C address.
Definition: ft5x06.h:116
i2c_t i2c
I2C device which is used.
Definition: ft5x06.h:115
uint16_t xmax
Touch screen max X position.
Definition: ft5x06.h:118
ft5x06_touch_conv_t xyconv
Touch screen coordinates conversion, swapping is performed before mirroring.
Definition: ft5x06.h:120
gpio_t int_pin
Touch screen interrupt pin.
Definition: ft5x06.h:117
Device descriptor for the driver.
Definition: ft5x06.h:128
const ft5x06_params_t * params
Initialization parameters.
Definition: ft5x06.h:132
Touch position structure.
Definition: ft5x06.h:45
uint16_t x
X position.
Definition: ft5x06.h:46
uint16_t y
Y position.
Definition: ft5x06.h:47
Generic type for a touch device.
Definition: touch_dev.h:116