Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
ft5x06touch.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_FT5X06TOUCH_H
27#define _ULTIBO_FT5X06TOUCH_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/gpio.h"
34#include "ultibo/i2c.h"
35#include "ultibo/touch.h"
36
38#define FT5X06_TOUCH_DESCRIPTION "EDT FocalTech FT5x06 Touch Controller"
39
41#define FT5X06_I2C_RATE 400000
42
44#define FT5X06_WORK_REGISTER_THRESHOLD 0x00
45#define FT5X06_WORK_REGISTER_REPORT_RATE 0x08
46#define FT5X06_WORK_REGISTER_GAIN 0x30
47#define FT5X06_WORK_REGISTER_OFFSET 0x31
48#define FT5X06_WORK_REGISTER_NUM_X 0x33
49#define FT5X06_WORK_REGISTER_NUM_Y 0x34
50
51#define FT5X06_PMOD_REGISTER_ACTIVE 0x00
52#define FT5X06_PMOD_REGISTER_HIBERNATE 0x03
53
54#define FT5X06_M09_REGISTER_THRESHOLD 0x80
55#define FT5X06_M09_REGISTER_GAIN 0x92
56#define FT5X06_M09_REGISTER_OFFSET 0x93
57#define FT5X06_M09_REGISTER_NUM_X 0x94
58#define FT5X06_M09_REGISTER_NUM_Y 0x95
59
60#define FT5X06_EV_REGISTER_THRESHOLD 0x40
61#define FT5X06_EV_REGISTER_GAIN 0x41
62#define FT5X06_EV_REGISTER_OFFSET_Y 0x45
63#define FT5X06_EV_REGISTER_OFFSET_X 0x46
64
65#define FT5X06_NO_REGISTER 0xff
66
67#define FT5X06_WORK_REGISTER_OPMODE 0x3c
68#define FT5X06_FACTORY_REGISTER_OPMODE 0x01
69#define FT5X06_PMOD_REGISTER_OPMODE 0xa5
70
71#define FT5X06_TOUCH_EVENT_DOWN 0x00
72#define FT5X06_TOUCH_EVENT_UP 0x01
73#define FT5X06_TOUCH_EVENT_ON 0x02
74#define FT5X06_TOUCH_EVENT_RESERVED 0x03
75
76#define FT5X06_EDT_NAME_LEN 23
77#define FT5X06_EDT_SWITCH_MODE_RETRIES 10
78#define FT5X06_EDT_SWITCH_MODE_DELAY 5
79#define FT5X06_EDT_RAW_DATA_RETRIES 100
80#define FT5X06_EDT_RAW_DATA_DELAY 1000
81
82#define FT5X06_POLL_INTERVAL_MS 17
83
85#define FT5X06_EDT_M06 0
86#define FT5X06_EDT_M09 1
87#define FT5X06_EDT_M12 2
88#define FT5X06_EV_FT 3
89#define FT5X06_GENERIC_FT 4
90
94{
95 uint8_t threshold;
96 uint8_t reportrate;
97 uint8_t gain;
98 uint8_t offset;
99 uint8_t offsetx;
100 uint8_t offsety;
101 uint8_t numx;
102 uint8_t numy;
103};
104
105
108{
109 uint8_t threshold;
110 uint8_t reportrate;
111 uint8_t gain;
112 uint8_t offset;
113 uint8_t offsetx;
114 uint8_t offsety;
115 uint8_t numx;
116 uint8_t numy;
117};
118
119
122{
123 // Touch Properties
125 // I2C Properties
127 uint16_t address;
128 // General Properties
132 uint16_t maxx;
133 uint16_t maxy;
134 uint16_t width;
135 uint16_t height;
136 uint32_t maxpoints;
137 uint32_t lastpoints;
138 // FT5x06 Properties
139 uint32_t version;
140 char *modelname;
147};
148
151
153
163TOUCH_DEVICE * STDCALL ft5x06_touch_create(I2C_DEVICE *i2c, uint16_t address, uint32_t width, uint32_t height, GPIO_INFO *irq, GPIO_INFO *rst);
164
171
172#ifdef __cplusplus
173}
174#endif
175
176#endif // _ULTIBO_FT5X06TOUCH_H
uint32_t STDCALL ft5x06_touch_destroy(TOUCH_DEVICE *touch)
Stop, deregister and destroy a FT5x06 Touch device created by this driver.
void STDCALL ft5x06_init(void)
struct _FT5X06_TOUCH FT5X06_TOUCH
Definition ft5x06touch.h:120
struct _FT5X06_PARAMETERS FT5X06_PARAMETERS
Definition ft5x06touch.h:106
TOUCH_DEVICE *STDCALL ft5x06_touch_create(I2C_DEVICE *i2c, uint16_t address, uint32_t width, uint32_t height, GPIO_INFO *irq, GPIO_INFO *rst)
Create, register and start a new FT5x06 Touch device connected to the specified I2C device.
struct _FT5X06_REGISTERS FT5X06_REGISTERS
Definition ft5x06touch.h:92
#define STDCALL
Definition globaltypes.h:45
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
HANDLE TIMER_HANDLE
Definition globaltypes.h:119
struct _GPIO_INFO GPIO_INFO
Definition gpio.h:176
struct _I2C_DEVICE I2C_DEVICE
Definition i2c.h:81
Definition ft5x06touch.h:108
uint8_t reportrate
Definition ft5x06touch.h:110
uint8_t offsety
Definition ft5x06touch.h:114
uint8_t numx
Definition ft5x06touch.h:115
uint8_t offsetx
Definition ft5x06touch.h:113
uint8_t gain
Definition ft5x06touch.h:111
uint8_t offset
Definition ft5x06touch.h:112
uint8_t numy
Definition ft5x06touch.h:116
uint8_t threshold
Definition ft5x06touch.h:109
Definition ft5x06touch.h:94
uint8_t reportrate
Definition ft5x06touch.h:96
uint8_t offsety
Definition ft5x06touch.h:100
uint8_t numx
Definition ft5x06touch.h:101
uint8_t offsetx
Definition ft5x06touch.h:99
uint8_t gain
Definition ft5x06touch.h:97
uint8_t offset
Definition ft5x06touch.h:98
uint8_t numy
Definition ft5x06touch.h:102
uint8_t threshold
Definition ft5x06touch.h:95
Definition ft5x06touch.h:122
char * modelname
Model name string for this device.
Definition ft5x06touch.h:140
BOOL invertreportx
If True invert the X value in the input report.
Definition ft5x06touch.h:145
uint16_t maxy
Maximum Y value from current configuration.
Definition ft5x06touch.h:133
I2C_DEVICE * i2c
The I2C device this device is connected to.
Definition ft5x06touch.h:126
uint16_t maxx
Maximum X value from current configuration.
Definition ft5x06touch.h:132
FT5X06_REGISTERS registers
Register addresses for this device.
Definition ft5x06touch.h:142
uint16_t address
The I2C address of the device.
Definition ft5x06touch.h:127
uint32_t lastpoints
Points reported in last input report.
Definition ft5x06touch.h:137
uint16_t height
Screen height value supplied during create.
Definition ft5x06touch.h:135
GPIO_INFO rst
The GPIO information for the Reset line (Optional).
Definition ft5x06touch.h:130
uint32_t maxpoints
Maximum touch points for this device.
Definition ft5x06touch.h:136
GPIO_INFO irq
The GPIO information for the IRQ line (Optional).
Definition ft5x06touch.h:129
TOUCH_DEVICE touch
Definition ft5x06touch.h:124
char * firmwareversion
Firmware version string for this device.
Definition ft5x06touch.h:141
uint32_t version
Version constant for this device (eg FT5X06_EDT_M06).
Definition ft5x06touch.h:139
uint16_t width
Screen width value supplied during create.
Definition ft5x06touch.h:134
FT5X06_PARAMETERS parameters
Configuration parameters for this device.
Definition ft5x06touch.h:143
BOOL swapreportxy
If True swap the X and Y values in the input report.
Definition ft5x06touch.h:144
TIMER_HANDLE timer
Handle for touch polling timer.
Definition ft5x06touch.h:131
BOOL invertreporty
If True invert the Y value in the input report.
Definition ft5x06touch.h:146
struct _TOUCH_DEVICE TOUCH_DEVICE
Definition touch.h:151