Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 9:bac5439e3c1c, committed 2014-07-07
- Comitter:
- displaymodule
- Date:
- Mon Jul 07 13:30:33 2014 +0000
- Parent:
- 8:b24f01d148c4
- Child:
- 10:d263094e666d
- Commit message:
- Fixed touch calibration issues
Changed in this revision
| DmTouch.cpp | Show annotated file Show diff for this revision Revisions of this file |
| DmTouchCalibration.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/DmTouch.cpp Mon Jul 07 10:38:09 2014 +0000
+++ b/DmTouch.cpp Mon Jul 07 13:30:33 2014 +0000
@@ -294,8 +294,10 @@
break;
}
}
- x = calculateMiddleValue(valuesX, nbrOfMeasurements);
- y = calculateMiddleValue(valuesY, nbrOfMeasurements);
+ if (haveAllMeasurements) {
+ x = calculateMiddleValue(valuesX, nbrOfMeasurements);
+ y = calculateMiddleValue(valuesY, nbrOfMeasurements);
+ }
return haveAllMeasurements;
}
--- a/DmTouchCalibration.cpp Mon Jul 07 10:38:09 2014 +0000
+++ b/DmTouchCalibration.cpp Mon Jul 07 13:30:33 2014 +0000
@@ -92,16 +92,20 @@
bool DmTouchCalibration::getRawTouch(uint16_t& x, uint16_t& y) const {
bool touched = false;
- bool hasAllSamples = false;
+ bool haveAllSamples = false;
while(!touched) {
if (_touch->isTouched()) {
//Serial.println("is touched");
- hasAllSamples = _touch->getMiddleXY(x, y);
- touched = true;
+ haveAllSamples = _touch->getMiddleXY(x, y);
+
+ // As many samples are take during calibration it is important to
+ // make sure that the screen is still touched. If the user has let
+ // go already then the gathered samples are not good enough.
+ touched = haveAllSamples && _touch->isTouched();
}
}
- return hasAllSamples;
+ return haveAllSamples;
}
void DmTouchCalibration::drawCalibPoint(uint16_t x, uint16_t y) const {