ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
gt9895_touchscreen.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/hal.h"
7
8namespace esphome::gt9895 {
9
10// Goodix GT9895 capacitive touch controller. Registers have a 32-bit big-endian address; data is little-endian and
11// each block ends with a 16-bit sum of its bytes.
12static constexpr uint32_t GT9895_REG_FW_VERSION = 0x00010014;
13static constexpr uint32_t GT9895_REG_RUNTIME_INFO = 0x00010070;
14static constexpr size_t GT9895_FW_VERSION_SIZE = 28;
15static constexpr size_t GT9895_RUNTIME_INFO_MAX_SIZE = 1024;
16
17// A touch report: an 8-byte header, then 8 bytes for each contact and a checksum
18static constexpr size_t GT9895_HEADER_SIZE = 8;
19static constexpr size_t GT9895_CONTACT_SIZE = 8;
20static constexpr size_t GT9895_CHECKSUM_SIZE = 2;
21static constexpr uint8_t GT9895_MAX_TOUCHES = 10;
22// Contacts read along with the header; more need a second read
23static constexpr uint8_t GT9895_FIRST_READ_CONTACTS = 2;
24static constexpr uint8_t GT9895_EVENT_TOUCH = 0x80;
25
27 public:
28 void setup() override;
29 void dump_config() override;
30
32 void set_reset_pin(GPIOPin *pin) { this->reset_pin_ = pin; }
33
34 protected:
35 void update_touches() override;
36 void read_info_();
37 bool read_(uint32_t address, uint8_t *data, size_t len);
38 void comm_failed_();
39 void read_again_();
40 static bool checksum_ok(const uint8_t *data, size_t len);
41
46 char product_id_[9]{};
47};
48
49} // namespace esphome::gt9895
void set_interrupt_pin(InternalGPIOPin *pin)
bool read_(uint32_t address, uint8_t *data, size_t len)
static bool checksum_ok(const uint8_t *data, size_t len)
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:144
const void size_t len
Definition hal.h:68
static void uint32_t