Armand Coetzer / F7_TSKeyboard

Fork of F7_TSKeypad_MultiKey by Armand Coetzer

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers F7_TSKeyboard.cpp Source File

F7_TSKeyboard.cpp

00001 #include "F7_TSKeyboard.h"
00002 #include "mbed.h"
00003 
00004 F7_TSKeyboard::F7_TSKeyboard()
00005 {
00006     btnsize = 35;
00007     state = 0;
00008     key = 0;
00009     Caps = 0;
00010     Func = 0;
00011     
00012     status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
00013     if (status != TS_OK) 
00014     {
00015         lcd.Clear(LCD_COLOR_RED);
00016         lcd.SetBackColor(LCD_COLOR_RED);
00017         lcd.SetTextColor(LCD_COLOR_WHITE);
00018         lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE);
00019         while(1);
00020     }
00021     else 
00022     {
00023         OK = 1;
00024         
00025     }
00026     
00027     ticker.attach(callback(this, &F7_TSKeyboard::Detect_isr),0.01);
00028 }
00029 
00030 void F7_TSKeyboard::Detect_isr()
00031 {                 
00032     if(OK)
00033     {       
00034         ts.GetState(&TS_State);
00035         
00036         if (TS_State.touchDetected) 
00037         {            
00038             
00039         ///////////////////////check correct touch//////////////////////////////////////////////////////////////
00040             if(TS_State.touchX[0]>= KeyboardstartX[0][0] && TS_State.touchX[0]<= KeyboardendX[0][0] && TS_State.touchY[0]>= KeyboardstartY[0][0] && TS_State.touchY[0]<= KeyboardendY[0][0] && Keyboard == 1)
00041             {
00042                 correcttouch = 1;
00043                 button = 1; 
00044                 if(button == key)
00045                 {   
00046                     lcd.SetTextColor(LCD_COLOR_GRAY); 
00047                     lcd.FillRect(KeyboardstartX[0][0], KeyboardstartY[0][0], btnsize, btnsize);     
00048                 }
00049                                  
00050             }
00051             else if(TS_State.touchX[0]>= KeyboardstartX[0][1] && TS_State.touchX[0]<= KeyboardendX[0][1] && TS_State.touchY[0]>= KeyboardstartY[0][1] && TS_State.touchY[0]<= KeyboardendY[0][1] && Keyboard == 1)
00052             {
00053                 correcttouch = 1;
00054                 button = 2;
00055                 if(button == key)
00056                 {
00057                     lcd.SetTextColor(LCD_COLOR_GRAY); 
00058                     lcd.FillRect(KeyboardstartX[0][1], KeyboardstartY[0][1], btnsize, btnsize); 
00059                 }
00060             }
00061             else if(TS_State.touchX[0]>= KeyboardstartX[0][2] && TS_State.touchX[0]<= KeyboardendX[0][2] && TS_State.touchY[0]>= KeyboardstartY[0][2] && TS_State.touchY[0]<= KeyboardendY[0][2] && Keyboard == 1)
00062             {
00063                 correcttouch = 1;
00064                 button = 3;
00065                 if(button == key)
00066                 {
00067                     lcd.SetTextColor(LCD_COLOR_GRAY); 
00068                     lcd.FillRect(KeyboardstartX[0][2], KeyboardstartY[0][2], btnsize, btnsize);
00069                 } 
00070             }
00071             else if(TS_State.touchX[0]>= KeyboardstartX[0][3] && TS_State.touchX[0]<= KeyboardendX[0][3] && TS_State.touchY[0]>= KeyboardstartY[0][3] && TS_State.touchY[0]<= KeyboardendY[0][3] && Keyboard == 1)
00072             {
00073                 correcttouch = 1;
00074                 button = 4;
00075                 if(button == key)
00076                 {
00077                     lcd.SetTextColor(LCD_COLOR_GRAY); 
00078                     lcd.FillRect(KeyboardstartX[0][3], KeyboardstartY[0][3], btnsize, btnsize); 
00079                 }
00080             }
00081             else if(TS_State.touchX[0]>= KeyboardstartX[0][4] && TS_State.touchX[0]<= KeyboardendX[0][4] && TS_State.touchY[0]>= KeyboardstartY[0][4] && TS_State.touchY[0]<= KeyboardendY[0][4] && Keyboard == 1)
00082             {
00083                 correcttouch = 1;
00084                 button = 5;
00085                 if(button == key)
00086                 {
00087                     lcd.SetTextColor(LCD_COLOR_GRAY); 
00088                     lcd.FillRect(KeyboardstartX[0][4], KeyboardstartY[0][4], btnsize, btnsize);
00089                 } 
00090             }
00091             else if(TS_State.touchX[0]>= KeyboardstartX[0][5] && TS_State.touchX[0]<= KeyboardendX[0][5] && TS_State.touchY[0]>= KeyboardstartY[0][5] && TS_State.touchY[0]<= KeyboardendY[0][5] && Keyboard == 1)
00092             {
00093                 correcttouch = 1;
00094                 button = 6;
00095                 if(button == key)
00096                 {
00097                     lcd.SetTextColor(LCD_COLOR_GRAY); 
00098                     lcd.FillRect(KeyboardstartX[0][5], KeyboardstartY[0][5], btnsize, btnsize); 
00099                 }
00100             }
00101             else if(TS_State.touchX[0]>= KeyboardstartX[0][6] && TS_State.touchX[0]<= KeyboardendX[0][6] && TS_State.touchY[0]>= KeyboardstartY[0][6] && TS_State.touchY[0]<= KeyboardendY[0][6] && Keyboard == 1)
00102             {
00103                 correcttouch = 1;
00104                 button = 7;
00105                 if(button == key)
00106                 {
00107                     lcd.SetTextColor(LCD_COLOR_GRAY); 
00108                     lcd.FillRect(KeyboardstartX[0][6], KeyboardstartY[0][6], btnsize, btnsize);
00109                 } 
00110             }
00111             else if(TS_State.touchX[0]>= KeyboardstartX[0][7] && TS_State.touchX[0]<= KeyboardendX[0][7] && TS_State.touchY[0]>= KeyboardstartY[0][7] && TS_State.touchY[0]<= KeyboardendY[0][7] && Keyboard == 1)
00112             {
00113                 correcttouch = 1;
00114                 button = 8;
00115                 if(button == key)
00116                 {
00117                     lcd.SetTextColor(LCD_COLOR_GRAY); 
00118                     lcd.FillRect(KeyboardstartX[0][7], KeyboardstartY[0][7], btnsize, btnsize);
00119                 } 
00120             }
00121             else if(TS_State.touchX[0]>= KeyboardstartX[0][8] && TS_State.touchX[0]<= KeyboardendX[0][8] && TS_State.touchY[0]>= KeyboardstartY[0][8] && TS_State.touchY[0]<= KeyboardendY[0][8] && Keyboard == 1)
00122             {
00123                 correcttouch = 1;
00124                 button = 9;
00125                 if(button == key)
00126                 {
00127                     lcd.SetTextColor(LCD_COLOR_GRAY); 
00128                     lcd.FillRect(KeyboardstartX[0][8], KeyboardstartY[0][8], btnsize, btnsize); 
00129                 }
00130             }
00131             else if(TS_State.touchX[0]>= KeyboardstartX[0][9] && TS_State.touchX[0]<= KeyboardendX[0][9] && TS_State.touchY[0]>= KeyboardstartY[0][9] && TS_State.touchY[0]<= KeyboardendY[0][9] && Keyboard == 1)
00132             {
00133                 correcttouch = 1;
00134                 button = 10;
00135                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00136                 lcd.FillRect(KeyboardstartX[0][9], KeyboardstartY[0][9], btnsize, btnsize); 
00137             }
00138             else if(TS_State.touchX[0]>= KeyboardstartX[1][0] && TS_State.touchX[0]<= KeyboardendX[1][0] && TS_State.touchY[0]>= KeyboardstartY[1][0] && TS_State.touchY[0]<= KeyboardendY[1][0] && Keyboard == 1)
00139             {
00140                 correcttouch = 1;
00141                 button = 11;
00142                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00143                 lcd.FillRect(KeyboardstartX[1][0], KeyboardstartY[1][0], btnsize, btnsize); 
00144             }
00145             else if(TS_State.touchX[0]>= KeyboardstartX[1][1] && TS_State.touchX[0]<= KeyboardendX[1][1] && TS_State.touchY[0]>= KeyboardstartY[1][1] && TS_State.touchY[0]<= KeyboardendY[1][1] && Keyboard == 1)
00146             {
00147                 correcttouch = 1;
00148                 button = 12;
00149                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00150                 lcd.FillRect(KeyboardstartX[1][1], KeyboardstartY[1][1], btnsize, btnsize); 
00151             }
00152             else if(TS_State.touchX[0]>= KeyboardstartX[1][2] && TS_State.touchX[0]<= KeyboardendX[1][2] && TS_State.touchY[0]>= KeyboardstartY[1][2] && TS_State.touchY[0]<= KeyboardendY[1][2] && Keyboard == 1)
00153             {
00154                 correcttouch = 1;
00155                 button = 13;
00156                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00157                 lcd.FillRect(KeyboardstartX[1][2], KeyboardstartY[1][2], btnsize, btnsize); 
00158             }
00159             else if(TS_State.touchX[0]>= KeyboardstartX[1][3] && TS_State.touchX[0]<= KeyboardendX[1][3] && TS_State.touchY[0]>= KeyboardstartY[1][3] && TS_State.touchY[0]<= KeyboardendY[1][3] && Keyboard == 1)
00160             {
00161                 correcttouch = 1;
00162                 button = 14;
00163                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00164                 lcd.FillRect(KeyboardstartX[1][3], KeyboardstartY[1][3], btnsize, btnsize); 
00165             }
00166             else if(TS_State.touchX[0]>= KeyboardstartX[1][4] && TS_State.touchX[0]<= KeyboardendX[1][4] && TS_State.touchY[0]>= KeyboardstartY[1][4] && TS_State.touchY[0]<= KeyboardendY[1][4] && Keyboard == 1)
00167             {
00168                 correcttouch = 1;
00169                 button = 15;
00170                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00171                 lcd.FillRect(KeyboardstartX[1][4], KeyboardstartY[1][4], btnsize, btnsize); 
00172             }
00173             else if(TS_State.touchX[0]>= KeyboardstartX[1][5] && TS_State.touchX[0]<= KeyboardendX[1][5] && TS_State.touchY[0]>= KeyboardstartY[1][5] && TS_State.touchY[0]<= KeyboardendY[1][5] && Keyboard == 1)
00174             {
00175                 correcttouch = 1;
00176                 button = 16;
00177                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00178                 lcd.FillRect(KeyboardstartX[1][5], KeyboardstartY[1][5], btnsize, btnsize); 
00179             }
00180             else if(TS_State.touchX[0]>= KeyboardstartX[1][6] && TS_State.touchX[0]<= KeyboardendX[1][6] && TS_State.touchY[0]>= KeyboardstartY[1][6] && TS_State.touchY[0]<= KeyboardendY[1][6] && Keyboard == 1)
00181             {
00182                 correcttouch = 1;
00183                 button = 17;
00184                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00185                 lcd.FillRect(KeyboardstartX[1][6], KeyboardstartY[1][6], btnsize, btnsize); 
00186             }
00187             else if(TS_State.touchX[0]>= KeyboardstartX[1][7] && TS_State.touchX[0]<= KeyboardendX[1][7] && TS_State.touchY[0]>= KeyboardstartY[1][7] && TS_State.touchY[0]<= KeyboardendY[1][7] && Keyboard == 1)
00188             {
00189                 correcttouch = 1;
00190                 button = 18;
00191                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00192                 lcd.FillRect(KeyboardstartX[1][7], KeyboardstartY[1][7], btnsize, btnsize); 
00193             }
00194             else if(TS_State.touchX[0]>= KeyboardstartX[1][8] && TS_State.touchX[0]<= KeyboardendX[1][8] && TS_State.touchY[0]>= KeyboardstartY[1][8] && TS_State.touchY[0]<= KeyboardendY[1][8] && Keyboard == 1)
00195             {
00196                 correcttouch = 1;
00197                 button = 19;
00198                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00199                 lcd.FillRect(KeyboardstartX[1][8], KeyboardstartY[1][8], btnsize, btnsize); 
00200             }
00201             else if(TS_State.touchX[0]>= KeyboardstartX[1][9] && TS_State.touchX[0]<= KeyboardendX[1][9] && TS_State.touchY[0]>= KeyboardstartY[1][9] && TS_State.touchY[0]<= KeyboardendY[1][9] && Keyboard == 1)
00202             {
00203                 correcttouch = 1;
00204                 button = 20;
00205                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00206                 lcd.FillRect(KeyboardstartX[1][9], KeyboardstartY[1][9], btnsize, btnsize); 
00207             }
00208             else if(TS_State.touchX[0]>= KeyboardstartX[2][0] && TS_State.touchX[0]<= KeyboardendX[2][0] && TS_State.touchY[0]>= KeyboardstartY[2][0] && TS_State.touchY[0]<= KeyboardendY[2][0] && Keyboard == 1)
00209             {
00210                 correcttouch = 1;
00211                 button = 21;
00212                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00213                 lcd.FillRect(KeyboardstartX[2][0], KeyboardstartY[2][0], btnsize, btnsize); 
00214             }
00215             else if(TS_State.touchX[0]>= KeyboardstartX[2][1] && TS_State.touchX[0]<= KeyboardendX[2][1] && TS_State.touchY[0]>= KeyboardstartY[2][1] && TS_State.touchY[0]<= KeyboardendY[2][1] && Keyboard == 1)
00216             {
00217                 correcttouch = 1;
00218                 button = 22;
00219                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00220                 lcd.FillRect(KeyboardstartX[2][1], KeyboardstartY[2][1], btnsize, btnsize); 
00221             }
00222             else if(TS_State.touchX[0]>= KeyboardstartX[2][2] && TS_State.touchX[0]<= KeyboardendX[2][2] && TS_State.touchY[0]>= KeyboardstartY[2][2] && TS_State.touchY[0]<= KeyboardendY[2][2] && Keyboard == 1)
00223             {
00224                 correcttouch = 1;
00225                 button = 23;
00226                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00227                 lcd.FillRect(KeyboardstartX[2][2], KeyboardstartY[2][2], btnsize, btnsize); 
00228             }
00229             else if(TS_State.touchX[0]>= KeyboardstartX[2][3] && TS_State.touchX[0]<= KeyboardendX[2][3] && TS_State.touchY[0]>= KeyboardstartY[2][3] && TS_State.touchY[0]<= KeyboardendY[2][3] && Keyboard == 1)
00230             {
00231                 correcttouch = 1; 
00232                 button = 24;
00233                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00234                 lcd.FillRect(KeyboardstartX[2][3], KeyboardstartY[2][3], btnsize, btnsize); 
00235             }
00236             else if(TS_State.touchX[0]>= KeyboardstartX[2][4] && TS_State.touchX[0]<= KeyboardendX[2][4] && TS_State.touchY[0]>= KeyboardstartY[2][4] && TS_State.touchY[0]<= KeyboardendY[2][4] && Keyboard == 1)
00237             {
00238                 correcttouch = 1;
00239                 button = 25;
00240                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00241                 lcd.FillRect(KeyboardstartX[2][4], KeyboardstartY[2][4], btnsize, btnsize); 
00242             }
00243             else if(TS_State.touchX[0]>= KeyboardstartX[2][5] && TS_State.touchX[0]<= KeyboardendX[2][5] && TS_State.touchY[0]>= KeyboardstartY[2][5] && TS_State.touchY[0]<= KeyboardendY[2][5] && Keyboard == 1)
00244             {
00245                 correcttouch = 1;
00246                 button = 26;
00247                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00248                 lcd.FillRect(KeyboardstartX[2][5], KeyboardstartY[2][5], btnsize, btnsize); 
00249             }
00250             else if(TS_State.touchX[0]>= KeyboardstartX[2][6] && TS_State.touchX[0]<= KeyboardendX[2][6] && TS_State.touchY[0]>= KeyboardstartY[2][6] && TS_State.touchY[0]<= KeyboardendY[2][6] && Keyboard == 1)
00251             {
00252                 correcttouch = 1;
00253                 button = 27;
00254                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00255                 lcd.FillRect(KeyboardstartX[2][6], KeyboardstartY[2][6], btnsize, btnsize); 
00256             }
00257             else if(TS_State.touchX[0]>= KeyboardstartX[2][7] && TS_State.touchX[0]<= KeyboardendX[2][7] && TS_State.touchY[0]>= KeyboardstartY[2][7] && TS_State.touchY[0]<= KeyboardendY[2][7] && Keyboard == 1)
00258             {
00259                 correcttouch = 1;
00260                 button = 28;
00261                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00262                 lcd.FillRect(KeyboardstartX[2][7], KeyboardstartY[2][7], btnsize, btnsize); 
00263             }
00264             else if(TS_State.touchX[0]>= KeyboardstartX[2][8] && TS_State.touchX[0]<= KeyboardendX[2][8] && TS_State.touchY[0]>= KeyboardstartY[2][8] && TS_State.touchY[0]<= KeyboardendY[2][8] && Keyboard == 1)
00265             {
00266                 correcttouch = 1;
00267                 button = 29;
00268                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00269                 lcd.FillRect(KeyboardstartX[2][8], KeyboardstartY[2][8], btnsize, btnsize); 
00270             }
00271             else if(TS_State.touchX[0]>= KeyboardstartX[2][9] && TS_State.touchX[0]<= KeyboardendX[2][9] && TS_State.touchY[0]>= KeyboardstartY[2][9] && TS_State.touchY[0]<= KeyboardendY[2][9] && Keyboard == 1)
00272             {
00273                 correcttouch = 1;
00274                 button = 30;
00275                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00276                 lcd.FillRect(KeyboardstartX[2][9], KeyboardstartY[2][9], btnsize, btnsize); 
00277             }
00278             else if(TS_State.touchX[0]>= KeyboardstartX[3][0] && TS_State.touchX[0]<= KeyboardendX[3][0] && TS_State.touchY[0]>= KeyboardstartY[3][0] && TS_State.touchY[0]<= KeyboardendY[3][0] && Keyboard == 1)
00279             {
00280                 correcttouch = 1;
00281                 button = 31;
00282                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00283                 lcd.FillRect(KeyboardstartX[3][0], KeyboardstartY[3][0], btnsize, btnsize); 
00284             }
00285             else if(TS_State.touchX[0]>= KeyboardstartX[3][1] && TS_State.touchX[0]<= KeyboardendX[3][1] && TS_State.touchY[0]>= KeyboardstartY[3][1] && TS_State.touchY[0]<= KeyboardendY[3][1] && Keyboard == 1)
00286             {
00287                correcttouch = 1; 
00288                button = 32;  
00289                lcd.SetTextColor(LCD_COLOR_GRAY); 
00290                lcd.FillRect(KeyboardstartX[3][1], KeyboardstartY[3][1], btnsize, btnsize);  
00291             }
00292             else if(TS_State.touchX[0]>= KeyboardstartX[3][2] && TS_State.touchX[0]<= KeyboardendX[3][2] && TS_State.touchY[0]>= KeyboardstartY[3][2] && TS_State.touchY[0]<= KeyboardendY[3][2] && Keyboard == 1)
00293             {
00294                correcttouch = 1; 
00295                button = 33;
00296                lcd.SetTextColor(LCD_COLOR_GRAY); 
00297                lcd.FillRect(KeyboardstartX[3][2], KeyboardstartY[3][2], btnsize, btnsize);    
00298             }
00299             else if(TS_State.touchX[0]>= KeyboardstartX[3][3] && TS_State.touchX[0]<= KeyboardendX[3][3] && TS_State.touchY[0]>= KeyboardstartY[3][3] && TS_State.touchY[0]<= KeyboardendY[3][3] && Keyboard == 1)
00300             {
00301                correcttouch = 1; 
00302                button = 34;
00303                lcd.SetTextColor(LCD_COLOR_GRAY); 
00304                lcd.FillRect(KeyboardstartX[3][3], KeyboardstartY[3][3], btnsize, btnsize);    
00305             }
00306             else if(TS_State.touchX[0]>= KeyboardstartX[3][4] && TS_State.touchX[0]<= KeyboardendX[3][4] && TS_State.touchY[0]>= KeyboardstartY[3][4] && TS_State.touchY[0]<= KeyboardendY[3][4] && Keyboard == 1)
00307             {
00308                 correcttouch = 1;
00309                 button = 35;
00310                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00311                 lcd.FillRect(KeyboardstartX[3][4], KeyboardstartY[3][4], btnsize, btnsize); 
00312             }
00313             else if(TS_State.touchX[0]>= KeyboardstartX[3][5] && TS_State.touchX[0]<= KeyboardendX[3][5] && TS_State.touchY[0]>= KeyboardstartY[3][5] && TS_State.touchY[0]<= KeyboardendY[3][5] && Keyboard == 1)
00314             {
00315                 correcttouch = 1;
00316                 button = 36;
00317                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00318                 lcd.FillRect(KeyboardstartX[3][5], KeyboardstartY[3][5], btnsize, btnsize); 
00319             }
00320             else if(TS_State.touchX[0]>= KeyboardstartX[3][6] && TS_State.touchX[0]<= KeyboardendX[3][6] && TS_State.touchY[0]>= KeyboardstartY[3][6] && TS_State.touchY[0]<= KeyboardendY[3][6] && Keyboard == 1)
00321             {
00322                 correcttouch = 1;
00323                 button = 37;
00324                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00325                 lcd.FillRect(KeyboardstartX[3][6], KeyboardstartY[3][6], btnsize, btnsize); 
00326             }
00327             else if(TS_State.touchX[0]>= KeyboardstartX[3][7] && TS_State.touchX[0]<= KeyboardendX[3][7] && TS_State.touchY[0]>= KeyboardstartY[3][7] && TS_State.touchY[0]<= KeyboardendY[3][7] && Keyboard == 1)
00328             {
00329                 correcttouch = 1;
00330                 button = 38;
00331                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00332                 lcd.FillRect(KeyboardstartX[3][7], KeyboardstartY[3][7], btnsize, btnsize); 
00333             }
00334             else if(TS_State.touchX[0]>= KeyboardstartX[3][8] && TS_State.touchX[0]<= KeyboardendX[3][8] && TS_State.touchY[0]>= KeyboardstartY[3][8] && TS_State.touchY[0]<= KeyboardendY[3][8] && Keyboard == 1)
00335             {
00336                 correcttouch = 1;
00337                 button = 39;
00338                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00339                 lcd.FillRect(KeyboardstartX[3][8], KeyboardstartY[3][8], btnsize, btnsize); 
00340             }
00341             else if(TS_State.touchX[0]>= KeyboardstartX[3][9] && TS_State.touchX[0]<= KeyboardendX[3][9] && TS_State.touchY[0]>= KeyboardstartY[3][9] && TS_State.touchY[0]<= KeyboardendY[3][9] && Keyboard == 1)
00342             {
00343                 correcttouch = 1;
00344                 button = 40;
00345                 lcd.SetTextColor(LCD_COLOR_GRAY); 
00346                 lcd.FillRect(KeyboardstartX[3][9], KeyboardstartY[3][9], btnsize, btnsize); 
00347             }
00348             else if(TS_State.touchX[0]>= KeyboardstartX[3][2] && TS_State.touchX[0]<= KeyboardendX[3][2] + 190 && TS_State.touchY[0]>= KeyboardstartY[3][2] + 38 && TS_State.touchY[0]<= KeyboardendY[3][2] + 38 && Keyboard == 1)
00349             {
00350                correcttouch = 1; 
00351                button = 41;
00352                lcd.SetTextColor(LCD_COLOR_GRAY); 
00353                lcd.FillRect(KeyboardstartX[3][2], KeyboardstartY[3][2] + 38, 225, btnsize);    
00354             }
00355             else if(TS_State.touchX[0]>= KeyboardstartX[3][0] && TS_State.touchX[0]<= KeyboardendX[3][0] + 38 && TS_State.touchY[0]>= KeyboardstartY[3][0] + 38 && TS_State.touchY[0]<= KeyboardendY[3][0] + 38 && Keyboard == 1)
00356             {
00357                correcttouch = 1; 
00358                button = 42;
00359                lcd.SetTextColor(LCD_COLOR_GRAY); 
00360                lcd.FillRect(KeyboardstartX[3][0], KeyboardstartY[3][0] + 38, 73, btnsize);    
00361             }
00362             else if(TS_State.touchX[0]>= KeyboardstartX[3][8] && TS_State.touchX[0]<= KeyboardendX[3][8] && TS_State.touchY[0]>= KeyboardstartY[3][8] + 38 && TS_State.touchY[0]<= KeyboardendY[3][8] + 38 && Keyboard == 1)
00363             {
00364                correcttouch = 1; 
00365                button = 43;
00366                lcd.SetTextColor(LCD_COLOR_GRAY); 
00367                lcd.FillRect(KeyboardstartX[3][8], KeyboardstartY[3][8] + 38, btnsize, btnsize);    
00368             }
00369             else if(TS_State.touchX[0]>= KeyboardstartX[3][9] && TS_State.touchX[0]<= KeyboardendX[3][9] + 38 && TS_State.touchY[0]>= KeyboardstartY[3][9] + 38 && TS_State.touchY[0]<= KeyboardendY[3][9] + 38 && Keyboard == 1)
00370             {
00371                correcttouch = 1; 
00372                button = 44;
00373                lcd.SetTextColor(LCD_COLOR_GRAY); 
00374                lcd.FillRect(KeyboardstartX[3][9], KeyboardstartY[3][9] + 38, 73, btnsize);    
00375             }
00376             else if(TS_State.touchX[0]>= KeyboardstartX[0][9] + 38 && TS_State.touchX[0]<= KeyboardendX[0][9] + 38 && TS_State.touchY[0]>= KeyboardstartY[0][9] && TS_State.touchY[0]<= KeyboardendY[0][9] + 38 && Keyboard == 1)
00377             {
00378                correcttouch = 1; 
00379                button = 45;
00380                lcd.SetTextColor(LCD_COLOR_GRAY); 
00381                lcd.FillRect(KeyboardstartX[0][9] + 38, KeyboardstartY[0][9], btnsize, 73);    
00382             }
00383             else if(TS_State.touchX[0]>= KeyboardstartX[2][9] + 38 && TS_State.touchX[0]<= KeyboardendX[2][9] + 38 && TS_State.touchY[0]>= KeyboardstartY[2][9] && TS_State.touchY[0]<= KeyboardendY[2][9] + 38 && Keyboard == 1)
00384             {
00385                correcttouch = 1; 
00386                button = 46;
00387                lcd.SetTextColor(LCD_COLOR_GRAY); 
00388                lcd.FillRect(KeyboardstartX[2][9] + 38, KeyboardstartY[2][9], btnsize, 73);    
00389             }
00390             else
00391             {
00392                 correcttouch = 0;  
00393                 button = 0;                 
00394             }  
00395         //////////////////////////////////////////////////////////////////////////////////////////////////////      
00396         }
00397     }
00398 }
00399  
00400 void F7_TSKeyboard::getkeys(char str[])
00401 {   
00402     uint8_t text2[40];
00403 
00404     Bckclr    = lcd.GetBackColor();
00405     Txtclr    = lcd.GetTextColor();
00406     *FontSize = *lcd.GetFont();
00407     
00408     lcd.ClearStringLine(0);
00409     DrawKeyboard();
00410     lcd.SetTextColor(LCD_COLOR_WHITE);
00411     lcd.FillRect(0, 0, 480, 20);
00412     
00413     while(Enter != 1)
00414     {     
00415         wait(0.0001);
00416            
00417         switch(state)
00418         {////////check if pressed on screen///////
00419             case 0:
00420             {
00421                 if(TS_State.touchDetected)
00422                 {  
00423                     frstprsx = TS_State.touchX[0];
00424                     frstprsy = TS_State.touchY[0];
00425                     state = 10;
00426                 }
00427              ////////////////////////////////////////              
00428             }break;
00429             ////////check if correctly pressed//////////
00430             case 10:
00431             {                
00432                 for(b = 0; b < 10; b++)
00433                 {
00434                     for(a = 0; a < 4; a++)
00435                     {
00436                         if(frstprsx >= KeyboardstartX[a][b] && frstprsx <= KeyboardendX[a][b] && frstprsy >= KeyboardstartY[a][b] && frstprsy <= KeyboardendY[a][b] || frstprsx >= KeyboardstartX[3][2] && frstprsx <= KeyboardendX[3][2] + 190 && frstprsy >= KeyboardstartY[3][2] + 38 && frstprsy <= KeyboardendY[3][2] + 38 || frstprsx >= KeyboardstartX[3][0] && frstprsx <= KeyboardendX[3][0] + 38 && frstprsy >= KeyboardstartY[3][0] + 38 && frstprsy <= KeyboardendY[3][0] + 38 || frstprsx >= KeyboardstartX[3][8] && frstprsx <= KeyboardendX[3][8] && frstprsy >= KeyboardstartY[3][8] + 38 && frstprsy <= KeyboardendY[3][8] + 38 || frstprsx >= KeyboardstartX[3][9] && frstprsx <= KeyboardendX[3][9] + 38 && frstprsy >= KeyboardstartY[3][9] + 38 && frstprsy <= KeyboardendY[3][9] + 38 || frstprsx >= KeyboardstartX[0][9] + 38 && frstprsx <= KeyboardendX[0][9] + 38 && frstprsy >= KeyboardstartY[0][9] && frstprsy <= KeyboardendY[0][9] + 38 || frstprsx >= KeyboardstartX[2][9] + 38 && frstprsx <= KeyboardendX[2][9] + 38 && frstprsy >= KeyboardstartY[2][9] && frstprsy <= KeyboardendY[2][9] + 38)
00437                         {   
00438                             state = 15;
00439                             correcttouch = 1;
00440                             key = button; 
00441                             a = 9;
00442                             b = 9;
00443                         }
00444                         else
00445                         {   
00446                             state = 30; 
00447                         }
00448                     }    
00449                 }
00450                              
00451             }break;
00452             case 15:
00453             {  
00454                 if(button == key && button != 0)
00455                 {     
00456                     if(TS_State.touchDetected == 0)
00457                     {  
00458                         DrawKeyboard();
00459                         state = 20;               
00460                     }                    
00461                 }
00462                 else if(button != key || button == 0)
00463                 {   
00464                     state = 30;
00465                 } 
00466                 
00467             }break; 
00468             ////////////button functions//////////
00469             case 20:
00470             {   ////////button 1/////////////
00471                 if(button == 1)
00472                 {   
00473                     if(Func == 1 && Caps == 0)
00474                     {
00475                         keypressed = '@';
00476                     }
00477                     else
00478                     {
00479                         keypressed = '1';
00480                     }
00481                     a = 0;
00482                     b = 0;
00483                     correcttouch = 0;
00484                     state = 0;
00485                 }    
00486                 else if(button == 2)
00487                 {   
00488                     if(Func == 1 && Caps == 0)
00489                     {
00490                         keypressed = '#';
00491                     }
00492                     else
00493                     {
00494                         keypressed = '2';
00495                     }
00496                     a = 0;
00497                     b = 0;
00498                     correcttouch = 0;
00499                     state = 0;
00500                 }  
00501                 else if(button == 3)
00502                 {   
00503                     if(Func == 1 && Caps == 0)
00504                     {
00505                         keypressed = '$';
00506                     }
00507                     else
00508                     {
00509                         keypressed = '3';
00510                     }
00511                     a = 0;
00512                     b = 0;
00513                     correcttouch = 0;
00514                     state = 0;
00515                 }    
00516                 else if(button == 4)
00517                 {   
00518                     if(Func == 1 && Caps == 0)
00519                     {
00520                         keypressed = '%';
00521                     }
00522                     else
00523                     {
00524                         keypressed = '4';
00525                     }
00526                     a = 0;
00527                     b = 0;
00528                     correcttouch = 0;
00529                     state = 0;
00530                 }  
00531                 else if(button == 5)
00532                 {   
00533                     if(Func == 1 && Caps == 0)
00534                     {
00535                         keypressed = 38;
00536                     }
00537                     else
00538                     {
00539                         keypressed = '5';
00540                     }
00541                     a = 0;
00542                     b = 0;
00543                     correcttouch = 0;
00544                     state = 0;
00545                 }    
00546                 else if(button == 6)
00547                 {   
00548                     if(Func == 1 && Caps == 0)
00549                     {
00550                         keypressed = '*';
00551                     }
00552                     else
00553                     {
00554                         keypressed = '6';
00555                     }
00556                     a = 0;
00557                     b = 0;
00558                     correcttouch = 0;
00559                     state = 0;
00560                 }    
00561                 else if(button == 7)
00562                 {   
00563                     if(Func == 1 && Caps == 0)
00564                     {
00565                         keypressed = '(';
00566                     }
00567                     else
00568                     {
00569                         keypressed = '7';
00570                     }
00571                     a = 0;
00572                     b = 0;
00573                     correcttouch = 0;
00574                     state = 0;
00575                 }    
00576                 else if(button == 8)
00577                 {   
00578                     if(Func == 1 && Caps == 0)
00579                     {
00580                         keypressed = ')';
00581                     }
00582                     else
00583                     {
00584                         keypressed = '8';
00585                     }
00586                     a = 0;
00587                     b = 0;
00588                     correcttouch = 0;
00589                     state = 0;
00590                 }    
00591                 else if(button == 9)
00592                 {   
00593                     if(Func == 1 && Caps == 0)
00594                     {
00595                         keypressed = '-';
00596                     }
00597                     else
00598                     {
00599                         keypressed = '9';
00600                     }
00601                     a = 0;
00602                     b = 0;
00603                     correcttouch = 0;
00604                     state = 0;
00605                 }    
00606                 else if(button == 10)
00607                 {   
00608                     if(Func == 1 && Caps == 0)
00609                     {
00610                         keypressed = '+';
00611                     }
00612                     else
00613                     {
00614                         keypressed = '0';
00615                     }
00616                     a = 0;
00617                     b = 0;
00618                     correcttouch = 0;
00619                     state = 0;
00620                 }    
00621                 else if(button == 11)
00622                 {   
00623                     if(Func == 1 && Caps == 0)
00624                     {
00625                         keypressed = '=';
00626                     }
00627                     else if(Caps == 1 && Func == 0)
00628                     {
00629                         keypressed = 'Q';
00630                     }
00631                     else
00632                     {
00633                         keypressed = 'q';
00634                     }
00635                     a = 0;
00636                     b = 0;
00637                     correcttouch = 0;
00638                     state = 0;
00639                 }    
00640                 else if(button == 12)
00641                 {   
00642                     if(Func == 1 && Caps == 0)
00643                     {
00644                         keypressed = '_';
00645                     }
00646                     else if(Caps == 1 && Func == 0)
00647                     {
00648                         keypressed = 'W';
00649                     }
00650                     else
00651                     {
00652                         keypressed = 'w';
00653                     }
00654                     a = 0;
00655                     b = 0;
00656                     correcttouch = 0;
00657                     state = 0;
00658                 }    
00659                 else if(button == 13)
00660                 {   
00661                     if(Func == 1 && Caps == 0)
00662                     {
00663                         keypressed = '^';
00664                     }
00665                     else if(Caps == 1 && Func == 0)
00666                     {
00667                         keypressed = 'E';
00668                     }
00669                     else
00670                     {
00671                         keypressed = 'e';
00672                     }
00673                     a = 0;
00674                     b = 0;
00675                     correcttouch = 0;
00676                     state = 0;
00677                 }    
00678                 else if(button == 14)
00679                 {   
00680                     if(Func == 1 && Caps == 0)
00681                     {
00682                         keypressed = ';';
00683                     }
00684                     else if(Caps == 1 && Func == 0)
00685                     {
00686                         keypressed = 'R';
00687                     }
00688                     else
00689                     {
00690                         keypressed = 'r';
00691                     }
00692                     a = 0;
00693                     b = 0;
00694                     correcttouch = 0;
00695                     state = 0;
00696                 }    
00697                 else if(button == 15)
00698                 {   
00699                     if(Func == 1 && Caps == 0)
00700                     {
00701                         keypressed = '"';
00702                     }
00703                     else if(Caps == 1 && Func == 0)
00704                     {
00705                         keypressed = 'T';
00706                     }
00707                     else
00708                     {
00709                         keypressed = 't';
00710                     }
00711                     a = 0;
00712                     b = 0;
00713                     correcttouch = 0;
00714                     state = 0;
00715                 }    
00716                 else if(button == 16)
00717                 {   
00718                     if(Func == 1 && Caps == 0)
00719                     {
00720                         keypressed = '\'';
00721                     }
00722                     else if(Caps == 1 && Func == 0)
00723                     {
00724                         keypressed = 'Y';
00725                     }
00726                     else
00727                     {
00728                         keypressed = 'y';
00729                     }
00730                     a = 0;
00731                     b = 0;
00732                     correcttouch = 0;
00733                     state = 0;
00734                 }   
00735                 else if(button == 17)
00736                 {   
00737                     if(Func == 1 && Caps == 0)
00738                     {
00739                         keypressed = '<';
00740                     }
00741                     else if(Caps == 1 && Func == 0)
00742                     {
00743                         keypressed = 'U';
00744                     }
00745                     else
00746                     {
00747                         keypressed = 'u';
00748                     }
00749                     a = 0;
00750                     b = 0;
00751                     correcttouch = 0;
00752                     state = 0;
00753                 }   
00754                 else if(button == 18)
00755                 {   
00756                     if(Func == 1 && Caps == 0)
00757                     {
00758                         keypressed = '>';
00759                     }
00760                     else if(Caps == 1 && Func == 0)
00761                     {
00762                         keypressed = 'I';
00763                     }
00764                     else
00765                     {
00766                         keypressed = 'i';
00767                     }
00768                     a = 0;
00769                     b = 0;
00770                     correcttouch = 0;
00771                     state = 0;
00772                 }   
00773                 else if(button == 19)
00774                 {   
00775                     if(Func == 1 && Caps == 0)
00776                     {
00777                         keypressed = '/';
00778                     }
00779                     else if(Caps == 1 && Func == 0)
00780                     {
00781                         keypressed = 'O';
00782                     }
00783                     else
00784                     {
00785                         keypressed = 'o';
00786                     }
00787                     a = 0;
00788                     b = 0;
00789                     correcttouch = 0;
00790                     state = 0;
00791                 }   
00792                 else if(button == 20)
00793                 {   
00794                     if(Func == 1 && Caps == 0)
00795                     {
00796                         keypressed = '\\';
00797                     }
00798                     else if(Caps == 1 && Func == 0)
00799                     {
00800                         keypressed = 'P';
00801                     }
00802                     else
00803                     {
00804                         keypressed = 'p';
00805                     }
00806                     a = 0;
00807                     b = 0;
00808                     correcttouch = 0;
00809                     state = 0;
00810                 }   
00811                 else if(button == 21)
00812                 {   
00813                     if(Func == 1 && Caps == 0)
00814                     {
00815                         keypressed = ' ';
00816                     }
00817                     else
00818                     {
00819                         keypressed = ':';
00820                     }
00821                     a = 0;
00822                     b = 0;
00823                     correcttouch = 0;
00824                     state = 0;
00825                 }    
00826                 else if(button == 22)
00827                 {   
00828                     if(Func == 1 && Caps == 0)
00829                     {
00830                         keypressed = ' ';
00831                     }
00832                     else if(Caps == 1 && Func == 0)
00833                     {
00834                         keypressed = 'A';
00835                     }
00836                     else
00837                     {
00838                         keypressed = 'a';
00839                     }
00840                     a = 0;
00841                     b = 0;
00842                     correcttouch = 0;
00843                     state = 0;
00844                 }  
00845                 else if(button == 23)
00846                 {   
00847                     if(Func == 1 && Caps == 0)
00848                     {
00849                         keypressed = '`';
00850                     }
00851                     else if(Caps == 1 && Func == 0)
00852                     {
00853                         keypressed = 'S';
00854                     }
00855                     else
00856                     {
00857                         keypressed = 's';
00858                     }
00859                     a = 0;
00860                     b = 0;
00861                     correcttouch = 0;
00862                     state = 0;
00863                 }    
00864                 else if(button == 24)
00865                 {   
00866                     if(Func == 1 && Caps == 0)
00867                     {
00868                         keypressed = '~';
00869                     }
00870                     else if(Caps == 1 && Func == 0)
00871                     {
00872                         keypressed = 'D';
00873                     }
00874                     else
00875                     {
00876                         keypressed = 'd';
00877                     }
00878                     a = 0;
00879                     b = 0;
00880                     correcttouch = 0;
00881                     state = 0;
00882                 }  
00883                 else if(button == 25)
00884                 {   
00885                     if(Func == 1 && Caps == 0)
00886                     {
00887                         keypressed = '{';
00888                     }
00889                     else if(Caps == 1 && Func == 0)
00890                     {
00891                         keypressed = 'F';
00892                     }
00893                     else
00894                     {
00895                         keypressed = 'f';
00896                     }
00897                     a = 0;
00898                     b = 0;
00899                     correcttouch = 0;
00900                     state = 0;
00901                 }    
00902                 else if(button == 26)
00903                 {   
00904                     if(Func == 1 && Caps == 0)
00905                     {
00906                         keypressed = '}';
00907                     }
00908                     else if(Caps == 1 && Func == 0)
00909                     {
00910                         keypressed = 'G';
00911                     }
00912                     else
00913                     {
00914                         keypressed = 'g';
00915                     }
00916                     a = 0;
00917                     b = 0;
00918                     correcttouch = 0;
00919                     state = 0;
00920                 }    
00921                 else if(button == 27)
00922                 {   
00923                     if(Func == 1 && Caps == 0)
00924                     {
00925                         keypressed = '[';
00926                     }
00927                     else if(Caps == 1 && Func == 0)
00928                     {
00929                         keypressed = 'H';
00930                     }
00931                     else
00932                     {
00933                         keypressed = 'h';
00934                     }
00935                     a = 0;
00936                     b = 0;
00937                     correcttouch = 0;
00938                     state = 0;
00939                 }    
00940                 else if(button == 28)
00941                 {   
00942                     if(Func == 1 && Caps == 0)
00943                     {
00944                         keypressed = ']';
00945                     }
00946                     else if(Caps == 1 && Func == 0)
00947                     {
00948                         keypressed = 'J';
00949                     }
00950                     else
00951                     {
00952                         keypressed = 'j';
00953                     }
00954                     a = 0;
00955                     b = 0;
00956                     correcttouch = 0;
00957                     state = 0;
00958                 }    
00959                 else if(button == 29)
00960                 {   
00961                     if(Func == 1 && Caps == 0)
00962                     {
00963                         keypressed = ' ';
00964                     }
00965                     else if(Caps == 1 && Func == 0)
00966                     {
00967                         keypressed = 'K';
00968                     }
00969                     else
00970                     {
00971                         keypressed = 'k';
00972                     }
00973                     a = 0;
00974                     b = 0;
00975                     correcttouch = 0;
00976                     state = 0;
00977                 }    
00978                 else if(button == 30)
00979                 {   
00980                     if(Func == 1 && Caps == 0)
00981                     {
00982                         keypressed = ' ';
00983                     }
00984                     else if(Caps == 1 && Func == 0)
00985                     {
00986                         keypressed = 'L';
00987                     }
00988                     else
00989                     {
00990                         keypressed = 'l';
00991                     }
00992                     a = 0;
00993                     b = 0;
00994                     correcttouch = 0;
00995                     state = 0;
00996                 }    
00997                 else if(button == 31)
00998                 {   
00999                     if(Func == 1 && Caps == 0)
01000                     {
01001                         keypressed = ' ';
01002                     }
01003                     else
01004                     {
01005                         keypressed = ',';
01006                     }
01007                     a = 0;
01008                     b = 0;
01009                     correcttouch = 0;
01010                     state = 0;
01011                 }    
01012                 else if(button == 32)
01013                 {   
01014                     if(Func == 1 && Caps == 0)
01015                     {
01016                         keypressed = ' ';
01017                     }
01018                     else
01019                     {
01020                         keypressed = '!';
01021                     }
01022                     a = 0;
01023                     b = 0;
01024                     correcttouch = 0;
01025                     state = 0;
01026                 }    
01027                 else if(button == 33)
01028                 {   
01029                     if(Func == 1 && Caps == 0)
01030                     {
01031                         keypressed = ' ';
01032                     }
01033                     else if(Caps == 1 && Func == 0)
01034                     {
01035                         keypressed = 'Z';
01036                     }
01037                     else
01038                     {
01039                         keypressed = 'z';
01040                     }
01041                     a = 0;
01042                     b = 0;
01043                     correcttouch = 0;
01044                     state = 0;
01045                 }    
01046                 else if(button == 34)
01047                 {   
01048                     if(Func == 1 && Caps == 0)
01049                     {
01050                         keypressed = ' ';
01051                     }
01052                     else if(Caps == 1 && Func == 0)
01053                     {
01054                         keypressed = 'X';
01055                     }
01056                     else
01057                     {
01058                         keypressed = 'x';
01059                     }
01060                     a = 0;
01061                     b = 0;
01062                     correcttouch = 0;
01063                     state = 0;
01064                 }    
01065                 else if(button == 35)
01066                 {   
01067                     if(Func == 1 && Caps == 0)
01068                     {
01069                         keypressed = ' ';
01070                     }
01071                     else if(Caps == 1 && Func == 0)
01072                     {
01073                         keypressed = 'C';
01074                     }
01075                     else
01076                     {
01077                         keypressed = 'c';
01078                     }
01079                     a = 0;
01080                     b = 0;
01081                     correcttouch = 0;
01082                     state = 0;
01083                 }    
01084                 else if(button == 36)
01085                 {   
01086                     if(Func == 1 && Caps == 0)
01087                     {
01088                         keypressed = ' ';
01089                     }
01090                     else if(Caps == 1 && Func == 0)
01091                     {
01092                         keypressed = 'V';
01093                     }
01094                     else
01095                     {
01096                         keypressed = 'v';
01097                     }
01098                     a = 0;
01099                     b = 0;
01100                     correcttouch = 0;
01101                     state = 0;
01102                 }   
01103                 else if(button == 37)
01104                 {   
01105                     if(Func == 1 && Caps == 0)
01106                     {
01107                         keypressed = ' ';
01108                     }
01109                     else if(Caps == 1 && Func == 0)
01110                     {
01111                         keypressed = 'B';
01112                     }
01113                     else
01114                     {
01115                         keypressed = 'b';
01116                     }
01117                     a = 0;
01118                     b = 0;
01119                     correcttouch = 0;
01120                     state = 0;
01121                 }   
01122                 else if(button == 38)
01123                 {   
01124                     if(Func == 1 && Caps == 0)
01125                     {
01126                         keypressed = ' ';
01127                     }
01128                     else if(Caps == 1 && Func == 0)
01129                     {
01130                         keypressed = 'N';
01131                     }
01132                     else
01133                     {
01134                         keypressed = 'n';
01135                     }
01136                     a = 0;
01137                     b = 0;
01138                     correcttouch = 0;
01139                     state = 0;
01140                 }   
01141                 else if(button == 39)
01142                 {   
01143                     if(Func == 1 && Caps == 0)
01144                     {
01145                         keypressed = ' ';
01146                     }
01147                     else if(Caps == 1 && Func == 0)
01148                     {
01149                         keypressed = 'M';
01150                     }
01151                     else
01152                     {
01153                         keypressed = 'm';
01154                     }
01155                     a = 0;
01156                     b = 0;
01157                     correcttouch = 0;
01158                     state = 0;
01159                 }   
01160                 else if(button == 40)
01161                 {   
01162                     if(Func == 1 && Caps == 0)
01163                     {
01164                         keypressed = ' ';
01165                     }
01166                     else
01167                     {
01168                         keypressed = '?';
01169                     }
01170                     a = 0;
01171                     b = 0;
01172                     correcttouch = 0;
01173                     state = 0;
01174                 }   
01175                 else if(button == 41)
01176                 {   
01177                     keypressed = ' '; 
01178                     m++;
01179                     textx += 12;
01180                     
01181                     str[m] =  keypressed; 
01182                                
01183                     m -= 1;
01184                     textx -= 12;
01185                     
01186                     str[m] =  keypressed;
01187                 
01188                     m++;
01189                     textx += 12;
01190                     
01191                     a = 0;
01192                     b = 0;
01193                     correcttouch = 0;
01194                     state = 0;
01195                 }   
01196                 else if(button == 42)
01197                 {   
01198                     if(Func != 1)
01199                     {   
01200                         keypressed = ' ';
01201                         Caps = !Caps;
01202                         Func = 0;
01203                         DrawKeyboard();
01204                         a = 0;
01205                         b = 0;
01206                         correcttouch = 0;
01207                     }
01208                     state = 0;
01209                 }  
01210                 else if(button == 43)
01211                 {   
01212                     keypressed = '.';
01213                     a = 0;
01214                     b = 0;
01215                     correcttouch = 0;
01216                     state = 0;
01217                 }    
01218                 else if(button == 44)
01219                 {   
01220                     keypressed = ' ';
01221                     Func = !Func;
01222                     Caps = 0;
01223                     DrawKeyboard();
01224                     a = 0;
01225                     b = 0;
01226                     correcttouch = 0;
01227                     state = 0;
01228                 }  
01229                 else if(button == 45)
01230                 {   
01231                     keypressed = ' ';
01232                     
01233                     if(m != 0 || textx != 0)
01234                     {
01235                         m -= 1;
01236                         textx -= 12;
01237                     }
01238                     
01239                     a = 0;
01240                     b = 0;
01241                     correcttouch = 0;
01242                     state = 0;
01243                 }       
01244                 else if(button == 46)
01245                 {   
01246                     keypressed = '\0';
01247                     Enter = 1;
01248                     a = 0;
01249                     b = 0;
01250                     correcttouch = 0;
01251                     state = 0;
01252                 }
01253                 else
01254                 {
01255                     state = 0;    
01256                 }     
01257                 
01258                 str[m] =  keypressed;
01259                 
01260                 lcd.SetTextColor(LCD_COLOR_BLACK);
01261                 lcd.SetBackColor(LCD_COLOR_WHITE);
01262                 lcd.SetFont(&Font20);
01263                 sprintf((char*)text2, "%c", str[m]);
01264                 lcd.DisplayStringAt(0 + textx, LINE(0), (uint8_t *)&text2, LEFT_MODE);
01265                     
01266                 if(keypressed != ' ')
01267                 {
01268                     m++;
01269                     textx += 12;
01270                 }  
01271                            
01272                 key = 0;
01273                 keypressed = ' ';
01274                 
01275             }break; 
01276             case 30:
01277             {
01278                 if(Keyboard == 1)
01279                 {
01280                     DrawKeyboard();
01281                     Keyboard = 0;
01282                 }
01283                 
01284                 if(TS_State.touchDetected == 0)
01285                 {  
01286                     DrawKeyboard();
01287                     a = 0;
01288                     b = 0;
01289                     correcttouch = 0;
01290                     state = 0;
01291                 }
01292             }break;             
01293         } 
01294     }
01295     
01296     Keyboard = 0;
01297     Enter = 0;
01298     m = 0;
01299     textx = 0;
01300     state = 0;
01301     Caps = 0;
01302     Func = 0;
01303     lcd.ClearStringLine(0);
01304     lcd.SetTextColor(Bckclr);
01305     lcd.FillRect(0, 0, 480, 20);
01306     lcd.FillRect(KeyboardstartX[0][0],KeyboardstartY[0][0], 415, 187);
01307     lcd.SetTextColor(Txtclr);
01308     lcd.SetBackColor(Bckclr);
01309     lcd.SetFont(FontSize);
01310 }
01311 
01312 void F7_TSKeyboard::DrawKeyboard()
01313 {    
01314     int i, o, stepx = 0, stepy = 0, Drawpointx, Drawpointy;
01315     uint8_t text[30];
01316     
01317     
01318         char keyboard1[4][10] = {
01319                                     {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'},
01320                                     {'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'},
01321                                     {':', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'},
01322                                     {',', '!', 'z', 'x', 'c', 'v', 'b', 'n', 'm', '?'}
01323                                 };
01324     
01325     
01326         char keyboard2[4][10] = {
01327                                     {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'},
01328                                     {'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'},
01329                                     {':', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L'},
01330                                     {',', '!', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '?'}
01331                                 };
01332                                 
01333         char keyboard3[4][10] = {
01334                                     {'@', '#', '$', '%', 38, '*', '(', ')', '-', '+'},
01335                                     {'=', '_', '^', ';', '"', '\'', '<', '>', '/', '\\'},
01336                                     {'\0', '\0', '`', '~', '{', '}', '[', ']', '\0', '\0'},
01337                                     {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}
01338                                 };
01339     
01340     Keyboard = 1;
01341     
01342     for(o= 0; o< 10; o++)
01343     {
01344         for(i= 0; i < 4; i++)
01345         {  
01346             lcd.SetTextColor(LCD_COLOR_WHITE);
01347              
01348             lcd.FillRect(Drawpointx = 33 + stepx, Drawpointy  = 75 + stepy, btnsize, btnsize);
01349             KeyboardstartX[i][o] = Drawpointx;
01350             KeyboardstartY[i][o] = Drawpointy;
01351             KeyboardendX[i][o] = Drawpointx + btnsize;
01352             KeyboardendY[i][o] = Drawpointy + btnsize;
01353             stepy += 38;
01354             
01355             if(Caps == 0 && Func == 0)
01356             {
01357                 lcd.SetBackColor(LCD_COLOR_WHITE);
01358                 lcd.SetTextColor(LCD_COLOR_BLACK);
01359                 lcd.SetFont(&Font16);
01360                 sprintf((char*)text, "%c", keyboard1[i][o]);
01361                 lcd.DisplayStringAt(Drawpointx+ 13, Drawpointy+ 13, (uint8_t *)&text, LEFT_MODE);
01362             }
01363             else if(Caps == 1 && Func == 0)
01364             {
01365                 lcd.SetBackColor(LCD_COLOR_WHITE);
01366                 lcd.SetTextColor(LCD_COLOR_BLACK);
01367                 lcd.SetFont(&Font16);
01368                 sprintf((char*)text, "%c", keyboard2[i][o]);
01369                 lcd.DisplayStringAt(Drawpointx+ 13, Drawpointy+ 13, (uint8_t *)&text, LEFT_MODE);
01370             }
01371             else if(Caps == 0 && Func == 1)
01372             {
01373                 lcd.SetBackColor(LCD_COLOR_WHITE);
01374                 lcd.SetTextColor(LCD_COLOR_BLACK);
01375                 lcd.SetFont(&Font16);
01376                 sprintf((char*)text, "%c", keyboard3[i][o]);
01377                 lcd.DisplayStringAt(Drawpointx+ 13, Drawpointy+ 13, (uint8_t *)&text, LEFT_MODE);
01378             }
01379             
01380             
01381             if(stepy > 114)
01382             {
01383                 stepy = 0;
01384             }       
01385         }  
01386         
01387         stepx += 38;     
01388     }
01389     
01390     lcd.SetTextColor(LCD_COLOR_WHITE);
01391     lcd.FillRect(KeyboardstartX[3][2], KeyboardstartY[3][2] + 38, 225, btnsize);
01392     lcd.FillRect(KeyboardstartX[3][0], KeyboardstartY[3][0] + 38, 73, btnsize);
01393     lcd.FillRect(KeyboardstartX[3][8], KeyboardstartY[3][8] + 38, btnsize, btnsize);
01394     lcd.FillRect(KeyboardstartX[3][9], KeyboardstartY[3][9] + 38, 73, btnsize);
01395     lcd.FillRect(KeyboardstartX[0][9] + 38, KeyboardstartY[0][9], btnsize, 73);
01396     lcd.FillRect(KeyboardstartX[2][9] + 38, KeyboardstartY[2][9], btnsize, 73);  
01397     
01398     lcd.SetBackColor(LCD_COLOR_WHITE);
01399     lcd.SetTextColor(LCD_COLOR_BLACK);
01400     lcd.SetFont(&Font16);
01401     
01402     sprintf((char*)text, "<");
01403     lcd.DisplayStringAt(KeyboardstartX[0][9] + 50, KeyboardstartY[0][3] + 35, (uint8_t *)&text, LEFT_MODE);
01404     lcd.SetFont(&Font12);
01405     sprintf((char*)text, "E");
01406     lcd.DisplayStringAt(KeyboardstartX[2][9] + 50, KeyboardstartY[2][9] + 15, (uint8_t *)&text, LEFT_MODE);
01407     sprintf((char*)text, "N");
01408     lcd.DisplayStringAt(KeyboardstartX[2][9] + 50, KeyboardstartY[2][9] + 25, (uint8_t *)&text, LEFT_MODE);
01409     sprintf((char*)text, "T");
01410     lcd.DisplayStringAt(KeyboardstartX[2][9] + 50, KeyboardstartY[2][9] + 35, (uint8_t *)&text, LEFT_MODE);
01411     sprintf((char*)text, "E");
01412     lcd.DisplayStringAt(KeyboardstartX[2][9] + 50, KeyboardstartY[2][9] + 45, (uint8_t *)&text, LEFT_MODE);
01413     sprintf((char*)text, "R");
01414     lcd.DisplayStringAt(KeyboardstartX[2][9] + 50, KeyboardstartY[2][9] + 55, (uint8_t *)&text, LEFT_MODE);
01415     sprintf((char*)text, "CAPS");
01416     lcd.DisplayStringAt(KeyboardstartX[3][0] + 20, KeyboardstartY[3][0] + 50, (uint8_t *)&text, LEFT_MODE);
01417     sprintf((char*)text, ".");
01418     lcd.DisplayStringAt(KeyboardstartX[3][8] + 16, KeyboardstartY[3][8] + 50, (uint8_t *)&text, LEFT_MODE);
01419     sprintf((char*)text, "FUNC");
01420     lcd.DisplayStringAt(KeyboardstartX[3][9] + 20, KeyboardstartY[3][9] + 50, (uint8_t *)&text, LEFT_MODE);
01421     
01422     lcd.SetTextColor(Txtclr);
01423     lcd.SetBackColor(Bckclr);
01424     lcd.SetFont(FontSize);
01425 }