TouchScreenAdapter v0.5.0
TouchScreenAdapter is a library providing a unified touchscreen API.
Classes | Public Member Functions | Protected Attributes | List of all members
TouchScreenAdapter Class Referenceabstract

Description

A lightweight abstract Abstract class for touch screen panels.

#include <TouchScreenAdapter.h>

Inheritance diagram for TouchScreenAdapter:
Inheritance graph
[legend]

Classes

struct  TouchPoint
 A consistent struct containing points X & Y plus Z as pressure. More...
 

Public Member Functions

void setDisplayWidth (uint16_t widthPx)
 Set the native (non-rotated) display width (X) in pixels. More...
 
void setDisplayHeight (uint16_t heightPx)
 Set the native (non-rotated) display height (Y) in pixels. More...
 
virtual TouchScreenAdapter::TouchPoint getTouchPoint (void)=0
 Get the TouchPoint object. More...
 
virtual TouchScreenAdapter::TouchPoint getTouchPointRaw (void)=0
 Get a TouchPoint struct containing raw values from the underlying library. More...
 
virtual bool begin (void)=0
 For compatibility with the Arduino library convention. More...
 
void setRotation (uint8_t r)
 Set the rotation touch screen. More...
 

Protected Attributes

uint8_t rotation = 0
 The current rotation of the touch panel. Default is 0 (native orientation).
 
uint16_t DISPLAY_WIDTH = 240
 The non-rotated width of the display in pixels.
 
uint16_t DISPLAY_HEIGHT = 320
 The non-rotated height of the display in pixels.
 
uint16_t displayWidth = DISPLAY_WIDTH
 The (optionally rotated) width of the display in pixels.
 
uint16_t displayHeight = DISPLAY_HEIGHT
 The (optionally rotated) height of the display in pixels.
 

Member Function Documentation

◆ begin()

virtual bool TouchScreenAdapter::begin ( void  )
pure virtual

For compatibility with the Arduino library convention.

Must be implemented (but can be empty) as some touch libraries require it. Can return a boolean to idicate if initialisation has failed.

Returns
true The initialisation was successful.
false The initialisation was failed.

Implemented in AdafruitFT6206TouchScreen, and AdafruitResistiveTouchScreen.

◆ getTouchPoint()

virtual TouchScreenAdapter::TouchPoint TouchScreenAdapter::getTouchPoint ( void  )
pure virtual

Get the TouchPoint object.

Returns a TouchPoint. Display are x & y populated (ie non-zero) only if touched.

Returns
TouchPoint

Implemented in AdafruitFT6206TouchScreen, and AdafruitResistiveTouchScreen.

◆ getTouchPointRaw()

virtual TouchScreenAdapter::TouchPoint TouchScreenAdapter::getTouchPointRaw ( void  )
pure virtual

Get a TouchPoint struct containing raw values from the underlying library.

Returns a TouchPoint with raw x, y & z populated from the underlying library. For most panels this will usually return the same values as getTouchPoint() but can be useful for tuning resistive panels. Note: This will return a populated TouchPoint irrespective of the Z value. Generally used for setup or debugging.

Returns
TouchPoint

Implemented in AdafruitFT6206TouchScreen, and AdafruitResistiveTouchScreen.

◆ setDisplayHeight()

void TouchScreenAdapter::setDisplayHeight ( uint16_t  heightPx)
inline

Set the native (non-rotated) display height (Y) in pixels.

Is set to 320 by default. For some adapters (resistive) this must be set to the native height of your display. For adapters that report pixel position directly, this is only used to reverse X or Y.

Parameters
heightPxWidth in pixels

◆ setDisplayWidth()

void TouchScreenAdapter::setDisplayWidth ( uint16_t  widthPx)
inline

Set the native (non-rotated) display width (X) in pixels.

Is set to 240 by default. For some adapters (resistive) this must be set to the native width of your display. For adapters that report pixel position directly, this is only reqired if X and/or Y need to be reversed. (Ahem, FT6206).

Parameters
widthPxWidth in pixels

◆ setRotation()

void TouchScreenAdapter::setRotation ( uint8_t  r)
inline

Set the rotation touch screen.

This should be called at the same time the display rotation is set.

Parameters
rFollows the convention of:
  • 0 = native orientation
  • 1 = 90degrees from native
  • 2 = 180degrees from native
  • 3 = 270degrees from native

The documentation for this class was generated from the following file: