ESPHome  2024.6.1
cst816_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 
9 namespace esphome {
10 namespace cst816 {
11 
12 static const char *const TAG = "cst816.touchscreen";
13 
14 static const uint8_t REG_STATUS = 0x00;
15 static const uint8_t REG_TOUCH_NUM = 0x02;
16 static const uint8_t REG_XPOS_HIGH = 0x03;
17 static const uint8_t REG_XPOS_LOW = 0x04;
18 static const uint8_t REG_YPOS_HIGH = 0x05;
19 static const uint8_t REG_YPOS_LOW = 0x06;
20 static const uint8_t REG_DIS_AUTOSLEEP = 0xFE;
21 static const uint8_t REG_CHIP_ID = 0xA7;
22 static const uint8_t REG_FW_VERSION = 0xA9;
23 static const uint8_t REG_SLEEP = 0xE5;
24 static const uint8_t REG_IRQ_CTL = 0xFA;
25 static const uint8_t IRQ_EN_MOTION = 0x70;
26 
27 static const uint8_t CST826_CHIP_ID = 0x11;
28 static const uint8_t CST820_CHIP_ID = 0xB7;
29 static const uint8_t CST816S_CHIP_ID = 0xB4;
30 static const uint8_t CST816D_CHIP_ID = 0xB6;
31 static const uint8_t CST816T_CHIP_ID = 0xB5;
32 static const uint8_t CST716_CHIP_ID = 0x20;
33 
35  public:
36  virtual void update_button(bool state) = 0;
37 };
38 
40  public:
41  void setup() override;
42  void update_touches() override;
43  void register_button_listener(CST816ButtonListener *listener) { this->button_listeners_.push_back(listener); }
44  void dump_config() override;
45 
46  void set_interrupt_pin(InternalGPIOPin *pin) { this->interrupt_pin_ = pin; }
47  void set_reset_pin(GPIOPin *pin) { this->reset_pin_ = pin; }
48 
49  protected:
50  void continue_setup_();
51  void update_button_state_(bool state);
52 
53  InternalGPIOPin *interrupt_pin_{};
54  GPIOPin *reset_pin_{};
55  uint8_t chip_id_{};
56  std::vector<CST816ButtonListener *> button_listeners_;
57  bool button_touched_{};
58 };
59 
60 } // namespace cst816
61 } // namespace esphome
void setup()
virtual void update_button(bool state)=0
void register_button_listener(CST816ButtonListener *listener)
void set_interrupt_pin(InternalGPIOPin *pin)
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
This Class provides the methods to read/write bytes from/to an i2c device.
Definition: i2c.h:133
std::vector< CST816ButtonListener * > button_listeners_
bool state
Definition: fan.h:34