Erik -
/
Mini_DK_clk
Simple clock program for LPC1768 Mini-DK
Mini_DK/TouchADS7843/Touch.cpp@0:ab0aec01b38e, 2012-12-30 (annotated)
- Committer:
- Sissors
- Date:
- Sun Dec 30 21:31:56 2012 +0000
- Revision:
- 0:ab0aec01b38e
v0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 0:ab0aec01b38e | 1 | // Code based on Carlos E. Vidales tutorial : How To Calibrate Touch Screens |
Sissors | 0:ab0aec01b38e | 2 | // http://www.embedded.com/design/configurable-systems/4023968/How-To-Calibrate-Touch-Screens |
Sissors | 0:ab0aec01b38e | 3 | |
Sissors | 0:ab0aec01b38e | 4 | #include "Touch.h" |
Sissors | 0:ab0aec01b38e | 5 | #include "mbed.h" |
Sissors | 0:ab0aec01b38e | 6 | #include "Arial12x12.h" |
Sissors | 0:ab0aec01b38e | 7 | |
Sissors | 0:ab0aec01b38e | 8 | // (To be modified) C code below works on KEIL compiler but NOT on LPCXpresso/mbed |
Sissors | 0:ab0aec01b38e | 9 | //Matrix matrix ; |
Sissors | 0:ab0aec01b38e | 10 | //Coordinate display ; |
Sissors | 0:ab0aec01b38e | 11 | |
Sissors | 0:ab0aec01b38e | 12 | Coordinate ScreenSample[3] = { |
Sissors | 0:ab0aec01b38e | 13 | { 45, 45 }, |
Sissors | 0:ab0aec01b38e | 14 | { 45, 270}, |
Sissors | 0:ab0aec01b38e | 15 | { 190,190} |
Sissors | 0:ab0aec01b38e | 16 | } ; |
Sissors | 0:ab0aec01b38e | 17 | Coordinate DisplaySample[3] = { |
Sissors | 0:ab0aec01b38e | 18 | { 45, 45 }, |
Sissors | 0:ab0aec01b38e | 19 | { 45, 270}, |
Sissors | 0:ab0aec01b38e | 20 | { 190,190} |
Sissors | 0:ab0aec01b38e | 21 | } ; |
Sissors | 0:ab0aec01b38e | 22 | |
Sissors | 0:ab0aec01b38e | 23 | #define THRESHOLD 2 |
Sissors | 0:ab0aec01b38e | 24 | // ********************************************************************** |
Sissors | 0:ab0aec01b38e | 25 | |
Sissors | 0:ab0aec01b38e | 26 | TouchScreenADS7843::TouchScreenADS7843(PinName tp_mosi,PinName tp_miso,PinName tp_sclk,PinName tp_cs,PinName tp_irq,PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset,const char* name) |
Sissors | 0:ab0aec01b38e | 27 | : SPI_TFT(mosi,miso,sclk,cs,reset,name), _tp_spi(tp_mosi, tp_miso, tp_sclk), _tp_cs(tp_cs), _tp_irq(tp_irq){} |
Sissors | 0:ab0aec01b38e | 28 | // ********************************************************************** |
Sissors | 0:ab0aec01b38e | 29 | void TouchScreenADS7843::TP_Init(void) |
Sissors | 0:ab0aec01b38e | 30 | { |
Sissors | 0:ab0aec01b38e | 31 | _tp_cs=1; |
Sissors | 0:ab0aec01b38e | 32 | _tp_spi.frequency(500000); |
Sissors | 0:ab0aec01b38e | 33 | _tp_spi.format(8,0); // 8 bit spi mode 3 |
Sissors | 0:ab0aec01b38e | 34 | } |
Sissors | 0:ab0aec01b38e | 35 | |
Sissors | 0:ab0aec01b38e | 36 | int TouchScreenADS7843::Read_XY(unsigned char XY) |
Sissors | 0:ab0aec01b38e | 37 | { |
Sissors | 0:ab0aec01b38e | 38 | unsigned char msb, lsb; |
Sissors | 0:ab0aec01b38e | 39 | unsigned int Temp; |
Sissors | 0:ab0aec01b38e | 40 | |
Sissors | 0:ab0aec01b38e | 41 | Temp=0; |
Sissors | 0:ab0aec01b38e | 42 | _tp_cs=0; |
Sissors | 0:ab0aec01b38e | 43 | wait_us(SPI_RD_DELAY); |
Sissors | 0:ab0aec01b38e | 44 | _tp_spi.write(XY); |
Sissors | 0:ab0aec01b38e | 45 | wait_us(SPI_RD_DELAY); |
Sissors | 0:ab0aec01b38e | 46 | msb = _tp_spi.write(0x00); // msb |
Sissors | 0:ab0aec01b38e | 47 | wait_us(SPI_RD_DELAY); |
Sissors | 0:ab0aec01b38e | 48 | lsb = _tp_spi.write(0x00); // lsb |
Sissors | 0:ab0aec01b38e | 49 | _tp_cs=1; |
Sissors | 0:ab0aec01b38e | 50 | Temp = ((msb <<8 ) | lsb); |
Sissors | 0:ab0aec01b38e | 51 | Temp >>= 3; |
Sissors | 0:ab0aec01b38e | 52 | Temp &= 0xfff; |
Sissors | 0:ab0aec01b38e | 53 | Temp /= 4; // Scaling : return value range must be between 0 and 1024 |
Sissors | 0:ab0aec01b38e | 54 | // Temp = (((msb & 0x7f) <<8) | lsb) >> 3; // 12 bit |
Sissors | 0:ab0aec01b38e | 55 | return(Temp); |
Sissors | 0:ab0aec01b38e | 56 | } |
Sissors | 0:ab0aec01b38e | 57 | |
Sissors | 0:ab0aec01b38e | 58 | |
Sissors | 0:ab0aec01b38e | 59 | void TouchScreenADS7843::TP_GetAdXY(int *x,int *y) |
Sissors | 0:ab0aec01b38e | 60 | { |
Sissors | 0:ab0aec01b38e | 61 | int adx,ady; |
Sissors | 0:ab0aec01b38e | 62 | adx = Read_XY(CHX); |
Sissors | 0:ab0aec01b38e | 63 | wait_us(1); |
Sissors | 0:ab0aec01b38e | 64 | ady = Read_XY(CHY); |
Sissors | 0:ab0aec01b38e | 65 | *x = adx; |
Sissors | 0:ab0aec01b38e | 66 | *y = ady; |
Sissors | 0:ab0aec01b38e | 67 | } |
Sissors | 0:ab0aec01b38e | 68 | |
Sissors | 0:ab0aec01b38e | 69 | void TouchScreenADS7843::TP_DrawPoint(unsigned int Xpos,unsigned int Ypos, unsigned int color) |
Sissors | 0:ab0aec01b38e | 70 | { |
Sissors | 0:ab0aec01b38e | 71 | wr_reg(0x03, 0x1030); |
Sissors | 0:ab0aec01b38e | 72 | WindowMax(); |
Sissors | 0:ab0aec01b38e | 73 | pixel(Xpos,Ypos,color); |
Sissors | 0:ab0aec01b38e | 74 | pixel(Xpos+1,Ypos,color); |
Sissors | 0:ab0aec01b38e | 75 | pixel(Xpos,Ypos+1,color); |
Sissors | 0:ab0aec01b38e | 76 | pixel(Xpos+1,Ypos+1,color); |
Sissors | 0:ab0aec01b38e | 77 | } |
Sissors | 0:ab0aec01b38e | 78 | |
Sissors | 0:ab0aec01b38e | 79 | void TouchScreenADS7843::DrawCross(unsigned int Xpos,unsigned int Ypos) |
Sissors | 0:ab0aec01b38e | 80 | { |
Sissors | 0:ab0aec01b38e | 81 | line(Xpos-15,Ypos,Xpos-2,Ypos,White); |
Sissors | 0:ab0aec01b38e | 82 | line(Xpos+2,Ypos,Xpos+15,Ypos,White); |
Sissors | 0:ab0aec01b38e | 83 | line(Xpos,Ypos-15,Xpos,Ypos-2,White); |
Sissors | 0:ab0aec01b38e | 84 | line(Xpos,Ypos+2,Xpos,Ypos+15,White); |
Sissors | 0:ab0aec01b38e | 85 | |
Sissors | 0:ab0aec01b38e | 86 | line(Xpos-15,Ypos+15,Xpos-7,Ypos+15,DarkGrey); |
Sissors | 0:ab0aec01b38e | 87 | line(Xpos-15,Ypos+7,Xpos-15,Ypos+15,DarkGrey); |
Sissors | 0:ab0aec01b38e | 88 | |
Sissors | 0:ab0aec01b38e | 89 | line(Xpos-15,Ypos-15,Xpos-7,Ypos-15,DarkGrey); |
Sissors | 0:ab0aec01b38e | 90 | line(Xpos-15,Ypos-7,Xpos-15,Ypos-15,DarkGrey); |
Sissors | 0:ab0aec01b38e | 91 | |
Sissors | 0:ab0aec01b38e | 92 | line(Xpos+7,Ypos+15,Xpos+15,Ypos+15,DarkGrey); |
Sissors | 0:ab0aec01b38e | 93 | line(Xpos+15,Ypos+7,Xpos+15,Ypos+15,DarkGrey); |
Sissors | 0:ab0aec01b38e | 94 | |
Sissors | 0:ab0aec01b38e | 95 | line(Xpos+7,Ypos-15,Xpos+15,Ypos-15,DarkGrey); |
Sissors | 0:ab0aec01b38e | 96 | line(Xpos+15,Ypos-15,Xpos+15,Ypos-7,DarkGrey); |
Sissors | 0:ab0aec01b38e | 97 | } |
Sissors | 0:ab0aec01b38e | 98 | |
Sissors | 0:ab0aec01b38e | 99 | unsigned char TouchScreenADS7843::Read_Ads7846(Coordinate * screenPtr) |
Sissors | 0:ab0aec01b38e | 100 | { |
Sissors | 0:ab0aec01b38e | 101 | // static Coordinate screen; |
Sissors | 0:ab0aec01b38e | 102 | int m0,m1,m2,TP_X[1],TP_Y[1],temp[3]; |
Sissors | 0:ab0aec01b38e | 103 | uint8_t count=0; |
Sissors | 0:ab0aec01b38e | 104 | int buffer[2][9]={{0},{0}}; |
Sissors | 0:ab0aec01b38e | 105 | do |
Sissors | 0:ab0aec01b38e | 106 | { |
Sissors | 0:ab0aec01b38e | 107 | TP_GetAdXY(TP_X,TP_Y); |
Sissors | 0:ab0aec01b38e | 108 | buffer[0][count]=TP_X[0]; |
Sissors | 0:ab0aec01b38e | 109 | buffer[1][count]=TP_Y[0]; |
Sissors | 0:ab0aec01b38e | 110 | count++; |
Sissors | 0:ab0aec01b38e | 111 | } |
Sissors | 0:ab0aec01b38e | 112 | while(!_tp_irq && (count < 9)); |
Sissors | 0:ab0aec01b38e | 113 | if(count==9) |
Sissors | 0:ab0aec01b38e | 114 | { |
Sissors | 0:ab0aec01b38e | 115 | temp[0]=(buffer[0][0]+buffer[0][1]+buffer[0][2])/3; |
Sissors | 0:ab0aec01b38e | 116 | temp[1]=(buffer[0][3]+buffer[0][4]+buffer[0][5])/3; |
Sissors | 0:ab0aec01b38e | 117 | temp[2]=(buffer[0][6]+buffer[0][7]+buffer[0][8])/3; |
Sissors | 0:ab0aec01b38e | 118 | m0=temp[0]-temp[1]; |
Sissors | 0:ab0aec01b38e | 119 | m1=temp[1]-temp[2]; |
Sissors | 0:ab0aec01b38e | 120 | m2=temp[2]-temp[0]; |
Sissors | 0:ab0aec01b38e | 121 | m0=m0>0?m0:(-m0); |
Sissors | 0:ab0aec01b38e | 122 | m1=m1>0?m1:(-m1); |
Sissors | 0:ab0aec01b38e | 123 | m2=m2>0?m2:(-m2); |
Sissors | 0:ab0aec01b38e | 124 | if( (m0>THRESHOLD) && (m1>THRESHOLD) && (m2>THRESHOLD) ) return 0; |
Sissors | 0:ab0aec01b38e | 125 | if(m0<m1) |
Sissors | 0:ab0aec01b38e | 126 | { |
Sissors | 0:ab0aec01b38e | 127 | if(m2<m0) |
Sissors | 0:ab0aec01b38e | 128 | screenPtr->x=(temp[0]+temp[2])/2; |
Sissors | 0:ab0aec01b38e | 129 | else |
Sissors | 0:ab0aec01b38e | 130 | screenPtr->x=(temp[0]+temp[1])/2; |
Sissors | 0:ab0aec01b38e | 131 | } |
Sissors | 0:ab0aec01b38e | 132 | else if(m2<m1) |
Sissors | 0:ab0aec01b38e | 133 | screenPtr->x=(temp[0]+temp[2])/2; |
Sissors | 0:ab0aec01b38e | 134 | else |
Sissors | 0:ab0aec01b38e | 135 | screenPtr->x=(temp[1]+temp[2])/2; |
Sissors | 0:ab0aec01b38e | 136 | |
Sissors | 0:ab0aec01b38e | 137 | temp[0]=(buffer[1][0]+buffer[1][1]+buffer[1][2])/3; |
Sissors | 0:ab0aec01b38e | 138 | temp[1]=(buffer[1][3]+buffer[1][4]+buffer[1][5])/3; |
Sissors | 0:ab0aec01b38e | 139 | temp[2]=(buffer[1][6]+buffer[1][7]+buffer[1][8])/3; |
Sissors | 0:ab0aec01b38e | 140 | m0=temp[0]-temp[1]; |
Sissors | 0:ab0aec01b38e | 141 | m1=temp[1]-temp[2]; |
Sissors | 0:ab0aec01b38e | 142 | m2=temp[2]-temp[0]; |
Sissors | 0:ab0aec01b38e | 143 | m0=m0>0?m0:(-m0); |
Sissors | 0:ab0aec01b38e | 144 | m1=m1>0?m1:(-m1); |
Sissors | 0:ab0aec01b38e | 145 | m2=m2>0?m2:(-m2); |
Sissors | 0:ab0aec01b38e | 146 | if( (m0>THRESHOLD) && (m1>THRESHOLD) && (m2>THRESHOLD) ) return 0; |
Sissors | 0:ab0aec01b38e | 147 | |
Sissors | 0:ab0aec01b38e | 148 | if(m0<m1) |
Sissors | 0:ab0aec01b38e | 149 | { |
Sissors | 0:ab0aec01b38e | 150 | if(m2<m0) |
Sissors | 0:ab0aec01b38e | 151 | screenPtr->y=(temp[0]+temp[2])/2; |
Sissors | 0:ab0aec01b38e | 152 | else |
Sissors | 0:ab0aec01b38e | 153 | screenPtr->y=(temp[0]+temp[1])/2; |
Sissors | 0:ab0aec01b38e | 154 | } |
Sissors | 0:ab0aec01b38e | 155 | else if(m2<m1) |
Sissors | 0:ab0aec01b38e | 156 | screenPtr->y=(temp[0]+temp[2])/2; |
Sissors | 0:ab0aec01b38e | 157 | else |
Sissors | 0:ab0aec01b38e | 158 | screenPtr->y=(temp[1]+temp[2])/2; |
Sissors | 0:ab0aec01b38e | 159 | return 1; |
Sissors | 0:ab0aec01b38e | 160 | } |
Sissors | 0:ab0aec01b38e | 161 | return 0; |
Sissors | 0:ab0aec01b38e | 162 | } |
Sissors | 0:ab0aec01b38e | 163 | |
Sissors | 0:ab0aec01b38e | 164 | uint8_t TouchScreenADS7843::setCalibrationMatrix( Coordinate * displayPtr, |
Sissors | 0:ab0aec01b38e | 165 | Coordinate * screenPtr, |
Sissors | 0:ab0aec01b38e | 166 | Matrix * matrixPtr) |
Sissors | 0:ab0aec01b38e | 167 | { |
Sissors | 0:ab0aec01b38e | 168 | uint8_t retTHRESHOLD = 0 ; |
Sissors | 0:ab0aec01b38e | 169 | // K = (Xs0 - Xs2)*(Ys1 - Ys2) - (Xs1 - Xs2)*(Ys0 - Ys2) |
Sissors | 0:ab0aec01b38e | 170 | matrixPtr->Divider = ((screenPtr[0].x - screenPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) - |
Sissors | 0:ab0aec01b38e | 171 | ((screenPtr[1].x - screenPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ; |
Sissors | 0:ab0aec01b38e | 172 | if( matrixPtr->Divider == 0 ) |
Sissors | 0:ab0aec01b38e | 173 | { |
Sissors | 0:ab0aec01b38e | 174 | retTHRESHOLD = 1; |
Sissors | 0:ab0aec01b38e | 175 | } |
Sissors | 0:ab0aec01b38e | 176 | else |
Sissors | 0:ab0aec01b38e | 177 | { |
Sissors | 0:ab0aec01b38e | 178 | // (Xd0 - Xd2)*(Ys1 - Ys2) - (Xd1 - Xd2)*(Ys0 - Ys2) |
Sissors | 0:ab0aec01b38e | 179 | // A = --------------------------------------------------- |
Sissors | 0:ab0aec01b38e | 180 | // K |
Sissors | 0:ab0aec01b38e | 181 | matrixPtr->An = ((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].y - screenPtr[2].y)) - |
Sissors | 0:ab0aec01b38e | 182 | ((displayPtr[1].x - displayPtr[2].x) * (screenPtr[0].y - screenPtr[2].y)) ; |
Sissors | 0:ab0aec01b38e | 183 | // (Xs0 - Xs2)*(Xd1 - Xd2) - (Xd0 - Xd2)*(Xs1 - Xs2) |
Sissors | 0:ab0aec01b38e | 184 | // B = --------------------------------------------------- |
Sissors | 0:ab0aec01b38e | 185 | // K |
Sissors | 0:ab0aec01b38e | 186 | matrixPtr->Bn = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].x - displayPtr[2].x)) - |
Sissors | 0:ab0aec01b38e | 187 | ((displayPtr[0].x - displayPtr[2].x) * (screenPtr[1].x - screenPtr[2].x)) ; |
Sissors | 0:ab0aec01b38e | 188 | // Ys0*(Xs2*Xd1 - Xs1*Xd2) + Ys1*(Xs0*Xd2 - Xs2*Xd0) + Ys2*(Xs1*Xd0 - Xs0*Xd1) |
Sissors | 0:ab0aec01b38e | 189 | // C = ---------------------------------------------------------------------------- |
Sissors | 0:ab0aec01b38e | 190 | // K |
Sissors | 0:ab0aec01b38e | 191 | matrixPtr->Cn = (screenPtr[2].x * displayPtr[1].x - screenPtr[1].x * displayPtr[2].x) * screenPtr[0].y + |
Sissors | 0:ab0aec01b38e | 192 | (screenPtr[0].x * displayPtr[2].x - screenPtr[2].x * displayPtr[0].x) * screenPtr[1].y + |
Sissors | 0:ab0aec01b38e | 193 | (screenPtr[1].x * displayPtr[0].x - screenPtr[0].x * displayPtr[1].x) * screenPtr[2].y ; |
Sissors | 0:ab0aec01b38e | 194 | // (Yd0 - Yd2)*(Ys1 - Ys2) - (Yd1 - Yd2)*(Ys0 - Ys2) |
Sissors | 0:ab0aec01b38e | 195 | // D = --------------------------------------------------- |
Sissors | 0:ab0aec01b38e | 196 | // K |
Sissors | 0:ab0aec01b38e | 197 | matrixPtr->Dn = ((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].y - screenPtr[2].y)) - |
Sissors | 0:ab0aec01b38e | 198 | ((displayPtr[1].y - displayPtr[2].y) * (screenPtr[0].y - screenPtr[2].y)) ; |
Sissors | 0:ab0aec01b38e | 199 | // (Xs0 - Xs2)*(Yd1 - Yd2) - (Yd0 - Yd2)*(Xs1 - Xs2) |
Sissors | 0:ab0aec01b38e | 200 | // E = --------------------------------------------------- |
Sissors | 0:ab0aec01b38e | 201 | // K |
Sissors | 0:ab0aec01b38e | 202 | matrixPtr->En = ((screenPtr[0].x - screenPtr[2].x) * (displayPtr[1].y - displayPtr[2].y)) - |
Sissors | 0:ab0aec01b38e | 203 | ((displayPtr[0].y - displayPtr[2].y) * (screenPtr[1].x - screenPtr[2].x)) ; |
Sissors | 0:ab0aec01b38e | 204 | // Ys0*(Xs2*Yd1 - Xs1*Yd2) + Ys1*(Xs0*Yd2 - Xs2*Yd0) + Ys2*(Xs1*Yd0 - Xs0*Yd1) |
Sissors | 0:ab0aec01b38e | 205 | // F = ---------------------------------------------------------------------------- |
Sissors | 0:ab0aec01b38e | 206 | // K |
Sissors | 0:ab0aec01b38e | 207 | matrixPtr->Fn = (screenPtr[2].x * displayPtr[1].y - screenPtr[1].x * displayPtr[2].y) * screenPtr[0].y + |
Sissors | 0:ab0aec01b38e | 208 | (screenPtr[0].x * displayPtr[2].y - screenPtr[2].x * displayPtr[0].y) * screenPtr[1].y + |
Sissors | 0:ab0aec01b38e | 209 | (screenPtr[1].x * displayPtr[0].y - screenPtr[0].x * displayPtr[1].y) * screenPtr[2].y ; |
Sissors | 0:ab0aec01b38e | 210 | } |
Sissors | 0:ab0aec01b38e | 211 | return( retTHRESHOLD ) ; |
Sissors | 0:ab0aec01b38e | 212 | } |
Sissors | 0:ab0aec01b38e | 213 | |
Sissors | 0:ab0aec01b38e | 214 | uint8_t TouchScreenADS7843::getDisplayPoint(Coordinate *displayPtr, |
Sissors | 0:ab0aec01b38e | 215 | Coordinate *screenPtr, |
Sissors | 0:ab0aec01b38e | 216 | Matrix *matrixPtr ) |
Sissors | 0:ab0aec01b38e | 217 | { |
Sissors | 0:ab0aec01b38e | 218 | uint8_t retTHRESHOLD = 0 ; |
Sissors | 0:ab0aec01b38e | 219 | |
Sissors | 0:ab0aec01b38e | 220 | if( matrixPtr->Divider != 0 ) |
Sissors | 0:ab0aec01b38e | 221 | { |
Sissors | 0:ab0aec01b38e | 222 | // XD = AX+BY+C |
Sissors | 0:ab0aec01b38e | 223 | displayPtr->x = ( (matrixPtr->An * screenPtr->x) + |
Sissors | 0:ab0aec01b38e | 224 | (matrixPtr->Bn * screenPtr->y) + |
Sissors | 0:ab0aec01b38e | 225 | matrixPtr->Cn |
Sissors | 0:ab0aec01b38e | 226 | ) / matrixPtr->Divider ; |
Sissors | 0:ab0aec01b38e | 227 | // YD = DX+EY+F |
Sissors | 0:ab0aec01b38e | 228 | displayPtr->y = ( (matrixPtr->Dn * screenPtr->x) + |
Sissors | 0:ab0aec01b38e | 229 | (matrixPtr->En * screenPtr->y) + |
Sissors | 0:ab0aec01b38e | 230 | matrixPtr->Fn |
Sissors | 0:ab0aec01b38e | 231 | ) / matrixPtr->Divider ; |
Sissors | 0:ab0aec01b38e | 232 | } |
Sissors | 0:ab0aec01b38e | 233 | else |
Sissors | 0:ab0aec01b38e | 234 | { |
Sissors | 0:ab0aec01b38e | 235 | retTHRESHOLD = 1; |
Sissors | 0:ab0aec01b38e | 236 | } |
Sissors | 0:ab0aec01b38e | 237 | return(retTHRESHOLD); |
Sissors | 0:ab0aec01b38e | 238 | } |
Sissors | 0:ab0aec01b38e | 239 | |
Sissors | 0:ab0aec01b38e | 240 | void TouchScreenADS7843::TouchPanel_Calibrate(Matrix *matrixPtr) |
Sissors | 0:ab0aec01b38e | 241 | { |
Sissors | 0:ab0aec01b38e | 242 | uint8_t i; |
Sissors | 0:ab0aec01b38e | 243 | Coordinate screen_cal; |
Sissors | 0:ab0aec01b38e | 244 | setCalibrationMatrix( &DisplaySample[0],&ScreenSample[0],matrixPtr ) ; |
Sissors | 0:ab0aec01b38e | 245 | set_font((unsigned char*) Arial12x12); |
Sissors | 0:ab0aec01b38e | 246 | for(i=0;i<3;i++) |
Sissors | 0:ab0aec01b38e | 247 | { |
Sissors | 0:ab0aec01b38e | 248 | cls(); |
Sissors | 0:ab0aec01b38e | 249 | locate(10,10); |
Sissors | 0:ab0aec01b38e | 250 | printf("Touch crosshair to calibrate"); |
Sissors | 0:ab0aec01b38e | 251 | wait_ms(500); |
Sissors | 0:ab0aec01b38e | 252 | DrawCross(DisplaySample[i].x,DisplaySample[i].y); |
Sissors | 0:ab0aec01b38e | 253 | do {} while (!Read_Ads7846(&screen_cal)); |
Sissors | 0:ab0aec01b38e | 254 | ScreenSample[i].x= screen_cal.x; ScreenSample[i].y= screen_cal.y; |
Sissors | 0:ab0aec01b38e | 255 | } |
Sissors | 0:ab0aec01b38e | 256 | setCalibrationMatrix( &DisplaySample[0],&ScreenSample[0],matrixPtr ) ; |
Sissors | 0:ab0aec01b38e | 257 | cls(); |
Sissors | 0:ab0aec01b38e | 258 | } |
Sissors | 0:ab0aec01b38e | 259 |