.
Dependencies: SPI_TFT_ILI9341
Fork of SeeedStudioTFTv2 by
Revision 6:2612205220c5, committed 2013-10-19
- Comitter:
- mazgch
- Date:
- Sat Oct 19 21:21:59 2013 +0000
- Parent:
- 5:366bdc7a8315
- Child:
- 7:dfd69b3be5b6
- Commit message:
- avoid crash if no font selected
Changed in this revision
| SeeedStudioTFTv2.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SeeedStudioTFTv2.cpp Sat Oct 19 21:07:54 2013 +0000
+++ b/SeeedStudioTFTv2.cpp Sat Oct 19 21:21:59 2013 +0000
@@ -33,6 +33,7 @@
#endif
// backlight
bl = 1;
+ font = NULL;
// touch screen pins
_xp = xp;
_yp = yp;
@@ -110,22 +111,25 @@
{
int i;
int a = 0,b = 0,c = 0, d = 0;
- int pos_x, pos_y;
+ int pos_x = 0, pos_y = 0;
point p;
cls();
foreground(White); // set chars to white
line(0,3,6,3,White);
line(3,0,3,6,White);
- // 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_x,pos_y + font[2]);
- printf("to calibrate ");
+ if (font)
+ {
+ // 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_x,pos_y + font[2]);
+ printf("to calibrate ");
+ }
for (i=0; i<5; i++) {
while (getTouch(p) != YES)
/*nothing*/;
@@ -134,19 +138,25 @@
}
a = a / 5;
b = b / 5;
- locate(pos_x,pos_y);
- printf("ok ");
- locate(pos_x,pos_y + font[2]);
- printf("release touch ");
+ if (font)
+ {
+ locate(pos_x,pos_y);
+ printf("ok ");
+ locate(pos_x,pos_y + font[2]);
+ printf("release touch ");
+ }
while (getTouch(p) != NO)
/*nothing*/;
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_x,pos_y);
- printf("press cross ");
- locate(pos_x,pos_y + font[2]);
- printf("to calibrate ");
+ if (font)
+ {
+ locate(pos_x,pos_y);
+ printf("press cross ");
+ locate(pos_x,pos_y + font[2]);
+ printf("to calibrate ");
+ }
for (i=0; i<5; i++) {
while (getTouch(p) != YES)
/*nothing*/;
@@ -155,21 +165,21 @@
}
c = c / 5;
d = d / 5;
- locate(pos_x, pos_y);
-
x_off = a;
y_off = b;
i = c-a; // delta x
pp_tx = i / (width() - 6);
i = d-b; // delta y
pp_ty = i / (height() - 6);
-
- locate(pos_x,pos_y);
- printf("Calibrated ");
- locate(pos_x,pos_y + font[2]);
- printf("x %6i %4i", x_off, pp_tx);
- locate(pos_x,pos_y + 2*font[2]);
- printf("y %6i %4i", y_off, pp_ty);
+ if (font)
+ {
+ locate(pos_x,pos_y);
+ printf("Calibrated ");
+ locate(pos_x,pos_y + font[2]);
+ printf("x %6i %4i", x_off, pp_tx);
+ locate(pos_x,pos_y + 2*font[2]);
+ printf("y %6i %4i", y_off, pp_ty);
+ }
while (getTouch(p) != NO)
/*nothing*/;
cls();
