ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
cst9220_touchscreen.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/hal.h"
7#include "esphome/core/log.h"
8
9namespace esphome::cst9220 {
10
11static const char *const TAG = "cst9220.touchscreen";
12
13// The CST92xx family uses 16-bit (big-endian) register addresses.
14static const uint16_t REG_TOUCH_DATA = 0xD000; // touch report
15static const uint16_t REG_CMD_MODE = 0xD101; // enter command mode
16static const uint16_t REG_CHECKCODE = 0xD1FC; // firmware check code
17static const uint16_t REG_RESOLUTION = 0xD1F8; // panel resolution
18static const uint16_t REG_CHIP_INFO = 0xD204; // chip type + project id
19
20static const uint8_t TOUCH_ACK = 0xAB;
21static const uint8_t TOUCH_EVENT_DOWN = 0x06;
22
23static const uint16_t CST9220_CHIP_ID = 0x9220;
24static const uint16_t CST9217_CHIP_ID = 0x9217;
25
26// Maximum simultaneous touch points reported by the family.
27static const uint8_t CST9220_MAX_TOUCHES = 5;
28// Report layout: 5 bytes per touch point plus 5 bytes of status/ack overhead.
29static const size_t CST9220_DATA_LENGTH = CST9220_MAX_TOUCHES * 5 + 5;
30
32 public:
33 void setup() override;
34 void dump_config() override;
35
37 void set_reset_pin(GPIOPin *pin) { this->reset_pin_ = pin; }
38
39 protected:
40 void update_touches() override;
41 void continue_setup_();
42
45 uint16_t chip_id_{};
46 uint16_t project_id_{};
48};
49
50} // namespace esphome::cst9220
void set_interrupt_pin(InternalGPIOPin *pin)
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132