rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
gt911.h File Reference

GT911 capacitive touch controller driver over I2C (Inter-Integrated Circuit). More...

#include "driver/i2c_master.h"
#include "esp_err.h"
#include "touch_types.h"

Go to the source code of this file.

Data Structures

struct  gt911_config_t

Macros

#define GT911_REG_COMMAND   0x8040
#define GT911_REG_CONFIG   0x8047
#define GT911_REG_X_MAX   0x8048
#define GT911_REG_Y_MAX   0x804A
#define GT911_REG_PRODUCT_ID   0x8140
#define GT911_REG_FW_VERSION   0x8144
#define GT911_REG_STATUS   0x814E
#define GT911_REG_POINT0   0x814F
#define GT911_STATUS_READY   0x80
#define GT911_STATUS_COUNT_MASK   0x0F
#define GT911_POINT_STRIDE   8

Typedefs

typedef struct gt911_dev_t * gt911_handle_t

Functions

esp_err_t gt911_new (i2c_master_bus_handle_t bus, const gt911_config_t *cfg, gt911_handle_t *out)
esp_err_t gt911_del (gt911_handle_t h)
uint16_t gt911_address (gt911_handle_t h)
esp_err_t gt911_info (gt911_handle_t h, char product_id[5], uint16_t *fw_version)
esp_err_t gt911_resolution (gt911_handle_t h, uint16_t *x_max, uint16_t *y_max)
esp_err_t gt911_read (gt911_handle_t h, touch_point_t *out, int max, int *count, bool *fresh)

Detailed Description

GT911 capacitive touch controller driver over I2C (Inter-Integrated Circuit).

The GT911 uses 16-bit big-endian register addresses. Coordinates live in a buffer whose ready flag the host clears after each read; while the flag is set the controller does not update the buffer.

SPDX-License-Identifier: MIT

Function Documentation

◆ gt911_address()

uint16_t gt911_address ( gt911_handle_t h)

I2C address the driver settled on.

◆ gt911_info()

esp_err_t gt911_info ( gt911_handle_t h,
char product_id[5],
uint16_t * fw_version )

Product id string ("911") and firmware version.

◆ gt911_new()

esp_err_t gt911_new ( i2c_master_bus_handle_t bus,
const gt911_config_t * cfg,
gt911_handle_t * out )

Attach to a controller already out of reset.

◆ gt911_read()

esp_err_t gt911_read ( gt911_handle_t h,
touch_point_t * out,
int max,
int * count,
bool * fresh )

Read the current contacts and acknowledge the buffer.

Parameters
outreceives up to max points, in controller coordinates
maxcapacity of out
countreceives the number of contacts (0 when all fingers lifted)
freshoptional; false means the controller had no new data and count/out were left untouched

◆ gt911_resolution()

esp_err_t gt911_resolution ( gt911_handle_t h,
uint16_t * x_max,
uint16_t * y_max )

Resolution the controller was configured with.