Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
goodixtouch.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_GOODIXTOUCH_H
27#define _ULTIBO_GOODIXTOUCH_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 GOODIX_TOUCH_DESCRIPTION "Goodix Touch Controller"
39
40#define GOODIX_MAX_HEIGHT 4096
41#define GOODIX_MAX_WIDTH 4096
42#define GOODIX_INT_TRIGGER 1
43#define GOODIX_CONTACT_SIZE 8
44#define GOODIX_MAX_CONTACT_SIZE 9
45#define GOODIX_MAX_CONTACTS 10
46#define GOODIX_MAX_KEYS 7
47
48#define GOODIX_CONFIG_MIN_LENGTH 186
49#define GOODIX_CONFIG_911_LENGTH 186
50#define GOODIX_CONFIG_967_LENGTH 228
51#define GOODIX_CONFIG_GT9X_LENGTH 240
52#define GOODIX_CONFIG_MAX_LENGTH 240
53
55#define GOODIX_I2C_RATE 400000
56#define GOODIX_CONFIG_TIMEOUT 3000
57
59#define GOODIX_REG_COMMAND 0x8040
60#define GOODIX_CMD_SCREEN_OFF 0x05
61
62#define GOODIX_READ_COOR_ADDR 0x814E
63#define GOODIX_GT1X_REG_CONFIG_DATA 0x8050
64#define GOODIX_GT9X_REG_CONFIG_DATA 0x8047
65#define GOODIX_REG_ID 0x8140
66
67#define GOODIX_BUFFER_STATUS_READY (1 << 7)
68#define GOODIX_HAVE_KEY (1 << 4)
69#define GOODIX_BUFFER_STATUS_TIMEOUT 20
70
71#define GOODIX_ID_MAX_LEN 4
72
73#define GOODIX_RESOLUTION_OFFSET 1
74#define GOODIX_MAX_CONTACTS_OFFSET 5
75#define GOODIX_TRIGGER_OFFSET 6
76
77static const uint32_t GOODIX_IRQ_TRIGGERS[4] = {GPIO_TRIGGER_RISING, GPIO_TRIGGER_FALLING, GPIO_TRIGGER_LOW, GPIO_TRIGGER_HIGH};
78
82{
83 // Touch Properties
85 // I2C Properties
87 uint16_t address;
88 // General Properties
91 uint16_t maxx;
92 uint16_t maxy;
93 uint16_t width;
94 uint16_t height;
95 uint32_t maxpoints;
96 uint32_t lastkeys;
97 uint32_t lastpoints;
98 // Goodix Properties
99 char *id;
100 uint16_t version;
101 uint16_t configaddress;
102 uint32_t configlength;
103 uint32_t checksumsize;
104 uint32_t contactsize;
114};
115
117
120
122
132TOUCH_DEVICE * STDCALL goodix_touch_create(I2C_DEVICE *i2c, uint16_t address, uint32_t width, uint32_t height, GPIO_INFO *irq, GPIO_INFO *rst);
133
140
141#ifdef __cplusplus
142}
143#endif
144
145#endif // _ULTIBO_GOODIXTOUCH_H
#define GPIO_TRIGGER_LOW
Definition globalconst.h:1402
#define GPIO_TRIGGER_HIGH
Definition globalconst.h:1403
#define GPIO_TRIGGER_RISING
Definition globalconst.h:1404
#define GPIO_TRIGGER_FALLING
Definition globalconst.h:1405
#define STDCALL
Definition globaltypes.h:45
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
void STDCALL goodix_init(void)
struct _GOODIX_TOUCH GOODIX_TOUCH
Definition goodixtouch.h:80
#define GOODIX_MAX_KEYS
Definition goodixtouch.h:46
uint32_t STDCALL goodix_touch_destroy(TOUCH_DEVICE *touch)
Stop, deregister and destroy a Goodix Touch device created by this driver.
#define GOODIX_MAX_CONTACT_SIZE
Definition goodixtouch.h:44
TOUCH_DEVICE *STDCALL goodix_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 Goodix Touch device connected to the specified I2C device.
#define GOODIX_CONFIG_MAX_LENGTH
Definition goodixtouch.h:52
uint8_t GOODIX_POINT_DATA[2+GOODIX_MAX_CONTACT_SIZE *GOODIX_MAX_CONTACTS]
Definition goodixtouch.h:116
#define GOODIX_MAX_CONTACTS
Definition goodixtouch.h:45
struct _GPIO_INFO GPIO_INFO
Definition gpio.h:176
struct _I2C_DEVICE I2C_DEVICE
Definition i2c.h:81
Definition goodixtouch.h:82
uint16_t scancodes[GOODIX_MAX_KEYS]
Definition goodixtouch.h:107
BOOL swapconfigxy
If True swap the max X and Y values in the configuration.
Definition goodixtouch.h:108
BOOL invertreportx
If True invert the X value in the input report.
Definition goodixtouch.h:110
uint16_t maxy
Maximum Y value from current configuration.
Definition goodixtouch.h:92
I2C_DEVICE * i2c
The I2C device this device is connected to.
Definition goodixtouch.h:86
uint32_t contactsize
Size of each contact point coordinate in touch data.
Definition goodixtouch.h:104
BOOL resetcontroller
If True reset the controller during initialization.
Definition goodixtouch.h:113
uint16_t maxx
Maximum X value from current configuration.
Definition goodixtouch.h:91
uint16_t address
The I2C address of the device.
Definition goodixtouch.h:87
uint32_t lastpoints
Points reported in last input report.
Definition goodixtouch.h:97
uint16_t configaddress
Configuration data address.
Definition goodixtouch.h:101
uint8_t configuration[GOODIX_CONFIG_MAX_LENGTH]
Definition goodixtouch.h:105
uint32_t configlength
Configuration data length in bytes.
Definition goodixtouch.h:102
uint16_t height
Screen height value supplied during create.
Definition goodixtouch.h:94
char * configfilename
The configuration filename to load during initialization.
Definition goodixtouch.h:112
GPIO_INFO rst
The GPIO information for the Reset line (Optional).
Definition goodixtouch.h:90
uint32_t maxpoints
Maximum touch points from current configuration.
Definition goodixtouch.h:95
GPIO_INFO irq
The GPIO information for the IRQ line (Optional).
Definition goodixtouch.h:89
uint16_t version
Version number for this device.
Definition goodixtouch.h:100
TOUCH_DEVICE touch
Definition goodixtouch.h:84
uint16_t keycodes[GOODIX_MAX_KEYS]
Definition goodixtouch.h:106
uint32_t checksumsize
Configuration checksum size.
Definition goodixtouch.h:103
uint16_t width
Screen width value supplied during create.
Definition goodixtouch.h:93
uint32_t lastkeys
Keys reported in last input report.
Definition goodixtouch.h:96
char * id
ID String for this device.
Definition goodixtouch.h:99
BOOL swapreportxy
If True swap the X and Y values in the input report.
Definition goodixtouch.h:109
BOOL invertreporty
If True invert the Y value in the input report.
Definition goodixtouch.h:111
struct _TOUCH_DEVICE TOUCH_DEVICE
Definition touch.h:151