Skip to content

Stutchbury/TouchScreenAdapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TouchScreenAdapter

TouchScreenAdapter is a library providing a unified touchscreen API. Included are implementations for typical touchscreen types: 4-wire resistive and capacitive.

The library provides a consistent TouchPoint structure, containing X & Y translated to display coordinates (even for resistive screens) and Z for touch/pressure where 0 = 'not touched' and >0 = 'touched'. Where available, pressure will be reported in the range 1-255.

Its primary use is for the EventTouchScreen library (that will become part of InputEvents) but is also very effective as a source for an LVGL input device: lv_indev_t.

The Adapter Class

The abstract TouchScreenAdapter class specifies the following methods:

  • void begin() - required for Arduino compatibility.
  • TouchScreenAdapter::TouchPoint getTouchPoint() - returns a TouchScreenAdapter::TouchPoint with X & Y display coordinates with Z where 0 is not touched and >= 1 is touched.
  • TouchScreenAdapter::TouchPoint getTouchPointRaw() - returns a TouchScreenAdapter::TouchPoint with raw Y, Y and Z coordinates.
  • void setDisplayWidth(uint16_t width) Set the display width. Required for resistive touch or if reversing X and/or Y is necessary.
  • void setDisplayHeight(uint16_t height) Set the display height. Required for resistive touch or if reversing X and/or Y is necessary.
  • void setRotation(uint8_t rotation) Rotate the touch panel as required.

Concrete Classes

Concrete implementations provide a constructor suitable for the underlying library and any additional methods required to configure the touch panel.

Adapter classes are fairly trivial to create but must be 'header only' to allow Arduino IDE to compile without error when the underlying libraries are not installed. Pull requests are most welcome.

The concrete classes currently provided are:

  • AdafruitResistiveTouchScreen - resistive, using Adafruit's TouchScreen library.
  • AdafruitFT6206TouchScreen - I2C, using Adafruit's FT6206 library.

Source Code

The TouchScreenAdapter Library is available via the Arduino IDE or PlatformIO Library Managers by searching for 'TouchScreenAdapter'.

Please see full Doxygen generated API documentation for more information.

Dependencies

Although this library lists no dependencies, it will be dependent on whichever underlying touch screen library that the chosen adapter uses.

Support

Feedback, pull requests and bug reports are welcome or chat on the InputEvents Discord channel if you have any questions.

About

The TouchScreenAdapter library provides a unified API for interacting with different types of touchscreens, including resistive and capacitive.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages