Driver Library for our displays

Dependents:   dm_bubbles dm_calc dm_paint dm_sdcard_with_adapter ... more

Files at this revision

API Documentation at this revision

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 {