By dave | January 12, 2021

Requires tcMenu V2.0 or greater.

TcMenu resistive touch screen input plugin supports four wire resistive touch devices that are often fitted in front of color TFT displays. This plugin requires two ADC analog inputs, but note that all pins must be output capable. The connectors are often referred to as X+, X-, Y+ and Y-. In all cases X- and Y+ must be connected to ADC (analog input) capable pins.

When using this touch unit, the concept of touching and holding touches is handled by the unit itself, even managing “repeat key” is handled by the library in an appropriate manner, based on which mode it is in.

You should note that this plugin can only be used with display renderers based on core graphical renderer, as of 2.0 this will be nearly all renderers.

Configuring for your system

First, ensure your menu structure is saved and then choose Code -> Generate Code from the menu. Once the code generation dialog appears, you can click on the image below the input plugin selection, and you’ll see the two below options in the list:

Choices for switches and rotary encoder

Choices for switches and rotary encoder

Once you’ve chosen the resistive touch screen plugin, you’ll need to configure the plugin for use, this includes working out the resistive ranges and how they map onto the screen, the easiest way to do this is to use the test sketch that’s packaged with IoAbstraction. You provide the minimum and maximum values in both the X and Y directions as floating-point fractions between 0 and 1.

Properties for resistive touch screen:

  • X+ is the pin connected to X+ of the resistive touch unit
  • X- is the pin connected to X- of the resistive touch unit - needs ADC
  • Y+ is the pin connected to Y+ of the resistive touch unit
  • Y- is the pin connected to Y- of the resistive touch unit - needs ADC
  • Touch Rotation allows you to match rotation of the screen with the touch interface.

Working with the touch interface in code

When you use this plugin, it will create a variable called touchScreen on your behalf, it will be of type MenuResistiveTouchScreen. It will be exported so that you can use it in your code.

To set the range of values (min, max) in both dimensions you first run the packaged example in IoAbstraction, this allows you to touch in the very edges and find the actual range, it outputs the raw touch events to the serial port, once you have them, you can provide calibration data as follows:

touchScreen.calibrateMinMaxValues(float xmin, float xmax, float ymin, float ymax)

For each dimension, min and max are the minimum and maximum values possible in that dimension, BEFORE any rotation is applied.

Other pages within this category

comments powered by Disqus

We use cookies to analyse traffic and to personalise content. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Please see our privacy policy should you need more information or wish to adjust your settings.