15static const uint8_t FT6X36_ADDR_DEVICE_MODE = 0x00;
17static const uint8_t FT63X6_ADDR_TD_STATUS = 0x02;
18static const uint8_t FT63X6_ADDR_TOUCH1_STATE = 0x03;
19static const uint8_t FT63X6_ADDR_TOUCH1_X = 0x03;
20static const uint8_t FT63X6_ADDR_TOUCH1_ID = 0x05;
21static const uint8_t FT63X6_ADDR_TOUCH1_Y = 0x05;
22static const uint8_t FT63X6_ADDR_TOUCH1_WEIGHT = 0x07;
23static const uint8_t FT63X6_ADDR_TOUCH1_MISC = 0x08;
24static const uint8_t FT6X36_ADDR_THRESHHOLD = 0x80;
25static const uint8_t FT6X36_ADDR_TOUCHRATE_ACTIVE = 0x88;
26static const uint8_t FT63X6_ADDR_CHIP_ID = 0xA3;
28static const char *
const TAG =
"FT63X6";
49 uint8_t chip_id = this->
read_byte_(FT63X6_ADDR_CHIP_ID);
51 ESP_LOGI(TAG,
"FT6336U touch driver started chipid: %d", chip_id);
53 ESP_LOGE(TAG,
"FT6336U touch driver failed to start");
55 this->
write_byte(FT6X36_ADDR_DEVICE_MODE, 0x00);
57 this->
write_byte(FT6X36_ADDR_TOUCHRATE_ACTIVE, 0x0E);
69 ESP_LOGCONFIG(TAG,
"FT63X6 Touchscreen:");
74 " X Calibration: [%d, %d]\n"
75 " Y Calibration: [%d, %d]",
77 LOG_UPDATE_INTERVAL(
this);
84 ESP_LOGV(TAG,
"Touches found: %d", touches);
85 if ((touches == 0x00) || (touches == 0xff)) {
90 for (
auto point = 0; point < touches; point++) {
95 if ((
x == 0) && (
y == 0)) {
96 ESP_LOGW(TAG,
"Reporting a (0,0) touch on %d",
touch_id);
107 read_buf[0] = this->
read_byte_(FT63X6_ADDR_TOUCH1_X + (touch * 6));
108 read_buf[1] = this->
read_byte_(FT63X6_ADDR_TOUCH1_X + 1 + (touch * 6));
109 return ((read_buf[0] & 0x0f) << 8) | read_buf[1];
113 read_buf[0] = this->
read_byte_(FT63X6_ADDR_TOUCH1_Y + (touch * 6));
114 read_buf[1] = this->
read_byte_(FT63X6_ADDR_TOUCH1_Y + 1 + (touch * 6));
115 return ((read_buf[0] & 0x0f) << 8) | read_buf[1];
118 return this->
read_byte_(FT63X6_ADDR_TOUCH1_X + (touch * 6)) >> 6;
121 return this->
read_byte_(FT63X6_ADDR_TOUCH1_ID + (touch * 6)) >> 4;
124 return this->
read_byte_(FT63X6_ADDR_TOUCH1_WEIGHT + (touch * 6));
127 return this->
read_byte_(FT63X6_ADDR_TOUCH1_MISC + (touch * 6)) >> 4;
virtual void pin_mode(gpio::Flags flags)=0
virtual void digital_write(bool value)=0
int get_native_width()
Get the native (original) width of the display in pixels.
int get_native_height()
Get the native (original) height of the display in pixels.
uint16_t read_touch_y_(uint8_t touch)
void dump_config() override
uint8_t read_touch_misc_(uint8_t touch)
uint8_t read_touch_number_()
uint8_t read_touch_id_(uint8_t touch)
uint8_t read_touch_weight_(uint8_t touch)
uint8_t read_byte_(uint8_t addr)
uint16_t read_touch_x_(uint8_t touch)
void update_touches() override
uint8_t read_touch_event_(uint8_t touch)
InternalGPIOPin * interrupt_pin_
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
bool read_byte(uint8_t a_register, uint8_t *data, bool stop=true)
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.
display::Display * display_
void add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw=0)
Providing packet encoding functions for exchanging data with a remote host.
void IRAM_ATTR HOT delay(uint32_t ms)