2 #ifndef IOA_RESISTIVETOUCHSCREEN_H
3 #define IOA_RESISTIVETOUCHSCREEN_H
5 #include "PlatformDetermination.h"
7 #include <TaskManagerIO.h>
14 #ifndef TOUCH_THRESHOLD
15 #define TOUCH_THRESHOLD 0.05F
18 #define TOUCH_ORIENTATION_BIT_SWAP 0
19 #define TOUCH_ORIENTATION_BIT_INV_X 1
20 #define TOUCH_ORIENTATION_BIT_INV_Y 2
41 bitWrite(flags, TOUCH_ORIENTATION_BIT_SWAP, swapAxisXY);
42 bitWrite(flags, TOUCH_ORIENTATION_BIT_INV_X, xIsInverted);
43 bitWrite(flags, TOUCH_ORIENTATION_BIT_INV_Y, yIsInverted);
48 bool isOrientationSwapped()
const {
return bitRead(flags, TOUCH_ORIENTATION_BIT_SWAP);}
49 bool isXInverted()
const {
return bitRead(flags, TOUCH_ORIENTATION_BIT_INV_X);}
50 bool isYInverted()
const {
return bitRead(flags, TOUCH_ORIENTATION_BIT_INV_Y);}
72 mode = accelerate ? WAITING : NEVER_ACCELERATES;
76 if(mode == ACCELERATING) mode = WAITING;
97 void setCalibrationValues(
float mnX,
float mxX,
float mnY,
float mxY);
99 void enableCalibration(
bool state) {
100 calibrationOn = state;
103 float calibrateX(
float rawValue,
bool isInverted)
const;
105 float calibrateY(
float rawValue,
bool isInverted)
const;
107 float getMinX()
const {
return minX;}
108 float getMinY()
const {
return minY;}
109 float getMaxX()
const {
return maxX;}
110 float getMaxY()
const {
return maxY;}
111 void setXPosition(
float x,
bool isMax);
112 void setYPosition(
float y,
bool isMax);
127 #define portableFloatAbs(x) ((x)<0.0F?-(x):(x))
157 bool usedForScrolling =
false;
160 accelerationHandler(10,
true), calibrator(),
161 touchInterrogator(interrogator), touchMode(
NOT_TOUCHED), orientation(orientationSettings) {}
165 taskManager.execute(
this);
168 void setUsedForScrolling(
bool scrolling) {
169 usedForScrolling = scrolling;
172 void calibrateMinMaxValues(
float xmin,
float xmax,
float ymin,
float ymax) {
173 calibrator.setCalibrationValues(xmin, xmax, ymin, ymax);
178 void enableCalibration(
bool ena) {
179 calibrator.enableCalibration(ena);
186 void exec()
override;
213 pinid_t xpPin, xnPinAdc, ypPinAdc, ynPin;
217 : xpPin(xpPin), xnPinAdc(xnPin), ypPinAdc(ypPin), ynPin(ynPin) {}
229 float lastX, lastY, touchPressure;
236 void sendEvent(
float locationX,
float locationY,
float pressure,
TouchState touched)
override;
238 float getTouchPressure()
const {
return touchPressure; }
239 float getLastX()
const {
return lastX; }
240 float getLastY()
const {
return lastY; }
241 bool isPressed()
const {
return touchState ==
TOUCHED; }
242 TouchState getTouchState()
const {
return touchState; }
Contains a series of helper classes for dealing with analog devices, these are compatible across a wi...
TouchState
Definition: ResistiveTouchScreen.h:116
@ TOUCH_DEBOUNCE
Definition: ResistiveTouchScreen.h:124
@ TOUCHED
Definition: ResistiveTouchScreen.h:120
@ NOT_TOUCHED
Definition: ResistiveTouchScreen.h:118
@ HELD
Definition: ResistiveTouchScreen.h:122
AccelerationMode
Definition: ResistiveTouchScreen.h:54
Definition: ResistiveTouchScreen.h:64
Definition: ResistiveTouchScreen.h:86
Definition: ResistiveTouchScreen.h:211
TouchState internalProcessTouch(float *ptrX, float *ptrY, const TouchOrientationSettings &rotation, const CalibrationHandler &calibrator) override
Definition: ResistiveTouchScreen.cpp:103
Definition: ResistiveTouchScreen.h:134
virtual TouchState internalProcessTouch(float *ptrX, float *ptrY, const TouchOrientationSettings &settings, const CalibrationHandler &calib)=0
Definition: ResistiveTouchScreen.h:29
TouchOrientationSettings(bool swapAxisXY, bool xIsInverted, bool yIsInverted)
Definition: ResistiveTouchScreen.h:39
Definition: ResistiveTouchScreen.h:149
virtual void sendEvent(float locationX, float locationY, float touchPressure, TouchState touched)=0
Definition: ResistiveTouchScreen.h:227
void sendEvent(float locationX, float locationY, float pressure, TouchState touched) override
Definition: ResistiveTouchScreen.cpp:159