ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
st7123_touchscreen.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/hal.h"
7
8namespace esphome::st7123 {
9
10// Sitronix ST7123 capacitive touch controller.
11// Registers are addressed with a 16-bit big-endian address (sent MSB first).
12static constexpr uint16_t ST7123_REG_STATUS = 0x0001; // [7:4] error code, [3:0] device status
13static constexpr uint16_t ST7123_REG_MAX_X = 0x0005; // 0x0005..0x0006 X resolution, 0x0007..0x0008 Y resolution
14static constexpr uint16_t ST7123_REG_MAX_TOUCHES = 0x0009;
15static constexpr uint16_t ST7123_REG_ADV_TOUCH_INFO = 0x0010; // start of the reporting table
16static constexpr uint16_t ST7123_REG_TOUCH_DATA = 0x0014; // first touch point
17
18// Device status field of the status register.
19static constexpr uint8_t ST7123_STATUS_INIT = 0x1;
20
21// Each touch point occupies 7 bytes: X high, X low, Y high, Y low, area, intensity, reserved.
22static constexpr uint8_t ST7123_TOUCH_STRIDE = 7;
23// Bit 7 of the X high byte indicates a valid touch point.
24static constexpr uint8_t ST7123_TOUCH_VALID = 0x80;
25// The X and Y high bytes only use the low 6 bits.
26static constexpr uint8_t ST7123_COORD_HIGH_MASK = 0x3F;
27// The ST7123 can report at most 10 touch points.
28static constexpr uint8_t ST7123_MAX_TOUCHES = 10;
29
31 public:
32 void setup() override;
33 void update() 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
44 uint8_t max_touches_{ST7123_MAX_TOUCHES};
46};
47
48} // namespace esphome::st7123
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:132
void set_interrupt_pin(InternalGPIOPin *pin)
static void uint32_t