Forked para SNOCC
Fork of RA8875 by
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); }