![]() |
TouchScreenAdapter v0.5.0
TouchScreenAdapter is a library providing a unified touchscreen API.
|
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>
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... | |
![]() | |
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 | |
![]() | |
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. | |
|
inline |
Construct a new Resistive Touch Screen object.
pinXPos | can be a digital pin |
pinYPos | Must be an analog pin, use "An" notation! |
pinXNeg | must be an analog pin, use "An" notation! |
pinYNeg | can be a digital pin |
ohms | Measurement of ohms between pinXPos and PinXNeg (default 300). Can improve touch accuracy. |
displayWidth | Native width of display with no rotation set (default 240) |
displayHeight | Native height of display with no rotation set (default 320) |
|
inlinevirtual |
|
inlinevirtual |
Get the TouchPoint struct.
The TouchPoint is populated with X and Y mapped from the raw resistance values to display pixel position.
Implements TouchScreenAdapter.
|
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.
Implements TouchScreenAdapter.
|
inline |
Set the maximum raw X value.
limit | The maximum X value reported by getTouchPointRaw() |
|
inline |
Set the maximum raw Y value.
limit | The maximum Y value reported by getTouchPointRaw() |
|
inline |
Set the maximum raw Z value.
limit | The maximum Z value reported by getTouchPointRaw() |
|
inline |
Set the minimun raw X value.
limit | The minimum X value reported by getTouchPointRaw() |
|
inline |
Set the minimun raw Y value.
limit | The minimum Y value reported by getTouchPointRaw() |
|
inline |
Set the maximum raw Z value.
limit | The maximum Z value reported by getTouchPointRaw() |