By dave | October 12, 2021

This touch screen input plugin supports both XPT2046 and FT6206 based touch screens. In order for this plugin to work correctly the right underlying library must be installed. These are described below:

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

You should note that this plugin can only be used with graphical display renderers. You can also read the IoAbstraction touch screen documentation as this support is based on that.

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 touch screen plugin, you’ll need to configure the plugin for use, this includes choosing the right library and working out the correct rotation that aligns with your display, the easiest way to do this is to use the test sketch that’s packaged with IoAbstraction.

Properties for library based touch screen:

  • Rotation - choose the rotation that matches your screen layout.
  • Touch Library - choose the library that you wish to integrate with. As above, the library must be installed.
  • Touch interrupt pin - XPT2046 library only, the interrupt pin to avoid polling.
  • Touch CS pin - XPT2046 library only, the CS pin for the SPI 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 calibrate the touch screen, you can use our calibration “extra”, see the ESP32Amplifier example that shows how to use it.

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

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.

Send a message
X

Please use the forum for help with UI & libraries.

This message will be securely transmitted to Nutricherry LTD servers.