TouchScreenAdapter v0.5.0
TouchScreenAdapter is a library providing a unified touchscreen API.
Public Member Functions | List of all members
AdafruitResistiveTouchScreen Class Reference

Description

Concrete implementation of TouchScreenAdapter for Adafruit's resistive TouchScreen class.

Provides a number of class methods to 'tune-in' the mapping of the raw resistance values in X and Y mapped to the display's X and Y pixel position. This will need to be done for each screen/MCU combination.

The Z pressure can also be mapped but do not recommend this as the reported pressures are not very repeatable.

Resistive screens will never be as consistent as capacitive ones but Some screen and board combinations work better than other - I suspect this is due to better pullup resistors.

#include <AdafruitResistiveTouchScreen.h>

Inheritance diagram for AdafruitResistiveTouchScreen:
Inheritance graph
[legend]

Public Member Functions

 AdafruitResistiveTouchScreen (uint8_t pinXPos, uint8_t pinYPos, uint8_t pinXNeg, uint8_t pinYNeg, uint16_t ohms=300, uint16_t displayWidth=240, uint16_t displayHeight=320)
 Construct a new Resistive Touch Screen object. More...
 
 ~AdafruitResistiveTouchScreen ()
 Destroy the AdafruitResistiveTouchScreen object.
 
TouchScreenAdapter::TouchPoint getTouchPoint (void)
 Get the TouchPoint struct. More...
 
TouchScreenAdapter::TouchPoint getTouchPointRaw (void)
 Get the raw TouchPoint struct. More...
 
bool begin (void)
 Empty begin() implementation. More...
 
void setMinRawY (uint16_t limit)
 Set the minimun raw Y value. More...
 
void setMinRawX (uint16_t limit)
 Set the minimun raw X value. More...
 
void setMaxRawX (uint16_t limit)
 Set the maximum raw X value. More...
 
void setMaxRawY (uint16_t limit)
 Set the maximum raw Y value. More...
 
void setMinRawZ (uint16_t limit)
 Set the maximum raw Z value. More...
 
void setMaxRawZ (uint16_t limit)
 Set the maximum raw Z value. More...
 
- Public Member Functions inherited from TouchScreenAdapter
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...
 

Additional Inherited Members

- Protected Attributes inherited from TouchScreenAdapter
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.
 

Constructor & Destructor Documentation

◆ AdafruitResistiveTouchScreen()

AdafruitResistiveTouchScreen::AdafruitResistiveTouchScreen ( uint8_t  pinXPos,
uint8_t  pinYPos,
uint8_t  pinXNeg,
uint8_t  pinYNeg,
uint16_t  ohms = 300,
uint16_t  displayWidth = 240,
uint16_t  displayHeight = 320 
)
inline

Construct a new Resistive Touch Screen object.

Parameters
pinXPoscan be a digital pin
pinYPosMust be an analog pin, use "An" notation!
pinXNegmust be an analog pin, use "An" notation!
pinYNegcan be a digital pin
ohmsMeasurement of ohms between pinXPos and PinXNeg (default 300). Can improve touch accuracy.
displayWidthNative width of display with no rotation set (default 240)
displayHeightNative height of display with no rotation set (default 320)

Member Function Documentation

◆ begin()

bool AdafruitResistiveTouchScreen::begin ( void  )
inlinevirtual

Empty begin() implementation.

Returns
true Always.
false Never.

Implements TouchScreenAdapter.

◆ getTouchPoint()

TouchScreenAdapter::TouchPoint AdafruitResistiveTouchScreen::getTouchPoint ( void  )
inlinevirtual

Get the TouchPoint struct.

The TouchPoint is populated with X and Y mapped from the raw resistance values to display pixel position.

Returns
TouchScreenAdapter::TouchPoint

Implements TouchScreenAdapter.

◆ getTouchPointRaw()

TouchScreenAdapter::TouchPoint AdafruitResistiveTouchScreen::getTouchPointRaw ( void  )
inlinevirtual

Get the raw TouchPoint struct.

The TouchPoint is populated with the raw resistance values from the Adafruit TouchScreen library.

Use these values to measure and set the raw min/max X and Y values.

Returns
TouchScreenAdapter::TouchPoint

Implements TouchScreenAdapter.

◆ setMaxRawX()

void AdafruitResistiveTouchScreen::setMaxRawX ( uint16_t  limit)
inline

Set the maximum raw X value.

Parameters
limitThe maximum X value reported by getTouchPointRaw()

◆ setMaxRawY()

void AdafruitResistiveTouchScreen::setMaxRawY ( uint16_t  limit)
inline

Set the maximum raw Y value.

Parameters
limitThe maximum Y value reported by getTouchPointRaw()

◆ setMaxRawZ()

void AdafruitResistiveTouchScreen::setMaxRawZ ( uint16_t  limit)
inline

Set the maximum raw Z value.

Parameters
limitThe maximum Z value reported by getTouchPointRaw()

◆ setMinRawX()

void AdafruitResistiveTouchScreen::setMinRawX ( uint16_t  limit)
inline

Set the minimun raw X value.

Parameters
limitThe minimum X value reported by getTouchPointRaw()

◆ setMinRawY()

void AdafruitResistiveTouchScreen::setMinRawY ( uint16_t  limit)
inline

Set the minimun raw Y value.

Parameters
limitThe minimum Y value reported by getTouchPointRaw()

◆ setMinRawZ()

void AdafruitResistiveTouchScreen::setMinRawZ ( uint16_t  limit)
inline

Set the maximum raw Z value.

Parameters
limitThe maximum Z value reported by getTouchPointRaw()

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