Skip to content

Commit fe4336b

Browse files
committed
example updates
1 parent dea812a commit fe4336b

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

examples/touchScreen/touchScreen.ino

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@
2626

2727
using namespace iotouch;
2828

29-
// the touch screen itself
29+
/*
30+
* the touch screen itself, you need to provide the pins on which the resistive screen is attached, see the help for
31+
* more information, as some pins must be output capable.
32+
*
33+
* For the orientation, you need to provide three booleans:
34+
* 1. XY are inverted if true, otherwise false
35+
* 2. the raw X value is inverted
36+
* 3, the raw Y value is inverted
37+
*/
38+
3039
ResistiveTouchInterrogator interrogator(XPOS_PIN, XNEG_PIN, YPOS_PIN, YNEG_PIN);
31-
ValueStoringResistiveTouchScreen touchScreen(interrogator, TouchInterrogator::PORTRAIT);
40+
ValueStoringResistiveTouchScreen touchScreen(interrogator, TouchOrientationSettings(false, true, true));
3241

3342
// couple of display options here, anything with a touch interface attached!
3443
//Adafruit_ST7735 gfx(MY_CS, MY_DC, MY_RST);

examples/touchScreenFT6206Lib/touchScreenFT6206Lib.ino

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
//
2929

3030
// For Paul Stoffregen's touch screen XPT2046 (or ThingPulse fork)
31-
#include <XPT2046_Touchscreen.h>
32-
#define TOUCH_CLASS XPT2046_Touchscreen
33-
#define CS_PIN 5
34-
XPT2046_Touchscreen touchDevice(CS_PIN, 0xFF);
31+
//#include <XPT2046_Touchscreen.h>
32+
//#define TOUCH_CLASS XPT2046_Touchscreen
33+
//#define CS_PIN 5
34+
//XPT2046_Touchscreen touchDevice(CS_PIN, 0xFF);
3535
//end XPT2046
3636

3737
// For Adafruit's FT6206 touch screen library
38-
//#include <Adafruit_FT6206>
39-
//#define TOUCH_CLASS Adafruit_FT6206
40-
//Adafruit_FT6206 touchDevice;
38+
#include <Adafruit_FT6206.h>
39+
#define TOUCH_CLASS Adafruit_FT6206
40+
Adafruit_FT6206 touchDevice;
4141
// end FT6206
4242

4343

@@ -60,13 +60,13 @@ public:
6060
// * if there is a touch, the reading should be obtained, and converted into floating points value between 0 and 1
6161
// * these x and y values should be run through the calibrator and used to set the pointers to x and y passed in
6262
// * lastly you should return TOUCHED to indicate a touch as taken place.
63-
TouchState internalProcessTouch(float *ptrX, float *ptrY, TouchRotation rotation, const CalibrationHandler& calib) {
63+
TouchState internalProcessTouch(float *ptrX, float *ptrY, const TouchOrientationSettings& orientationSettings, const CalibrationHandler& calib) {
6464
if(theTouchDevice.touched() == 0) return NOT_TOUCHED;
6565

6666
TS_Point pt = theTouchDevice.getPoint();
6767

68-
*ptrX = calib.calibrateX(float(pt.x) / KNOWN_DEVICE_TOUCH_RANGE, false);
69-
*ptrY = calib.calibrateY(float(pt.y) / KNOWN_DEVICE_TOUCH_RANGE, false);
68+
*ptrX = calib.calibrateX(float(pt.x) / KNOWN_DEVICE_TOUCH_RANGE, orientationSettings.isXInverted());
69+
*ptrY = calib.calibrateY(float(pt.y) / KNOWN_DEVICE_TOUCH_RANGE, orientationSettings.isYInverted());
7070
return TOUCHED;
7171
}
7272
} interrogator(touchDevice);
@@ -76,12 +76,21 @@ public:
7676
* interface. In the simplest case you can use the ValueStoringResistiveTouchScreen, but you can also extend from
7777
* ResistiveTouchScreen, see the reference documentation for more on this.
7878
*
79-
* Notice that we pass in the above created "glue" interrogator and the desired rotation.
79+
* Notice that we pass in the above created "glue" interrogator and the desired orientation, the three parameters to
80+
* the orientation:
81+
* 1. XY are inverted if true, otherwise false
82+
* 2. the raw X value is inverted
83+
* 3, the raw Y value is inverted
8084
*/
81-
ValueStoringResistiveTouchScreen touchScreen(interrogator, TouchInterrogator::PORTRAIT);
85+
ValueStoringResistiveTouchScreen touchScreen(interrogator, TouchOrientationSettings(false, true, true));
8286

8387
void setup() {
8488
Serial.begin(115200);
89+
90+
// depending on your board, adjust as needed.
91+
//Wire.begin();
92+
Wire.begin(5, 4);
93+
8594
// first start the underlying touch library
8695
touchDevice.begin();
8796

0 commit comments

Comments
 (0)