Library for SeeedStudioTFTv2 2.8 Zoll 240x360 pixel touch SD card
Dependencies: SPI_TFT_ILI9341
Dependents: Seeed_TFT_Touch_Shield Seeed_TFT_Touch_Shield Adafruit_TFT_Touch_Shield UIT2_SpectrumAnalyzer ... more
Fork of SeeedStudioTFTv2 by
Revision 2:ef7972c29c0e, committed 2011-09-04
- Comitter:
- dreschpe
- Date:
- Sun Sep 04 21:23:31 2011 +0000
- Parent:
- 1:1745fdf054b5
- Child:
- 3:1e05b273008a
- Commit message:
- Fix bug from SPI_TFT lib changes
Changed in this revision
| touch_tft.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/touch_tft.cpp Thu Jul 14 21:27:19 2011 +0000
+++ b/touch_tft.cpp Sun Sep 04 21:23:31 2011 +0000
@@ -110,16 +110,22 @@
void touch_tft::calibrate(void) {
int i;
int a = 0,b = 0,c = 0, d = 0;
- int pos;
+ int pos_x, pos_y;
point p;
cls();
line(0,3,6,3,White);
line(3,0,3,6,White);
- pos = columns() / 2 - 5;
- locate(pos,5);
+
+ // get the center of the screen
+ pos_x = columns() / 2 - 3;
+ pos_x = pos_x * font[1];
+ pos_y = (rows() / 2) - 1;
+ pos_y = pos_y * font[2];
+
+ locate(pos_x,pos_y);
printf("press cross");
- locate(pos,6);
+ locate(pos_x,pos_y + font[2]);
printf("to calibrate");
for (i=0; i<5; i++) {
do {
@@ -130,7 +136,7 @@
}
a = a / 5;
b = b / 5;
- locate(pos,5);
+ locate(pos_x,pos_y);
printf("OK ");
do {
p = get_touch();
@@ -139,9 +145,9 @@
cls();
line(width() -5, height() - 8,width() - 5,height() -1,White); // paint cross
line(width() - 8,height() - 5,width() - 1,height() - 5,White);
- locate(pos,5);
+ locate(pos_x,pos_y);
printf("press cross");
- locate(pos,6);
+ locate(pos_x,pos_y + font[2]);
printf("to calibrate");
for (i=0; i<5; i++) {
do {
@@ -153,7 +159,7 @@
c = c / 5;
d = d / 5;
- locate(pos,5);
+ locate(pos_x, pos_y);
printf("OK ");
do {
p = get_touch();
@@ -176,13 +182,13 @@
point p;
p.x = (a_point.x - x_off) / pp_tx;
- if(p.x > width()) p.x = 0;
+ if (p.x > width()) p.x = width();
p.y = (a_point.y - y_off) / pp_ty;
- if(p.y > height()) p.y = 0;
+ if (p.y > height()) p.y = height();
return (p);
}
-bool touch_tft::is_touched(point a){
- if (a.x > threshold & a.y > threshold) return(true);
- else return(false);
+bool touch_tft::is_touched(point a) {
+ if (a.x > threshold & a.y > threshold) return(true);
+ else return(false);
}

Seeed Studio 2.8'' TFT Touch Shield V2.0
Adafruit 2.8" TFT Touch Shield v2