Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.
Dependents: FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more
Fork of SPI_TFT by
See Components - RA8875 Based Display
Enhanced touch-screen support - where it previous supported both the Resistive Touch and Capacitive Touch based on the FT5206 Touch Controller, now it also has support for the GSL1680 Touch Controller.
Offline Help Manual (Windows chm)
/media/uploads/WiredHome/ra8875.zip.bin (download, rename to .zip and unzip)
Diff: RA8875_Touch.cpp
- Revision:
- 88:bfddef6ec836
- Parent:
- 85:022bba13c5c4
- Child:
- 103:7e0464ca6c5c
--- a/RA8875_Touch.cpp Mon Jan 19 13:32:56 2015 +0000 +++ b/RA8875_Touch.cpp Mon Jan 19 15:44:41 2015 +0000 @@ -74,13 +74,15 @@ } -RetCode_t RA8875::TouchPanelCalibrate(const char * msg, tpMatrix_t * matrix) +RetCode_t RA8875::TouchPanelCalibrate(const char * msg, tpMatrix_t * matrix, int maxwait_s) { point_t pTest[3]; point_t pSample[3]; int x,y; + Timer timeout; // timeout guards for not-installed, stuck, user not present... - while (TouchPanelA2DFiltered(&x, &y)) + timeout.start(); + while (TouchPanelA2DFiltered(&x, &y) && timeout.read() < maxwait_s) wait_ms(20); cls(); if (msg) @@ -89,12 +91,13 @@ pTest[0].x = 50; pTest[0].y = 50; pTest[1].x = width() - 50; pTest[1].y = height()/2; pTest[2].x = width()/2; pTest[2].y = height() - 50; + for (int i=0; i<3; i++) { foreground(Blue); printf(" (%3d,%3d) => ", pTest[i].x, pTest[i].y); line(pTest[i].x-10, pTest[i].y, pTest[i].x+10, pTest[i].y, White); line(pTest[i].x, pTest[i].y-10, pTest[i].x, pTest[i].y+10, White); - while (!TouchPanelA2DFiltered(&x, &y)) + while (!TouchPanelA2DFiltered(&x, &y) && timeout.read() < maxwait_s) wait_ms(20); pSample[i].x = x; pSample[i].y = y; @@ -102,11 +105,14 @@ line(pTest[i].x, pTest[i].y-10, pTest[i].x, pTest[i].y+10, Black); foreground(Blue); printf(" (%4d,%4d)\r\n", x,y); - while (TouchPanelA2DFiltered(&x, &y)) + while (TouchPanelA2DFiltered(&x, &y) && timeout.read() < maxwait_s) wait_ms(20); wait(2); } - return TouchPanelComputeCalibration(pTest, pSample, matrix); + if (timeout.read() >= maxwait_s) + return touch_cal_timeout; + else + return TouchPanelComputeCalibration(pTest, pSample, matrix); }