15 static const uint8_t FT6X36_ADDR_DEVICE_MODE = 0x00;
17 static const uint8_t FT63X6_ADDR_TD_STATUS = 0x02;
18 static const uint8_t FT63X6_ADDR_TOUCH1_STATE = 0x03;
19 static const uint8_t FT63X6_ADDR_TOUCH1_X = 0x03;
20 static const uint8_t FT63X6_ADDR_TOUCH1_ID = 0x05;
21 static const uint8_t FT63X6_ADDR_TOUCH1_Y = 0x05;
22 static const uint8_t FT63X6_ADDR_TOUCH1_WEIGHT = 0x07;
23 static const uint8_t FT63X6_ADDR_TOUCH1_MISC = 0x08;
24 static const uint8_t FT6X36_ADDR_THRESHHOLD = 0x80;
25 static const uint8_t FT6X36_ADDR_TOUCHRATE_ACTIVE = 0x88;
26 static const uint8_t FT63X6_ADDR_CHIP_ID = 0xA3;
28 static const char *
const TAG =
"FT63X6";
31 ESP_LOGCONFIG(TAG,
"Setting up FT63X6 Touchscreen...");
50 uint8_t chip_id = this->
read_byte_(FT63X6_ADDR_CHIP_ID);
52 ESP_LOGI(TAG,
"FT6336U touch driver started chipid: %d", chip_id);
54 ESP_LOGE(TAG,
"FT6336U touch driver failed to start");
56 this->
write_byte(FT6X36_ADDR_DEVICE_MODE, 0x00);
58 this->
write_byte(FT6X36_ADDR_TOUCHRATE_ACTIVE, 0x0E);
70 ESP_LOGCONFIG(TAG,
"FT63X6 Touchscreen:");
74 LOG_UPDATE_INTERVAL(
this);
81 ESP_LOGV(TAG,
"Touches found: %d", touches);
82 if ((touches == 0x00) || (touches == 0xff)) {
87 for (
auto point = 0; point < touches; point++) {
92 if ((x == 0) && (y == 0)) {
93 ESP_LOGW(TAG,
"Reporting a (0,0) touch on %d", touch_id);
104 read_buf[0] = this->
read_byte_(FT63X6_ADDR_TOUCH1_X + (touch * 6));
105 read_buf[1] = this->
read_byte_(FT63X6_ADDR_TOUCH1_X + 1 + (touch * 6));
106 return ((read_buf[0] & 0x0f) << 8) | read_buf[1];
110 read_buf[0] = this->
read_byte_(FT63X6_ADDR_TOUCH1_Y + (touch * 6));
111 read_buf[1] = this->
read_byte_(FT63X6_ADDR_TOUCH1_Y + 1 + (touch * 6));
112 return ((read_buf[0] & 0x0f) << 8) | read_buf[1];
115 return this->
read_byte_(FT63X6_ADDR_TOUCH1_X + (touch * 6)) >> 6;
118 return this->
read_byte_(FT63X6_ADDR_TOUCH1_ID + (touch * 6)) >> 4;
121 return this->
read_byte_(FT63X6_ADDR_TOUCH1_WEIGHT + (touch * 6));
124 return this->
read_byte_(FT63X6_ADDR_TOUCH1_MISC + (touch * 6)) >> 4;
virtual void digital_write(bool value)=0
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
uint8_t read_touch_number_()
InternalGPIOPin * interrupt_pin_
uint8_t read_touch_weight_(uint8_t touch)
virtual void pin_mode(gpio::Flags flags)=0
void update_touches() override
void dump_config() override
void attach_interrupt_(InternalGPIOPin *irq_pin, esphome::gpio::InterruptType type)
Call this function to send touch points to the on_touch listener and the binary_sensors.
uint16_t read_touch_x_(uint8_t touch)
uint8_t read_byte_(uint8_t addr)
uint8_t read_touch_misc_(uint8_t touch)
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
void add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw=0)
Implementation of SPI Controller mode.
uint8_t read_touch_id_(uint8_t touch)
uint16_t read_touch_y_(uint8_t touch)
uint8_t read_touch_event_(uint8_t touch)
void IRAM_ATTR HOT delay(uint32_t ms)