TS library is for the 4-wire resistive Touch Screen (without an interface) which is usually included on TFT LCD like are MCUFriend displays.
Revision 1:ca8fdb4d4afc, committed 2021-01-17
- Comitter:
- JohnnyK
- Date:
- Sun Jan 17 15:58:15 2021 +0000
- Parent:
- 0:f2fda7f69e5a
- Commit message:
- Corrections - include guards was added
Changed in this revision
diff -r f2fda7f69e5a -r ca8fdb4d4afc TS.h --- a/TS.h Mon Nov 02 21:14:08 2020 +0000 +++ b/TS.h Sun Jan 17 15:58:15 2021 +0000 @@ -20,7 +20,7 @@ #define XP D8 #define RD A0 -TS_config config = {2955,325,3070,470,240,320}; +TS_config config = {2955,325,3070,470,240,320}; // that are minimum and maxim mV for all axis TouchScreen ts(YP,YM,XP,XM,config); int main() @@ -40,6 +40,9 @@ * @/code */ +#ifndef TS_H +#define TS_H + #include "TS_porting.h" struct TS_point{ @@ -65,13 +68,14 @@ }; + struct TS_config{ - unsigned int TS_adc_Xmax, - TS_adc_Xmin, - TS_adc_Ymax, - TS_adc_Ymin, - TFTWIDTH, - TFTHEIGHT; + unsigned int TS_adc_Xmax, // max value for X in mV + TS_adc_Xmin, // max value for X in mV + TS_adc_Ymax, // max value for Y in mV + TS_adc_Ymin, // min value for Y in mV + TFTWIDTH, // Display width + TFTHEIGHT; // Display height }; @@ -96,7 +100,7 @@ /** Set the orientation * - * @param orientation It is set via the struct TS_Orientation + * @param orientation It is set via the TS_Orientation enum * TS_PORTRAITE(default), TS_LANDSCAPE,TS_PORTRAITE_REV and TS_LANDSCAPE_REV */ void setOrientation(TS_Orientation orientation); @@ -130,4 +134,4 @@ /** ADC Y value normalization*/ float nrm_adcY(unsigned int y); }; - +#endif \ No newline at end of file
diff -r f2fda7f69e5a -r ca8fdb4d4afc TS_porting.cpp --- a/TS_porting.cpp Mon Nov 02 21:14:08 2020 +0000 +++ b/TS_porting.cpp Sun Jan 17 15:58:15 2021 +0000 @@ -1,7 +1,5 @@ #include "TS_porting.h" -#include "mbed.h" - int TouchScreenPort::getADCvalue(int pin){ return AnalogIn((PinName)pin).read() * 3300; }
diff -r f2fda7f69e5a -r ca8fdb4d4afc TS_porting.h --- a/TS_porting.h Mon Nov 02 21:14:08 2020 +0000 +++ b/TS_porting.h Sun Jan 17 15:58:15 2021 +0000 @@ -1,6 +1,15 @@ - -class TouchScreenPort{ - protected: - int getADCvalue(int pin); - void setDigitalPin(int pin, int dir, int value); +/* +* Mbed implementation but teory is it can be used also on another platform, I hope. +*/ + +#ifndef TS_PORTING_H +#define TS_PORTING_H + +#include "mbed.h" + +class TouchScreenPort{ + protected: + int getADCvalue(int pin); + void setDigitalPin(int pin, int dir, int value); }; +#endif \ No newline at end of file