2022-10-10 23:10:27 +02:00
|
|
|
XPT2046 Touch Screen Controller (Updated version)
|
|
|
|
==================================================
|
2021-05-17 03:04:12 +02:00
|
|
|
|
|
|
|
.. seo::
|
|
|
|
:description: Instructions for setting up XPT2046 touch screen controller with ESPHome
|
|
|
|
:image: xpt2046.jpg
|
|
|
|
:keywords: XPT2046
|
|
|
|
|
|
|
|
.. _xpt2046-component:
|
|
|
|
|
2022-10-10 23:10:27 +02:00
|
|
|
The ``xpt2046`` touchscreen platform allows using the touch screen controllers
|
2021-05-17 03:04:12 +02:00
|
|
|
based on the XPT2046 chip
|
|
|
|
(`datasheet <https://datasheetspdf.com/pdf-file/746665/XPTEK/XPT2046/1>`__,
|
|
|
|
`AZ-Delivery`_) with ESPHome. Many cheap LCD displays contain this controller.
|
|
|
|
The :ref:`SPI <spi>` is required to be set up in your configuration for this sensor to work.
|
|
|
|
|
|
|
|
.. figure:: images/xpt2046-full.jpg
|
|
|
|
:align: center
|
|
|
|
:width: 50.0%
|
|
|
|
|
|
|
|
XPT2046 Touch Screen Controller
|
|
|
|
|
|
|
|
.. _AZ-Delivery: https://www.az-delivery.de/en/products/2-4-tft-lcd-touch-display
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Example configuration entry
|
2022-10-10 23:10:27 +02:00
|
|
|
touchscreen:
|
|
|
|
platform: xpt2046
|
2022-10-30 17:45:17 +01:00
|
|
|
id: my_touchscreen
|
2024-05-07 07:40:12 +02:00
|
|
|
cs_pin: GPIOXX
|
|
|
|
interrupt_pin: GPIOXX
|
2021-05-17 03:04:12 +02:00
|
|
|
update_interval: 50ms
|
|
|
|
threshold: 400
|
2024-01-03 17:01:11 +01:00
|
|
|
calibration:
|
|
|
|
x_min: 3860
|
|
|
|
x_max: 280
|
|
|
|
y_min: 340
|
|
|
|
y_max: 3860
|
2021-05-17 03:04:12 +02:00
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
------------------------
|
|
|
|
The configuration is made up of two parts: The touch screen component, and optional individual binary sensors.
|
|
|
|
|
|
|
|
Base Configuration:
|
|
|
|
|
|
|
|
- **id** (*Optional*, :ref:`config-id`): Set the ID of this sensor.
|
|
|
|
|
|
|
|
- **cs_pin** (*Optional*, :ref:`Pin Schema <config-pin_schema>`): The chip select pin.
|
|
|
|
Often marked ``T_CS`` on the board.
|
|
|
|
|
2022-10-30 15:38:28 +01:00
|
|
|
- **interrupt_pin** (*Optional*, :ref:`Pin Schema <config-pin_schema>`): The touch detection pin.
|
2021-05-17 03:04:12 +02:00
|
|
|
Often marked ``T_IRQ`` on the board. If not specified the component will use polling
|
2022-10-10 23:10:27 +02:00
|
|
|
via SPI. This key is renamed from **irq_pin**
|
2021-05-17 03:04:12 +02:00
|
|
|
|
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The interval to check the
|
2023-01-24 18:56:46 +01:00
|
|
|
sensor. If ``interrupt_pin`` is specified the touch will be detected nearly instantaneously and this setting
|
2021-05-17 03:04:12 +02:00
|
|
|
will be used only for the release detection. Defaults to ``50ms``.
|
|
|
|
|
2021-11-28 19:57:01 +01:00
|
|
|
- **threshold** (*Optional*, int): The value to detect the touch or release. Defaults to ``400``.
|
2021-05-17 03:04:12 +02:00
|
|
|
|
|
|
|
|
2024-01-03 17:01:11 +01:00
|
|
|
- **calibration_x_min** (*Depricated*): This value is moved to the ``calibration`` values
|
2021-05-17 03:04:12 +02:00
|
|
|
|
2024-01-03 17:01:11 +01:00
|
|
|
- **calibration_x_max** (*Depricated*): This value is moved to the ``calibration`` values.
|
2021-05-17 03:04:12 +02:00
|
|
|
|
2024-01-03 17:01:11 +01:00
|
|
|
- **calibration_y_min** (*Depricated*): This value is moved to the ``calibration`` values.
|
2021-05-17 03:04:12 +02:00
|
|
|
|
2024-01-03 17:01:11 +01:00
|
|
|
- **calibration_y_max** (*Depricated*): This value is moved to the ``calibration`` values.
|
2021-05-17 03:04:12 +02:00
|
|
|
|
2024-01-03 17:01:11 +01:00
|
|
|
- **swap_x_y** (*Depricated*): This value is moved to the ``transform`` values as ``swap_xy`` see :ref:`config-touchscreen`.
|
2021-05-17 03:04:12 +02:00
|
|
|
|
2024-01-03 17:01:11 +01:00
|
|
|
- **report_interval** (*Depricated*): This interval is removed in favor of the ``update_interval``.
|
2021-05-17 03:04:12 +02:00
|
|
|
|
2024-01-03 17:01:11 +01:00
|
|
|
- All other options from :ref:`config-touchscreen`.
|
2021-05-17 03:04:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
|
|
|
- :ref:`Binary Sensor Filters <binary_sensor-filters>`
|
|
|
|
- :apiref:`xpt2046/xpt2046.h`
|
|
|
|
- `XPT2046 Library <https://platformio.org/lib/show/542/XPT2046_Touchscreen>`__ by `Paul Stoffregen <https://github.com/PaulStoffregen>`__
|
|
|
|
- :ghedit:`Edit`
|