LPC1768 Mini-DK board with 2.8" SPI TFT and SPI touch
Dependencies: Mini-DK SDFileSystem mbed
Fork of LPC1768_Mini-DK by
Revision 16:784a071dec0e, committed 2014-03-23
- Comitter:
- frankvnk
- Date:
- Sun Mar 23 20:02:45 2014 +0000
- Parent:
- 15:5059751d2fa2
- Commit message:
- Added GetCalibration and SetCalibration
Changed in this revision
Mini-DK.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 5059751d2fa2 -r 784a071dec0e Mini-DK.lib --- a/Mini-DK.lib Tue Mar 18 19:30:28 2014 +0000 +++ b/Mini-DK.lib Sun Mar 23 20:02:45 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/frankvnk/code/Mini-DK/#5feb12e3801f +http://mbed.org/users/frankvnk/code/Mini-DK/#9d05a7e6dc9d
diff -r 5059751d2fa2 -r 784a071dec0e main.cpp --- a/main.cpp Tue Mar 18 19:30:28 2014 +0000 +++ b/main.cpp Sun Mar 23 20:02:45 2014 +0000 @@ -36,6 +36,13 @@ int main() { + // Structs for storing touchpanel calibration data. + // Can be written to external storage (eg : eeprom), + // read back on startup and written to the touchpanel. + // As a result, the real calibration only needs to be done once. + Matrix matrix; + Coordinate ScreenSample[3]; + unsigned short LCD_id; TFT.claim(stdout); // send stdout to the TFT display // Disable stdout buffering, allows us to omit \n with printf. @@ -147,6 +154,40 @@ TP.TouchPanel_Calibrate(); TFT.set_font((unsigned char*) Arial12x12); TFT.set_orientation(0); + + TFT.cls(); + TFT.locate(0,20); + // read calibration results + TP.GetCalibration(&matrix, &ScreenSample[0]); + printf("Read calibration results.\n"); + printf("matrix.An = %d\n", matrix.An); + printf("matrix.Bn = %d\n", matrix.Bn); + printf("matrix.Cn = %d\n", matrix.Cn); + printf("matrix.Dn = %d\n", matrix.Dn); + printf("matrix.En = %d\n", matrix.En); + printf("matrix.Fn = %d\n", matrix.Fn); + printf("matrix.Di = %d\n", matrix.Divider); + for (i=0;i<3;i++) + printf("sample x[%d] = %d\nsample y[%d] = %d\n", i, ScreenSample[i].x, i, ScreenSample[i].y); + // Write calibration results + printf("\nWrite calibration results...\n"); + TP.SetCalibration(&matrix, &ScreenSample[0]); + printf("Done.\nTouch panel to read again.\n"); + while(TP._tp_irq); + // read calibration results + TFT.cls(); + TFT.locate(0,20); + printf("Calibration results.\n\n"); + printf("matrix.An = %d\n", matrix.An); + printf("matrix.Bn = %d\n", matrix.Bn); + printf("matrix.Cn = %d\n", matrix.Cn); + printf("matrix.Dn = %d\n", matrix.Dn); + printf("matrix.En = %d\n", matrix.En); + printf("matrix.Fn = %d\n", matrix.Fn); + printf("matrix.Di = %d\n", matrix.Divider); + for (i=0;i<3;i++) + printf("sample x[%d] = %d\nsample y[%d] = %d\n", i, ScreenSample[i].x, i, ScreenSample[i].y); + TFT.locate(0,0); printf(" X:"); TFT.locate(70,0);