### The problem
I brought this board : https://s.click.aliexpress.com/e/_DnD2p7…L
and I had configured the touch with calibration somewhere in september 2023.
Now since yesterday I tried updating to the latest version of esphome i.e 2024.2.2 and I see some options have changed.
I updated the changes but since then my touch direction are always opposite or diagnol direction.
I am trying to calibrate the touch screen and I tried all the combination of transform option. (mirror_x, mirror_y, swap_x_y)
Finally I figured out the that mirror_x under transform does not change orientation of the touch.
Also as per the documentation calibration has its own section now. https://esphome.io/components/touchscreen/#config-touchscreen
but when I use it it gives compilation error that calibration does not exists and the old calibration fields like `calibration_x_min` only works.
I tried all possible combination of transform and calibration_x_min / calibration_y_min.
but it does not give me correct touch value on the screen.
Finally I reached this yaml, where in the touch on the bottom left and top right is correct.
But the touch on the top left and bottom right are wrong.
```
captive_portal:
web_server:
port: 80
##### Visual settings
font:
- file:
type: gfonts
family: Mulish
weight: medium
id: mulish
size: 30
########### CONNECTIONS
spi:
- id: screen
clk_pin: 14
mosi_pin: 13
miso_pin: 12
- id: touch
clk_pin: 25
mosi_pin: 32
miso_pin: 39
touchscreen:
id: my_touchscreen
platform: xpt2046
spi_id: touch
cs_pin: 33
interrupt_pin: 36
update_interval: 50ms
# report_interval: 1s
threshold: 400
calibration_x_min: 3860
calibration_x_max: 280
calibration_y_max: 340
calibration_y_min: 3860
transform:
mirror_x: false
mirror_y: false
swap_xy: false
on_touch:
- lambda: |-
ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%d",
touch.x,
touch.y,
touch.x_raw,
touch.y_raw
);
display:
- platform: ili9xxx
model: ILI9341
spi_id: screen
cs_pin: 15
dc_pin: 2
# reset_pin: en
rotation: 90
lambda: |-
auto touch = id(my_touchscreen) -> get_touch();
auto red = Color(255, 0, 0);
auto orange = Color(255, 0, 0);
auto green = Color(0, 255, 0);
auto blue = Color(0, 0, 255);
auto white = Color(255, 255, 255);
it.fill(orange);
it.print(10, 100, id(mulish), "Test Smart Home Circle");
if (touch) {
it.filled_circle(touch.value().x, touch.value().y, 30, white);
ESP_LOGI("Test", "x=%d, y=%d",touch.value().x, touch.value().y);
}
########## Display LED
# Define a PWM output on the ESP32
output:
- platform: ledc
pin: 21 #display LED
id: gpio_21_backlight_pwm
############ Light Controls
# Define a monochromatic, dimmable light for the backlight
light:
- platform: monochromatic
output: gpio_21_backlight_pwm
name: "Display Brightness"
id: back_light
restore_mode: ALWAYS_ON
```
This touch was working fine and well calibrated somewhere in sept 2023. But then I dint use the display today after updating the display, with the new changes, I started facing problems.
Can someone help me out here?
I am sure there is some bug in the updated touch screen XPT2046 code, as this was all working fine in sept 2023.
### Which version of ESPHome has the issue?
2024.2.2
### What type of installation are you using?
Docker
### Which version of Home Assistant has the issue?
_No response_
### What platform are you using?
ESP32
### Board
_No response_
### Component causing the issue
_No response_
### Example YAML snippet
```yaml
captive_portal:
web_server:
port: 80
##### Visual settings
font:
- file:
type: gfonts
family: Mulish
weight: medium
id: mulish
size: 30
########### CONNECTIONS
spi:
- id: screen
clk_pin: 14
mosi_pin: 13
miso_pin: 12
- id: touch
clk_pin: 25
mosi_pin: 32
miso_pin: 39
touchscreen:
id: my_touchscreen
platform: xpt2046
spi_id: touch
cs_pin: 33
interrupt_pin: 36
update_interval: 50ms
# report_interval: 1s
threshold: 400
calibration_x_min: 3860
calibration_x_max: 280
calibration_y_max: 340
calibration_y_min: 3860
transform:
mirror_x: false
mirror_y: false
swap_xy: false
on_touch:
- lambda: |-
ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%d",
touch.x,
touch.y,
touch.x_raw,
touch.y_raw
);
display:
- platform: ili9xxx
model: ILI9341
spi_id: screen
cs_pin: 15
dc_pin: 2
# reset_pin: en
rotation: 90
lambda: |-
auto touch = id(my_touchscreen) -> get_touch();
auto red = Color(255, 0, 0);
auto orange = Color(255, 0, 0);
auto green = Color(0, 255, 0);
auto blue = Color(0, 0, 255);
auto white = Color(255, 255, 255);
it.fill(orange);
it.print(10, 100, id(mulish), "Test Smart Home Circle");
if (touch) {
it.filled_circle(touch.value().x, touch.value().y, 30, white);
ESP_LOGI("Test", "x=%d, y=%d",touch.value().x, touch.value().y);
}
########## Display LED
# Define a PWM output on the ESP32
output:
- platform: ledc
pin: 21 #display LED
id: gpio_21_backlight_pwm
############ Light Controls
# Define a monochromatic, dimmable light for the backlight
light:
- platform: monochromatic
output: gpio_21_backlight_pwm
name: "Display Brightness"
id: back_light
restore_mode: ALWAYS_ON
```
```
### Anything in the logs that might be useful for us?
```txt
here is log for the touch calibration.
top left
[I][cal:085]: x=29, y=17, x_raw=3527, y_raw=3602
[W][component:214]: Component display took a long time for an operation (0.09 s).
[W][component:215]: Components should block for at most 20-30ms.
[W][component:214]: Component display took a long time for an operation (0.09 s).
[W][component:215]: Components should block for at most 20-30ms.
bottom left
[I][cal:085]: x=288, y=24, x_raw=630, y_raw=3498
[W][component:214]: Component display took a long time for an operation (0.09 s).
[W][component:215]: Components should block for at most 20-30ms.
[W][component:214]: Component display took a long time for an operation (0.09 s).
[W][component:215]: Components should block for at most 20-30ms.
botom right
[I][cal:085]: x=283, y=202, x_raw=691, y_raw=888
[W][component:214]: Component display took a long time for an operation (0.09 s).
[W][component:215]: Components should block for at most 20-30ms.
[W][component:214]: Component display took a long time for an operation (0.09 s).
[W][component:215]: Components should block for at most 20-30ms.
top right
[I][cal:085]: x=33, y=227, x_raw=3487, y_raw=519
```
```
### Additional information
_No response_