Modified version of the DmTftLibrary, optimized for the LPC4088 Experiment Base Board

Dependents:   lpc4088_ebb_dm_calc lpc4088_ebb_dm_bubbles

Fork of DmTftLibrary by Display Module

Committer:
displaymodule
Date:
Mon Jul 07 13:30:33 2014 +0000
Revision:
9:bac5439e3c1c
Parent:
7:6cd8c36cbdb3
Fixed touch calibration issues

Who changed what in which revision?

UserRevisionLine numberNew contents of line
displaymodule 7:6cd8c36cbdb3 1 /**********************************************************************************************
displaymodule 7:6cd8c36cbdb3 2 Copyright (c) 2014 DisplayModule. All rights reserved.
displaymodule 7:6cd8c36cbdb3 3
displaymodule 7:6cd8c36cbdb3 4 Redistribution and use of this source code, part of this source code or any compiled binary
displaymodule 7:6cd8c36cbdb3 5 based on this source code is permitted as long as the above copyright notice and following
displaymodule 7:6cd8c36cbdb3 6 disclaimer is retained.
displaymodule 7:6cd8c36cbdb3 7
displaymodule 7:6cd8c36cbdb3 8 DISCLAIMER:
displaymodule 7:6cd8c36cbdb3 9 THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES
displaymodule 7:6cd8c36cbdb3 10 NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
displaymodule 7:6cd8c36cbdb3 11 ********************************************************************************************/
displaymodule 7:6cd8c36cbdb3 12
displaymodule 7:6cd8c36cbdb3 13 #include "DmTouchCalibration.h"
displaymodule 7:6cd8c36cbdb3 14
displaymodule 7:6cd8c36cbdb3 15 DmTouchCalibration::DmTouchCalibration(DmTftBase *tftBase, DmTouch *touch) {
displaymodule 7:6cd8c36cbdb3 16 _tft = tftBase;
displaymodule 7:6cd8c36cbdb3 17 _touch = touch;
displaymodule 7:6cd8c36cbdb3 18 _textRow = 20;
displaymodule 7:6cd8c36cbdb3 19 }
displaymodule 7:6cd8c36cbdb3 20
displaymodule 7:6cd8c36cbdb3 21 // For best result, create a calibration for each display
displaymodule 7:6cd8c36cbdb3 22 CalibrationMatrix DmTouchCalibration::getDefaultCalibrationData(DmTouch::Display disp) {
displaymodule 7:6cd8c36cbdb3 23 CalibrationMatrix calibrationMatrix = {0};
displaymodule 7:6cd8c36cbdb3 24 switch (disp) {
displaymodule 7:6cd8c36cbdb3 25 case DmTouch::DM_TFT28_103:
displaymodule 7:6cd8c36cbdb3 26 calibrationMatrix.a = 67548; // 63787;
displaymodule 7:6cd8c36cbdb3 27 calibrationMatrix.b = -625; // -138;
displaymodule 7:6cd8c36cbdb3 28 calibrationMatrix.c = -16854644;//-15921157;
displaymodule 7:6cd8c36cbdb3 29 calibrationMatrix.d = 362; // -244;
displaymodule 7:6cd8c36cbdb3 30 calibrationMatrix.e = 89504; // 89313;
displaymodule 7:6cd8c36cbdb3 31 calibrationMatrix.f = -14380636;//-10726623;
displaymodule 7:6cd8c36cbdb3 32 break;
displaymodule 7:6cd8c36cbdb3 33
displaymodule 7:6cd8c36cbdb3 34 case DmTouch::DM_TFT24_104:
displaymodule 7:6cd8c36cbdb3 35 calibrationMatrix.a = -71855;
displaymodule 7:6cd8c36cbdb3 36 calibrationMatrix.b = 2147;
displaymodule 7:6cd8c36cbdb3 37 calibrationMatrix.c = 259719524;
displaymodule 7:6cd8c36cbdb3 38 calibrationMatrix.d = -1339;
displaymodule 7:6cd8c36cbdb3 39 calibrationMatrix.e = -91012;
displaymodule 7:6cd8c36cbdb3 40 calibrationMatrix.f = 354268832;
displaymodule 7:6cd8c36cbdb3 41 break;
displaymodule 7:6cd8c36cbdb3 42
displaymodule 7:6cd8c36cbdb3 43 case DmTouch::DM_TFT28_105:
displaymodule 7:6cd8c36cbdb3 44 calibrationMatrix.a = 65521;
displaymodule 7:6cd8c36cbdb3 45 calibrationMatrix.b = -253;
displaymodule 7:6cd8c36cbdb3 46 calibrationMatrix.c = -11813673;
displaymodule 7:6cd8c36cbdb3 47 calibrationMatrix.d = -439;
displaymodule 7:6cd8c36cbdb3 48 calibrationMatrix.e = 89201;
displaymodule 7:6cd8c36cbdb3 49 calibrationMatrix.f = -10450920;
displaymodule 7:6cd8c36cbdb3 50 break;
displaymodule 7:6cd8c36cbdb3 51
displaymodule 7:6cd8c36cbdb3 52 case DmTouch::DM_TFT35_107:
displaymodule 7:6cd8c36cbdb3 53 calibrationMatrix.a = 91302; // 85984;
displaymodule 7:6cd8c36cbdb3 54 calibrationMatrix.b = 817; // 451;
displaymodule 7:6cd8c36cbdb3 55 calibrationMatrix.c = -26296117;//-16494041;
displaymodule 7:6cd8c36cbdb3 56 calibrationMatrix.d = -1877; // 2308;
displaymodule 7:6cd8c36cbdb3 57 calibrationMatrix.e = 73762; // 65173;
displaymodule 7:6cd8c36cbdb3 58 calibrationMatrix.f = -26384255;//-19179080;
displaymodule 7:6cd8c36cbdb3 59 break;
displaymodule 7:6cd8c36cbdb3 60
displaymodule 7:6cd8c36cbdb3 61 default:
displaymodule 7:6cd8c36cbdb3 62 break;
displaymodule 7:6cd8c36cbdb3 63 }
displaymodule 7:6cd8c36cbdb3 64 return calibrationMatrix;
displaymodule 7:6cd8c36cbdb3 65 }
displaymodule 7:6cd8c36cbdb3 66
displaymodule 7:6cd8c36cbdb3 67
displaymodule 7:6cd8c36cbdb3 68 bool DmTouchCalibration::getTouchReferencePoints(Point displayRefPoint[], Point touchRefPoint[], uint16_t tftWidth, uint16_t tftHeight) {
displaymodule 7:6cd8c36cbdb3 69 _touch->setPrecison(60);
displaymodule 7:6cd8c36cbdb3 70 displayRefPoint[0].x = (tftWidth / 2);
displaymodule 7:6cd8c36cbdb3 71 displayRefPoint[0].y = (tftHeight / 2);
displaymodule 7:6cd8c36cbdb3 72 displayRefPoint[1].x = 1 * (tftWidth / 5);
displaymodule 7:6cd8c36cbdb3 73 displayRefPoint[1].y = 1 * (tftHeight / 5);
displaymodule 7:6cd8c36cbdb3 74 displayRefPoint[2].x = 4 * (tftWidth / 5);
displaymodule 7:6cd8c36cbdb3 75 displayRefPoint[2].y = 1 * (tftHeight / 5);
displaymodule 7:6cd8c36cbdb3 76 displayRefPoint[3].x = 4 * (tftWidth / 5);
displaymodule 7:6cd8c36cbdb3 77 displayRefPoint[3].y = 4 * (tftHeight / 5);
displaymodule 7:6cd8c36cbdb3 78 displayRefPoint[4].x = 1 * (tftWidth / 5);
displaymodule 7:6cd8c36cbdb3 79 displayRefPoint[4].y = 4 * (tftHeight / 5);
displaymodule 7:6cd8c36cbdb3 80
displaymodule 7:6cd8c36cbdb3 81 for(int n = 0; n < 5; n++) {
displaymodule 7:6cd8c36cbdb3 82 drawCalibPoint(displayRefPoint[n].x, displayRefPoint[n].y);
displaymodule 7:6cd8c36cbdb3 83 if (!getRawTouch(touchRefPoint[n].x, touchRefPoint[n].y)) {
displaymodule 7:6cd8c36cbdb3 84 return false;
displaymodule 7:6cd8c36cbdb3 85 }
displaymodule 7:6cd8c36cbdb3 86 releaseTouch(displayRefPoint[n].x, displayRefPoint[n].y);
displaymodule 7:6cd8c36cbdb3 87 }
displaymodule 7:6cd8c36cbdb3 88
displaymodule 7:6cd8c36cbdb3 89 _touch->setPrecison(3);
displaymodule 7:6cd8c36cbdb3 90 return true;
displaymodule 7:6cd8c36cbdb3 91 }
displaymodule 7:6cd8c36cbdb3 92
displaymodule 7:6cd8c36cbdb3 93 bool DmTouchCalibration::getRawTouch(uint16_t& x, uint16_t& y) const {
displaymodule 7:6cd8c36cbdb3 94 bool touched = false;
displaymodule 9:bac5439e3c1c 95 bool haveAllSamples = false;
displaymodule 7:6cd8c36cbdb3 96
displaymodule 7:6cd8c36cbdb3 97 while(!touched) {
displaymodule 7:6cd8c36cbdb3 98 if (_touch->isTouched()) {
displaymodule 7:6cd8c36cbdb3 99 //Serial.println("is touched");
displaymodule 9:bac5439e3c1c 100 haveAllSamples = _touch->getMiddleXY(x, y);
displaymodule 9:bac5439e3c1c 101
displaymodule 9:bac5439e3c1c 102 // As many samples are take during calibration it is important to
displaymodule 9:bac5439e3c1c 103 // make sure that the screen is still touched. If the user has let
displaymodule 9:bac5439e3c1c 104 // go already then the gathered samples are not good enough.
displaymodule 9:bac5439e3c1c 105 touched = haveAllSamples && _touch->isTouched();
displaymodule 7:6cd8c36cbdb3 106 }
displaymodule 7:6cd8c36cbdb3 107 }
displaymodule 9:bac5439e3c1c 108 return haveAllSamples;
displaymodule 7:6cd8c36cbdb3 109 }
displaymodule 7:6cd8c36cbdb3 110
displaymodule 7:6cd8c36cbdb3 111 void DmTouchCalibration::drawCalibPoint(uint16_t x, uint16_t y) const {
displaymodule 7:6cd8c36cbdb3 112 const uint8_t lineSize = 5;
displaymodule 7:6cd8c36cbdb3 113 _tft->drawHorizontalLine(x-lineSize, y, lineSize*2, RED);
displaymodule 7:6cd8c36cbdb3 114 _tft->drawVerticalLine(x, y-lineSize, lineSize*2, RED);
displaymodule 7:6cd8c36cbdb3 115 }
displaymodule 7:6cd8c36cbdb3 116
displaymodule 7:6cd8c36cbdb3 117 void DmTouchCalibration::releaseTouch(uint16_t x, uint16_t y) const {
displaymodule 7:6cd8c36cbdb3 118 _tft->drawCircle(x, y, 10, YELLOW);
displaymodule 7:6cd8c36cbdb3 119 delay(100);
displaymodule 7:6cd8c36cbdb3 120 _tft->fillCircle(x, y, 10, GREEN);
displaymodule 7:6cd8c36cbdb3 121 delay(100);
displaymodule 7:6cd8c36cbdb3 122 _tft->fillCircle(x, y, 10, BLACK);
displaymodule 7:6cd8c36cbdb3 123 delay(300);
displaymodule 7:6cd8c36cbdb3 124 _touch->waitForTouchRelease();
displaymodule 7:6cd8c36cbdb3 125 }
displaymodule 7:6cd8c36cbdb3 126
displaymodule 7:6cd8c36cbdb3 127 CalibrationMatrix DmTouchCalibration::calculateCalibrationMatrix(Point displayRefPoint[], Point touchRefPoint[]) {
displaymodule 7:6cd8c36cbdb3 128 double A = 0.0, B = 0.0, C = 0.0, D = 0.0, E = 0.0, F = 0.0;
displaymodule 7:6cd8c36cbdb3 129 double d = 0.0, dx1 = 0.0, dx2 = 0.0, dx3 = 0.0, dy1 = 0.0, dy2 = 0.0, dy3 = 0.0;
displaymodule 7:6cd8c36cbdb3 130 uint32_t X2_1 = 0, X2_2 = 0, X2_3 = 0, X2_4 = 0, X2_5 = 0;
displaymodule 7:6cd8c36cbdb3 131 uint32_t Y2_1 = 0, Y2_2 = 0, Y2_3 = 0, Y2_4 = 0, Y2_5 = 0;
displaymodule 7:6cd8c36cbdb3 132 uint32_t XxY_1 = 0, XxY_2 = 0, XxY_3 = 0, XxY_4 = 0, XxY_5 = 0;
displaymodule 7:6cd8c36cbdb3 133 uint32_t XxXd_1 = 0, XxXd_2 = 0, XxXd_3 = 0, XxXd_4 = 0, XxXd_5 = 0;
displaymodule 7:6cd8c36cbdb3 134 uint32_t YxXd_1 = 0, YxXd_2 = 0, YxXd_3 = 0, YxXd_4 = 0, YxXd_5 = 0;
displaymodule 7:6cd8c36cbdb3 135 uint32_t XxYd_1 = 0, XxYd_2 = 0, XxYd_3 = 0, XxYd_4 = 0, XxYd_5 = 0;
displaymodule 7:6cd8c36cbdb3 136 uint32_t YxYd_1 = 0, YxYd_2 = 0, YxYd_3 = 0, YxYd_4 = 0, YxYd_5 = 0;
displaymodule 7:6cd8c36cbdb3 137 uint32_t alfa = 0, beta = 0, chi = 0, Kx = 0, Ky = 0, Lx = 0, Ly = 0;
displaymodule 7:6cd8c36cbdb3 138 uint16_t epsilon = 0, fi = 0, Mx = 0, My = 0;
displaymodule 7:6cd8c36cbdb3 139
displaymodule 7:6cd8c36cbdb3 140 X2_1 = ((uint32_t)touchRefPoint[0].x * touchRefPoint[0].x);
displaymodule 7:6cd8c36cbdb3 141 X2_2 = ((uint32_t)touchRefPoint[1].x * touchRefPoint[1].x);
displaymodule 7:6cd8c36cbdb3 142 X2_3 = ((uint32_t)touchRefPoint[2].x * touchRefPoint[2].x);
displaymodule 7:6cd8c36cbdb3 143 X2_4 = ((uint32_t)touchRefPoint[3].x * touchRefPoint[3].x);
displaymodule 7:6cd8c36cbdb3 144 X2_5 = ((uint32_t)touchRefPoint[4].x * touchRefPoint[4].x);
displaymodule 7:6cd8c36cbdb3 145
displaymodule 7:6cd8c36cbdb3 146 Y2_1 = ((uint32_t)touchRefPoint[0].y * touchRefPoint[0].y);
displaymodule 7:6cd8c36cbdb3 147 Y2_2 = ((uint32_t)touchRefPoint[1].y * touchRefPoint[1].y);
displaymodule 7:6cd8c36cbdb3 148 Y2_3 = ((uint32_t)touchRefPoint[2].y * touchRefPoint[2].y);
displaymodule 7:6cd8c36cbdb3 149 Y2_4 = ((uint32_t)touchRefPoint[3].y * touchRefPoint[3].y);
displaymodule 7:6cd8c36cbdb3 150 Y2_5 = ((uint32_t)touchRefPoint[4].y * touchRefPoint[4].y);
displaymodule 7:6cd8c36cbdb3 151
displaymodule 7:6cd8c36cbdb3 152 XxY_1 = ((uint32_t)touchRefPoint[0].x * touchRefPoint[0].y);
displaymodule 7:6cd8c36cbdb3 153 XxY_2 = ((uint32_t)touchRefPoint[1].x * touchRefPoint[1].y);
displaymodule 7:6cd8c36cbdb3 154 XxY_3 = ((uint32_t)touchRefPoint[2].x * touchRefPoint[2].y);
displaymodule 7:6cd8c36cbdb3 155 XxY_4 = ((uint32_t)touchRefPoint[3].x * touchRefPoint[3].y);
displaymodule 7:6cd8c36cbdb3 156 XxY_5 = ((uint32_t)touchRefPoint[4].x * touchRefPoint[4].y);
displaymodule 7:6cd8c36cbdb3 157
displaymodule 7:6cd8c36cbdb3 158 XxXd_1 = ((uint32_t)touchRefPoint[0].x * displayRefPoint[0].x);
displaymodule 7:6cd8c36cbdb3 159 XxXd_2 = ((uint32_t)touchRefPoint[1].x * displayRefPoint[1].x);
displaymodule 7:6cd8c36cbdb3 160 XxXd_3 = ((uint32_t)touchRefPoint[2].x * displayRefPoint[2].x);
displaymodule 7:6cd8c36cbdb3 161 XxXd_4 = ((uint32_t)touchRefPoint[3].x * displayRefPoint[3].x);
displaymodule 7:6cd8c36cbdb3 162 XxXd_5 = ((uint32_t)touchRefPoint[4].x * displayRefPoint[4].x);
displaymodule 7:6cd8c36cbdb3 163
displaymodule 7:6cd8c36cbdb3 164 YxXd_1 = ((uint32_t)touchRefPoint[0].y * displayRefPoint[0].x);
displaymodule 7:6cd8c36cbdb3 165 YxXd_2 = ((uint32_t)touchRefPoint[1].y * displayRefPoint[1].x);
displaymodule 7:6cd8c36cbdb3 166 YxXd_3 = ((uint32_t)touchRefPoint[2].y * displayRefPoint[2].x);
displaymodule 7:6cd8c36cbdb3 167 YxXd_4 = ((uint32_t)touchRefPoint[3].y * displayRefPoint[3].x);
displaymodule 7:6cd8c36cbdb3 168 YxXd_5 = ((uint32_t)touchRefPoint[4].y * displayRefPoint[4].x);
displaymodule 7:6cd8c36cbdb3 169
displaymodule 7:6cd8c36cbdb3 170 XxYd_1 = ((uint32_t)touchRefPoint[0].x * displayRefPoint[0].y);
displaymodule 7:6cd8c36cbdb3 171 XxYd_2 = ((uint32_t)touchRefPoint[1].x * displayRefPoint[1].y);
displaymodule 7:6cd8c36cbdb3 172 XxYd_3 = ((uint32_t)touchRefPoint[2].x * displayRefPoint[2].y);
displaymodule 7:6cd8c36cbdb3 173 XxYd_4 = ((uint32_t)touchRefPoint[3].x * displayRefPoint[3].y);
displaymodule 7:6cd8c36cbdb3 174 XxYd_5 = ((uint32_t)touchRefPoint[4].x * displayRefPoint[4].y);
displaymodule 7:6cd8c36cbdb3 175
displaymodule 7:6cd8c36cbdb3 176 YxYd_1 = ((uint32_t)touchRefPoint[0].y * displayRefPoint[0].y);
displaymodule 7:6cd8c36cbdb3 177 YxYd_2 = ((uint32_t)touchRefPoint[1].y * displayRefPoint[1].y);
displaymodule 7:6cd8c36cbdb3 178 YxYd_3 = ((uint32_t)touchRefPoint[2].y * displayRefPoint[2].y);
displaymodule 7:6cd8c36cbdb3 179 YxYd_4 = ((uint32_t)touchRefPoint[3].y * displayRefPoint[3].y);
displaymodule 7:6cd8c36cbdb3 180 YxYd_5 = ((uint32_t)touchRefPoint[4].y * displayRefPoint[4].y);
displaymodule 7:6cd8c36cbdb3 181
displaymodule 7:6cd8c36cbdb3 182 alfa = X2_1 + X2_2 + X2_3 + X2_4 + X2_5;
displaymodule 7:6cd8c36cbdb3 183 beta = Y2_1 + Y2_2 + Y2_3 + Y2_4 + Y2_5;
displaymodule 7:6cd8c36cbdb3 184 chi = XxY_1 + XxY_2 + XxY_3 + XxY_4 + XxY_5;
displaymodule 7:6cd8c36cbdb3 185 epsilon = touchRefPoint[0].x + touchRefPoint[1].x + touchRefPoint[2].x + touchRefPoint[3].x + touchRefPoint[4].x;
displaymodule 7:6cd8c36cbdb3 186 fi = touchRefPoint[0].y + touchRefPoint[1].y + touchRefPoint[2].y + touchRefPoint[3].y + touchRefPoint[4].y;
displaymodule 7:6cd8c36cbdb3 187 Kx = XxXd_1 + XxXd_2 + XxXd_3 + XxXd_4 + XxXd_5;
displaymodule 7:6cd8c36cbdb3 188 Ky = XxYd_1 + XxYd_2 + XxYd_3 + XxYd_4 + XxYd_5;
displaymodule 7:6cd8c36cbdb3 189 Lx = YxXd_1 + YxXd_2 + YxXd_3 + YxXd_4 + YxXd_5;
displaymodule 7:6cd8c36cbdb3 190 Ly = YxYd_1 + YxYd_2 + YxYd_3 + YxYd_4 + YxYd_5;
displaymodule 7:6cd8c36cbdb3 191 Mx = displayRefPoint[0].x + displayRefPoint[1].x + displayRefPoint[2].x + displayRefPoint[3].x + displayRefPoint[4].x;
displaymodule 7:6cd8c36cbdb3 192 My = displayRefPoint[0].y + displayRefPoint[1].y + displayRefPoint[2].y + displayRefPoint[3].y + displayRefPoint[4].y;
displaymodule 7:6cd8c36cbdb3 193 d = 5 * ( ((double)alfa * beta) - ((double)chi * chi) ) + 2 * ((double)chi * epsilon * fi) - ((double)alfa * fi * fi ) - ( (double)beta * epsilon * epsilon );
displaymodule 7:6cd8c36cbdb3 194 dx1 = 5 * ( ((double)Kx * beta) - ((double)Lx * chi) ) + ((double)fi * ( ((double)Lx * epsilon) - ((double)Kx * fi) )) + ((double)Mx * ( ((double)chi * fi) - ((double)beta * epsilon) ));
displaymodule 7:6cd8c36cbdb3 195 dx2 = 5 * ( ((double)Lx * alfa) - ((double)Kx * chi) ) + ((double)epsilon * ( ((double)Kx * fi) - ((double)Lx * epsilon) )) + ((double)Mx * ( ((double)chi * epsilon) - ((double)alfa * fi) ));
displaymodule 7:6cd8c36cbdb3 196 dx3 = ((double)Kx * ( ((double)chi * fi) - ((double)beta * epsilon) )) + ((double)Lx * ( ((double)chi * epsilon) - ((double)alfa * fi) )) + ((double)Mx * ( ((double)alfa * beta) - ((double)chi * chi) ));
displaymodule 7:6cd8c36cbdb3 197 dy1 = 5 * ( ((double)Ky * beta) - ((double)Ly * chi) ) + ((double)fi * ( ((double)Ly * epsilon) - ((double)Ky * fi) )) + ((double)My * ( ((double)chi * fi) - ((double)beta * epsilon) ));
displaymodule 7:6cd8c36cbdb3 198 dy2 = 5 * ( ((double)Ly * alfa) - ((double)Ky * chi) ) + ((double)epsilon * ( ((double)Ky * fi) - ((double)Ly * epsilon) )) + ((double)My * ( ((double)chi * epsilon) - ((double)alfa * fi) ));
displaymodule 7:6cd8c36cbdb3 199 dy3 = ((double)Ky * ( ((double)chi * fi) - ((double)beta * epsilon) )) + ((double)Ly * ( ((double)chi * epsilon) - ((double)alfa * fi) )) + ((double)My * ( ((double)alfa * beta) - ((double)chi * chi) ));
displaymodule 7:6cd8c36cbdb3 200
displaymodule 7:6cd8c36cbdb3 201 A = dx1 / d;
displaymodule 7:6cd8c36cbdb3 202 B = dx2 / d;
displaymodule 7:6cd8c36cbdb3 203 C = dx3 / d;
displaymodule 7:6cd8c36cbdb3 204 D = dy1 / d;
displaymodule 7:6cd8c36cbdb3 205 E = dy2 / d;
displaymodule 7:6cd8c36cbdb3 206 F = dy3 / d;
displaymodule 7:6cd8c36cbdb3 207
displaymodule 7:6cd8c36cbdb3 208 CalibrationMatrix calibrationData;
displaymodule 7:6cd8c36cbdb3 209 calibrationData.a = (int32_t)(A * _touch->rescaleFactor());
displaymodule 7:6cd8c36cbdb3 210 calibrationData.b = (int32_t)(B * _touch->rescaleFactor());
displaymodule 7:6cd8c36cbdb3 211 calibrationData.c = (int32_t)(C * _touch->rescaleFactor());
displaymodule 7:6cd8c36cbdb3 212 calibrationData.d = (int32_t)(D * _touch->rescaleFactor());
displaymodule 7:6cd8c36cbdb3 213 calibrationData.e = (int32_t)(E * _touch->rescaleFactor());
displaymodule 7:6cd8c36cbdb3 214 calibrationData.f = (int32_t)(F * _touch->rescaleFactor());
displaymodule 7:6cd8c36cbdb3 215
displaymodule 7:6cd8c36cbdb3 216 return calibrationData;
displaymodule 7:6cd8c36cbdb3 217 }
displaymodule 7:6cd8c36cbdb3 218
displaymodule 7:6cd8c36cbdb3 219 void DmTouchCalibration::drawCalibration(CalibrationMatrix calibrationMatrix) {
displaymodule 7:6cd8c36cbdb3 220 printHeadline("CalibrationData: ");
displaymodule 7:6cd8c36cbdb3 221 printHeadline("a: ");
displaymodule 7:6cd8c36cbdb3 222 printNumber(calibrationMatrix.a);
displaymodule 7:6cd8c36cbdb3 223 printHeadline("b: ");
displaymodule 7:6cd8c36cbdb3 224 printNumber(calibrationMatrix.b);
displaymodule 7:6cd8c36cbdb3 225 printHeadline("c: ");
displaymodule 7:6cd8c36cbdb3 226 printNumber(calibrationMatrix.c);
displaymodule 7:6cd8c36cbdb3 227 printHeadline("d: ");
displaymodule 7:6cd8c36cbdb3 228 printNumber(calibrationMatrix.d);
displaymodule 7:6cd8c36cbdb3 229 printHeadline("e: ");
displaymodule 7:6cd8c36cbdb3 230 printNumber(calibrationMatrix.e);
displaymodule 7:6cd8c36cbdb3 231 printHeadline("f: ");
displaymodule 7:6cd8c36cbdb3 232 printNumber(calibrationMatrix.f);
displaymodule 7:6cd8c36cbdb3 233 }
displaymodule 7:6cd8c36cbdb3 234
displaymodule 7:6cd8c36cbdb3 235 void DmTouchCalibration::printHeadline(char* text) {
displaymodule 7:6cd8c36cbdb3 236 _textRow += 20;
displaymodule 7:6cd8c36cbdb3 237 _tft->drawString(5, _textRow, text);
displaymodule 7:6cd8c36cbdb3 238 }
displaymodule 7:6cd8c36cbdb3 239
displaymodule 7:6cd8c36cbdb3 240 void DmTouchCalibration::printNumber(int32_t number) const {
displaymodule 7:6cd8c36cbdb3 241 _tft->drawNumber(20, _textRow, number, 10, false);
displaymodule 7:6cd8c36cbdb3 242 }
displaymodule 7:6cd8c36cbdb3 243
displaymodule 7:6cd8c36cbdb3 244 void DmTouchCalibration::printCalibration(CalibrationMatrix calibrationMatrix) const {
displaymodule 7:6cd8c36cbdb3 245 #if defined (DM_TOOLCHAIN_ARDUINO)
displaymodule 7:6cd8c36cbdb3 246 Serial.println(F("-------- Calibration data ------"));
displaymodule 7:6cd8c36cbdb3 247 Serial.println(F("CalibrationMatrix calibrationMatrix;"));
displaymodule 7:6cd8c36cbdb3 248 Serial.print(F("calibrationMatrix.a = "));
displaymodule 7:6cd8c36cbdb3 249 Serial.print(calibrationMatrix.a);
displaymodule 7:6cd8c36cbdb3 250 Serial.println(F(";"));
displaymodule 7:6cd8c36cbdb3 251 Serial.print(F("calibrationMatrix.b = "));
displaymodule 7:6cd8c36cbdb3 252 Serial.print(calibrationMatrix.b);
displaymodule 7:6cd8c36cbdb3 253 Serial.println(F(";"));
displaymodule 7:6cd8c36cbdb3 254 Serial.print(F("calibrationMatrix.c = "));
displaymodule 7:6cd8c36cbdb3 255 Serial.print(calibrationMatrix.c);
displaymodule 7:6cd8c36cbdb3 256 Serial.println(F(";"));
displaymodule 7:6cd8c36cbdb3 257 Serial.print(F("calibrationMatrix.d = "));
displaymodule 7:6cd8c36cbdb3 258 Serial.print(calibrationMatrix.d);
displaymodule 7:6cd8c36cbdb3 259 Serial.println(F(";"));
displaymodule 7:6cd8c36cbdb3 260 Serial.print(F("calibrationMatrix.e = "));
displaymodule 7:6cd8c36cbdb3 261 Serial.print(calibrationMatrix.e);
displaymodule 7:6cd8c36cbdb3 262 Serial.println(F(";"));
displaymodule 7:6cd8c36cbdb3 263 Serial.print(F("calibrationMatrix.f = "));
displaymodule 7:6cd8c36cbdb3 264 Serial.print(calibrationMatrix.f);
displaymodule 7:6cd8c36cbdb3 265 Serial.println(F(";"));
displaymodule 7:6cd8c36cbdb3 266 Serial.println("-------------------------------");
displaymodule 7:6cd8c36cbdb3 267 #endif
displaymodule 7:6cd8c36cbdb3 268 }