Skip to content

Configuring Touch for 4 wire

DavidCBarrett edited this page Jan 31, 2024 · 4 revisions

Overview > Configuring GUIslice > Touch >

Configuring 4-wire Simple Resistive Touch Handler

  • Touch mode selected by: DRV_TOUCH_ADA_SIMPLE

The 4-wire simple mode is intended for cheap TFT displays that have a 4-wire resistive touch overlay but no touch driver chip (like the STMPE610). To sample the raw touch readings the MCU (eg. Arduino) is responsible for driving certain voltages across 2 of the 4 pins and then performing an analog read of the remaining 2 pins. The software is also responsible for performing a remapping between the raw analog read values and the corresponding display coordinates.

Connection from MCU to Touchscreen

For the purposes of the touch interface, 4 additional pins are required between the MCU and the touchscreen overlay. Two of these pins must support analog read capability, whereas the other two can be digital IOs.

The pin connectivity is defined by the following configuration:

  • ADATOUCH_PIN_YP: Defines the Y+ pin, which must be an analog-capable pin (eg. A1)
  • ADATOUCH_PIN_XM: Defines the X- pin, which must be an analog-capable pin (eg. A2)
  • ADATOUCH_PIN_YM: Defines the Y- pin, which can be a digital pin (eg. 7)
  • ADATOUCH_PIN_XP: Defines the X+ pin, which can be a digital pin (eg. 6)
  • ADATOUCH_RX: Defines the rxplate, which is the measure of the resistance between the X+ and X- pins (default of 300 is usually OK)

Add the Adafruit TouchScreen libray to your project too (e.g. in platformio add adafruit/Adafruit TouchScreen@^1.1.5 to libdeps)

In order to detect these pin settings (on Arduino), please run the examples/arduino/diag_ard_touch_detect sketch.

Calibration

The 4-wire mode uses calibration settings that are specific to your display, described in the following configuration parameters:

  • ADATOUCH_X_MIN
  • ADATOUCH_X_MAX
  • ADATOUCH_Y_MIN
  • ADATOUCH_Y_MAX

In order to determine these calibration settings, please run the examples/arduino/diag_ard_touch_calib sketch.

Configuring touch sensitivity

The touch sensitivity can be defined by the following parameters. In most cases the default setting can be used.

  • ADATOUCH_PRESS_MIN
  • ADATOUCH_PRESS_MAX

Testing your display

Run examples/arduino/diag_ard_touch_test to assess whether the touch handling is operating correctly.

Clone this wiki locally