Shish

Dependencies:   mbed USBDevice GLCD

Committer:
pepperu96
Date:
Thu May 06 23:15:31 2021 +0000
Revision:
3:2bf723da1732
Parent:
2:4b3d056967a8
Child:
4:fc3364c83df6
First working version of USB transfer from the board to the PC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
montie97 0:9ae27a35a771 1 #include "mbed.h"
montie97 0:9ae27a35a771 2 #include "GLCD.h"
montie97 0:9ae27a35a771 3 #include "GLCD.c"
montie97 0:9ae27a35a771 4 #include "AsciiLib.c"
montie97 0:9ae27a35a771 5 #include "HzLib.c"
montie97 0:9ae27a35a771 6 #include "USBSerial.h"
montie97 0:9ae27a35a771 7 #include "TouchPanel.h"
protopapaandrea 1:a32ccf18194d 8
pepperu96 2:4b3d056967a8 9 #define DEBUG
montie97 0:9ae27a35a771 10
montie97 0:9ae27a35a771 11 //FUNZIONI GIORGIO
montie97 0:9ae27a35a771 12 void readtouch();
montie97 0:9ae27a35a771 13
montie97 0:9ae27a35a771 14 //VARIABILI GIORGIO
montie97 0:9ae27a35a771 15 Coordinate tocco;
montie97 0:9ae27a35a771 16 int x,y,k,avg_x,avg_y,ready;
montie97 0:9ae27a35a771 17
montie97 0:9ae27a35a771 18 int startGame=0;
montie97 0:9ae27a35a771 19 int isWritten=0;
montie97 0:9ae27a35a771 20 int inferenceStarted=0;
montie97 0:9ae27a35a771 21 uint8_t drawnPoints[28][28];
montie97 0:9ae27a35a771 22 int threshold = 32;
montie97 0:9ae27a35a771 23 USBSerial serial;
montie97 0:9ae27a35a771 24
protopapaandrea 1:a32ccf18194d 25 int charPos;
protopapaandrea 1:a32ccf18194d 26
montie97 0:9ae27a35a771 27 /*Buttons*/
montie97 0:9ae27a35a771 28 typedef enum {space,infer,del} button;
montie97 0:9ae27a35a771 29
montie97 0:9ae27a35a771 30 /* Private function prototypes -----------------------------------------------*/
montie97 0:9ae27a35a771 31 void spaceText(int x1, int x2, int yText, int spessore, uint16_t color);
montie97 0:9ae27a35a771 32 void clearPad(void);
montie97 0:9ae27a35a771 33 void showCompression(void);
montie97 0:9ae27a35a771 34 void clearBar(void);
montie97 0:9ae27a35a771 35 void drawButtons(void);
montie97 0:9ae27a35a771 36 void drawButton(button b, uint16_t color);
montie97 0:9ae27a35a771 37 void start(void);
montie97 0:9ae27a35a771 38 void drawTriangle(int posX, int posY, int lungMax);
protopapaandrea 1:a32ccf18194d 39 void readTouch(void);
montie97 0:9ae27a35a771 40
montie97 0:9ae27a35a771 41 int main() {
montie97 0:9ae27a35a771 42 LCD_Initialization();
montie97 0:9ae27a35a771 43 TP_Init();
protopapaandrea 1:a32ccf18194d 44 TouchPanel_Calibrate();
protopapaandrea 1:a32ccf18194d 45
montie97 0:9ae27a35a771 46 LCD_Clear(Blue2);
montie97 0:9ae27a35a771 47
montie97 0:9ae27a35a771 48 clearBar();
montie97 0:9ae27a35a771 49 drawButtons();
montie97 0:9ae27a35a771 50 start();
montie97 0:9ae27a35a771 51
montie97 0:9ae27a35a771 52 while(1){
protopapaandrea 1:a32ccf18194d 53 readTouch();
protopapaandrea 1:a32ccf18194d 54 wait_us(500);
montie97 0:9ae27a35a771 55 }
montie97 0:9ae27a35a771 56 }
montie97 0:9ae27a35a771 57
montie97 0:9ae27a35a771 58 /*******************************************************************************
montie97 0:9ae27a35a771 59 * Function Name : spaceText
montie97 0:9ae27a35a771 60 * Description :
montie97 0:9ae27a35a771 61 * Input : None
montie97 0:9ae27a35a771 62 * Output : None
montie97 0:9ae27a35a771 63 * Return : None
montie97 0:9ae27a35a771 64 * Attention : None
montie97 0:9ae27a35a771 65 *******************************************************************************/
montie97 0:9ae27a35a771 66 void spaceText(int x1, int x2, int yText, int spessore, uint16_t color){ //Spazio di un unico colore
montie97 0:9ae27a35a771 67 int i;
montie97 0:9ae27a35a771 68 for(i=spessore;i>0;i--){
montie97 0:9ae27a35a771 69 LCD_DrawLine(x1,yText-i,x2,yText-i,color);
montie97 0:9ae27a35a771 70 }
montie97 0:9ae27a35a771 71 return;
montie97 0:9ae27a35a771 72 }
montie97 0:9ae27a35a771 73
montie97 0:9ae27a35a771 74 /*******************************************************************************
montie97 0:9ae27a35a771 75 * Function Name : clearPad
montie97 0:9ae27a35a771 76 * Description :
montie97 0:9ae27a35a771 77 * Input : None
montie97 0:9ae27a35a771 78 * Output : None
montie97 0:9ae27a35a771 79 * Return : None
montie97 0:9ae27a35a771 80 * Attention : None
montie97 0:9ae27a35a771 81 *******************************************************************************/
montie97 0:9ae27a35a771 82 void clearPad(){
montie97 0:9ae27a35a771 83 int i,j;
montie97 0:9ae27a35a771 84 for(i=0;i<224;i++){
montie97 0:9ae27a35a771 85 LCD_DrawLine(8,52+i,232,52+i,White);
montie97 0:9ae27a35a771 86 }
montie97 0:9ae27a35a771 87 for(i=0;i<28;i++) //also clear the matrix
montie97 0:9ae27a35a771 88 for(j=0;j<28;j++)
montie97 0:9ae27a35a771 89 drawnPoints[i][j]=0;
montie97 0:9ae27a35a771 90
montie97 0:9ae27a35a771 91 return;
montie97 0:9ae27a35a771 92 }
montie97 0:9ae27a35a771 93
montie97 0:9ae27a35a771 94 /*******************************************************************************
montie97 0:9ae27a35a771 95 * Function Name : showCompression
montie97 0:9ae27a35a771 96 * Description :
montie97 0:9ae27a35a771 97 * Input : None
montie97 0:9ae27a35a771 98 * Output : None
montie97 0:9ae27a35a771 99 * Return : None
montie97 0:9ae27a35a771 100 * Attention : None
montie97 0:9ae27a35a771 101 *******************************************************************************/
montie97 0:9ae27a35a771 102 void showCompression(){
montie97 0:9ae27a35a771 103 int i,j;
montie97 0:9ae27a35a771 104 for(i=0;i<224;i++){ //clean the pad
montie97 0:9ae27a35a771 105 LCD_DrawLine(8,52+i,232,52+i,White);
montie97 0:9ae27a35a771 106 }
montie97 0:9ae27a35a771 107 for(i=0;i<28;i++)
montie97 0:9ae27a35a771 108 for(j=0;j<28;j++)
montie97 0:9ae27a35a771 109 if(drawnPoints[i][j]==1)
montie97 0:9ae27a35a771 110 LCD_SetPoint(i+110,j+150,Black);
montie97 0:9ae27a35a771 111
montie97 0:9ae27a35a771 112 return;
montie97 0:9ae27a35a771 113 }
montie97 0:9ae27a35a771 114
montie97 0:9ae27a35a771 115 /*******************************************************************************
montie97 0:9ae27a35a771 116 * Function Name : clearBar
montie97 0:9ae27a35a771 117 * Description :
montie97 0:9ae27a35a771 118 * Input : None
montie97 0:9ae27a35a771 119 * Output : None
montie97 0:9ae27a35a771 120 * Return : None
montie97 0:9ae27a35a771 121 * Attention : None
montie97 0:9ae27a35a771 122 *******************************************************************************/
montie97 0:9ae27a35a771 123 void clearBar(){
montie97 0:9ae27a35a771 124 int i;
montie97 0:9ae27a35a771 125 for(i=0;i<32;i++){
montie97 0:9ae27a35a771 126 LCD_DrawLine(8,10+i,232,10+i,White);
montie97 0:9ae27a35a771 127 }
montie97 0:9ae27a35a771 128 return;
montie97 0:9ae27a35a771 129 }
montie97 0:9ae27a35a771 130
montie97 0:9ae27a35a771 131 /*******************************************************************************
montie97 0:9ae27a35a771 132 * Function Name : drawButton
montie97 0:9ae27a35a771 133 * Description :
montie97 0:9ae27a35a771 134 * Input : None
montie97 0:9ae27a35a771 135 * Output : None
montie97 0:9ae27a35a771 136 * Return : None
montie97 0:9ae27a35a771 137 * Attention : None
montie97 0:9ae27a35a771 138 *******************************************************************************/
montie97 0:9ae27a35a771 139 void drawButton(button b, uint16_t color){
montie97 0:9ae27a35a771 140 int i;
montie97 0:9ae27a35a771 141 switch(b){
montie97 0:9ae27a35a771 142 case space: //Space Button
montie97 0:9ae27a35a771 143 spaceText(8,87,291,8,color);
montie97 0:9ae27a35a771 144 GUI_Text(8, 291, (uint8_t *) " Space ", Blue, color,1);
montie97 0:9ae27a35a771 145 spaceText(8,87,291+16+8,8,color);
montie97 0:9ae27a35a771 146 break;
montie97 0:9ae27a35a771 147 case infer: //Infer Button
montie97 0:9ae27a35a771 148 for(i=0;i<32;i++){
montie97 0:9ae27a35a771 149 LCD_DrawLine(100,283+i,139,283+i,color);
montie97 0:9ae27a35a771 150 }
montie97 0:9ae27a35a771 151 drawTriangle(112,289,10);
montie97 0:9ae27a35a771 152 break;
montie97 0:9ae27a35a771 153 case del: //Delete Button
montie97 0:9ae27a35a771 154 spaceText(153,232,291,8,color);
montie97 0:9ae27a35a771 155 GUI_Text(153, 291, (uint8_t *) " Delete ", Blue, color,1);
montie97 0:9ae27a35a771 156 spaceText(153,232,291+16+8,8,color);
montie97 0:9ae27a35a771 157 break;
montie97 0:9ae27a35a771 158 default:
montie97 0:9ae27a35a771 159 break;
montie97 0:9ae27a35a771 160 }
montie97 0:9ae27a35a771 161 return;
montie97 0:9ae27a35a771 162 }
montie97 0:9ae27a35a771 163
montie97 0:9ae27a35a771 164 /*******************************************************************************
montie97 0:9ae27a35a771 165 * Function Name : drawButtons
montie97 0:9ae27a35a771 166 * Description :
montie97 0:9ae27a35a771 167 * Input : None
montie97 0:9ae27a35a771 168 * Output : None
montie97 0:9ae27a35a771 169 * Return : None
montie97 0:9ae27a35a771 170 * Attention : None
montie97 0:9ae27a35a771 171 *******************************************************************************/
montie97 0:9ae27a35a771 172 void drawButtons(){
montie97 0:9ae27a35a771 173 drawButton(space,White);
montie97 0:9ae27a35a771 174 drawButton(infer,White);
montie97 0:9ae27a35a771 175 drawButton(del,White);
montie97 0:9ae27a35a771 176 return;
montie97 0:9ae27a35a771 177 }
montie97 0:9ae27a35a771 178
montie97 0:9ae27a35a771 179 /*******************************************************************************
montie97 0:9ae27a35a771 180 * Function Name : drawTriangle
montie97 0:9ae27a35a771 181 * Description :
montie97 0:9ae27a35a771 182 * Input : None
montie97 0:9ae27a35a771 183 * Output : None
montie97 0:9ae27a35a771 184 * Return : None
montie97 0:9ae27a35a771 185 * Attention : None
montie97 0:9ae27a35a771 186 *******************************************************************************/
montie97 0:9ae27a35a771 187 void drawTriangle(int posX, int posY, int lungMax){
montie97 0:9ae27a35a771 188 int i;
montie97 0:9ae27a35a771 189 uint16_t color=Green2;
montie97 0:9ae27a35a771 190 for(i=0;i<lungMax;i++){ //Direction EAST
montie97 0:9ae27a35a771 191 LCD_DrawLine(posX+5,posY+i+1,posX+5+i,posY+i+1,color);
montie97 0:9ae27a35a771 192 }
montie97 0:9ae27a35a771 193 for(i=0;i<lungMax-1;i++){
montie97 0:9ae27a35a771 194 LCD_DrawLine(posX+5,posY+lungMax+i+1,posX+5+(lungMax-2)-i,posY+lungMax+i+1,color);
montie97 0:9ae27a35a771 195 }
montie97 0:9ae27a35a771 196 }
montie97 0:9ae27a35a771 197
montie97 0:9ae27a35a771 198 /*******************************************************************************
montie97 0:9ae27a35a771 199 * Function Name : start
montie97 0:9ae27a35a771 200 * Description :
montie97 0:9ae27a35a771 201 * Input : None
montie97 0:9ae27a35a771 202 * Output : None
montie97 0:9ae27a35a771 203 * Return : None
montie97 0:9ae27a35a771 204 * Attention : None
montie97 0:9ae27a35a771 205 *******************************************************************************/
montie97 0:9ae27a35a771 206 void start(){
montie97 0:9ae27a35a771 207 //disable_timer(0);
montie97 0:9ae27a35a771 208 //reset_timer(0);
montie97 0:9ae27a35a771 209
montie97 0:9ae27a35a771 210 clearPad();
montie97 0:9ae27a35a771 211 GUI_Text(22, 90, (uint8_t *) "Touch to", Black, White, 3);
montie97 0:9ae27a35a771 212 GUI_Text(32, 135, (uint8_t *)" start", Black, White, 3);
montie97 0:9ae27a35a771 213 GUI_Text(28, 185, (uint8_t *) "writing!", Black, White, 3);
montie97 0:9ae27a35a771 214
montie97 0:9ae27a35a771 215 startGame=0;
montie97 0:9ae27a35a771 216 isWritten=0;
montie97 0:9ae27a35a771 217 inferenceStarted=0;
montie97 0:9ae27a35a771 218 //enable_timer(0);
montie97 0:9ae27a35a771 219
montie97 0:9ae27a35a771 220 return;
montie97 0:9ae27a35a771 221 }
montie97 0:9ae27a35a771 222
montie97 0:9ae27a35a771 223 // FUNZIONI GIORGIO
montie97 0:9ae27a35a771 224
montie97 0:9ae27a35a771 225 void readtouch(){
montie97 0:9ae27a35a771 226 if(Read_X()!=4095){
montie97 0:9ae27a35a771 227 wait(0.1);
montie97 0:9ae27a35a771 228 for(k=0; k<400;k++){
montie97 0:9ae27a35a771 229 x=Read_Y();
montie97 0:9ae27a35a771 230 y=Read_X();
montie97 0:9ae27a35a771 231 x=(x-300)*240/3900;
montie97 0:9ae27a35a771 232 y=(y-220)*320/3800;
montie97 0:9ae27a35a771 233 avg_x+=x;
montie97 0:9ae27a35a771 234 avg_y+=y;
montie97 0:9ae27a35a771 235 }
montie97 0:9ae27a35a771 236 avg_x=avg_x/400;
montie97 0:9ae27a35a771 237 avg_y=avg_y/400;
montie97 0:9ae27a35a771 238 tocco.x=avg_x+10;
montie97 0:9ae27a35a771 239 tocco.y=avg_y+19;
montie97 0:9ae27a35a771 240 ready=1;
montie97 0:9ae27a35a771 241 }
montie97 0:9ae27a35a771 242 else
montie97 0:9ae27a35a771 243 ready=0;
protopapaandrea 1:a32ccf18194d 244 }
protopapaandrea 1:a32ccf18194d 245
protopapaandrea 1:a32ccf18194d 246 void readTouch(){
protopapaandrea 1:a32ccf18194d 247 int i,j;
protopapaandrea 1:a32ccf18194d 248 Coordinate p;
protopapaandrea 1:a32ccf18194d 249 getDisplayPoint(&display, Read_Ads7846(), &matrix ) ; //resto in attesa di un punto che venga toccato
protopapaandrea 1:a32ccf18194d 250 if(display.x <= 240 && display.x > 0){
protopapaandrea 1:a32ccf18194d 251 if(display.y >= 52 && display.y <= 275 && display.x >=8 && display.x <= 232){//punto in zona alta (start writing)
protopapaandrea 1:a32ccf18194d 252 if(!startGame){
protopapaandrea 1:a32ccf18194d 253 startGame=1;
protopapaandrea 1:a32ccf18194d 254 clearPad();
protopapaandrea 1:a32ccf18194d 255 charPos=0;
protopapaandrea 1:a32ccf18194d 256 }
protopapaandrea 1:a32ccf18194d 257 else{//game already started: handwriting input
protopapaandrea 1:a32ccf18194d 258 if(charPos<26*8){ //topbar bound: otherwise the topbar is full
protopapaandrea 1:a32ccf18194d 259 #ifdef DEBUG
protopapaandrea 1:a32ccf18194d 260 if(!isWritten)
protopapaandrea 1:a32ccf18194d 261 clearPad();//clear to delete the testing result printed on screen before
protopapaandrea 1:a32ccf18194d 262 #endif
protopapaandrea 1:a32ccf18194d 263 isWritten=1;
protopapaandrea 1:a32ccf18194d 264 p.x=display.x-8;
protopapaandrea 1:a32ccf18194d 265 p.y=display.y-52;
protopapaandrea 1:a32ccf18194d 266 for(i=-1;i<2;i++)
protopapaandrea 1:a32ccf18194d 267 for(j=-1;j<2;j++){
protopapaandrea 1:a32ccf18194d 268 if((p.x+i)>=0&&(p.y+j)>=0&&(p.x+i)<224&&(p.y+j)<224){
protopapaandrea 1:a32ccf18194d 269 TP_DrawPoint(display.x+i,display.y+j);
protopapaandrea 1:a32ccf18194d 270 drawnPoints[(p.x+i)/8][(p.y+j)/8]++; //count +1 for the macrocell containing this pixel
protopapaandrea 1:a32ccf18194d 271 }
protopapaandrea 1:a32ccf18194d 272 }
protopapaandrea 1:a32ccf18194d 273 }
protopapaandrea 1:a32ccf18194d 274 }
protopapaandrea 1:a32ccf18194d 275 }
protopapaandrea 1:a32ccf18194d 276 else{
protopapaandrea 1:a32ccf18194d 277 if(display.y >= 283 && display.y <= 315 && display.x >=8 && display.x <= 87 && startGame && !isWritten && !inferenceStarted){//punto in tasto Space
protopapaandrea 1:a32ccf18194d 278 if(charPos<26*8){ //topbar bound: otherwise the topbar is full
protopapaandrea 1:a32ccf18194d 279 drawButton(space,Yellow);
protopapaandrea 1:a32ccf18194d 280
protopapaandrea 1:a32ccf18194d 281 //space operation: writing a whitespace into the topbar
protopapaandrea 1:a32ccf18194d 282
protopapaandrea 1:a32ccf18194d 283 //--TO BE COMPLETED--//
protopapaandrea 1:a32ccf18194d 284 if(charPos!=0)
protopapaandrea 1:a32ccf18194d 285 LCD_DrawLine(15+charPos-8, 35, 15+charPos+8-8, 35, White); //delete last cursor
protopapaandrea 1:a32ccf18194d 286 GUI_Text(15+charPos, 20, (uint8_t *)" ", Black, White,1); //testing space on topbar
protopapaandrea 1:a32ccf18194d 287 LCD_DrawLine(15+charPos, 35, 15+charPos+8, 35, Black); //cursor
protopapaandrea 1:a32ccf18194d 288 charPos+=8;
protopapaandrea 1:a32ccf18194d 289
protopapaandrea 1:a32ccf18194d 290 clearPad(); //useful only to see the same response time of the other buttons
protopapaandrea 1:a32ccf18194d 291
protopapaandrea 1:a32ccf18194d 292 drawButton(space,White);
protopapaandrea 1:a32ccf18194d 293 }
protopapaandrea 1:a32ccf18194d 294 }
protopapaandrea 1:a32ccf18194d 295 else{
protopapaandrea 1:a32ccf18194d 296 if(display.y >= 283 && display.y <= 315 && display.x >=100 && display.x <= 139 && startGame && isWritten &&!inferenceStarted){//punto in tasto Infer
protopapaandrea 1:a32ccf18194d 297 //wait flag to able
protopapaandrea 1:a32ccf18194d 298
protopapaandrea 1:a32ccf18194d 299 drawButton(infer,Yellow);
protopapaandrea 1:a32ccf18194d 300
protopapaandrea 1:a32ccf18194d 301 inferenceStarted=1;
protopapaandrea 1:a32ccf18194d 302 //infer operation: compress the matrix and send the final 28x28 matrix to the inference step
protopapaandrea 1:a32ccf18194d 303
protopapaandrea 1:a32ccf18194d 304 //--TO BE COMPLETED--//
protopapaandrea 1:a32ccf18194d 305 for(i=0;i<28;i++) //if the counter of the macrocell is greater than threshold, set the final cell to 1, otherwise it would be a 0-cell
protopapaandrea 1:a32ccf18194d 306 for(j=0;j<28;j++)
protopapaandrea 1:a32ccf18194d 307 drawnPoints[i][j]=drawnPoints[i][j]>=threshold?1:0;
protopapaandrea 1:a32ccf18194d 308
protopapaandrea 1:a32ccf18194d 309 #ifdef DEBUG
protopapaandrea 1:a32ccf18194d 310 showCompression();
protopapaandrea 1:a32ccf18194d 311 if(charPos!=0)
protopapaandrea 1:a32ccf18194d 312 LCD_DrawLine(15+charPos-8, 35, 15+charPos+8-8, 35, White); //delete last cursor
protopapaandrea 1:a32ccf18194d 313 GUI_Text(15+charPos, 20, (uint8_t *)"T", Black, White,1); //testing text on topbar
protopapaandrea 1:a32ccf18194d 314 LCD_DrawLine(15+charPos, 35, 15+charPos+8, 35, Black); //cursor
protopapaandrea 1:a32ccf18194d 315 charPos+=8;
pepperu96 2:4b3d056967a8 316 #endif
pepperu96 3:2bf723da1732 317
pepperu96 2:4b3d056967a8 318 for(i=0;i<28;i++) {
pepperu96 2:4b3d056967a8 319 for(j=0;j<28;j++) {
pepperu96 3:2bf723da1732 320 serial.printf("%d",static_cast<int>(drawnPoints[j][i]));
pepperu96 2:4b3d056967a8 321 }
pepperu96 2:4b3d056967a8 322 }
protopapaandrea 1:a32ccf18194d 323
pepperu96 3:2bf723da1732 324 #ifndef DEBUG
pepperu96 3:2bf723da1732 325 clearPad(); //here the matix is also cleaned
pepperu96 3:2bf723da1732 326 #endif
pepperu96 3:2bf723da1732 327
protopapaandrea 1:a32ccf18194d 328 isWritten=0;
protopapaandrea 1:a32ccf18194d 329 inferenceStarted=0;
protopapaandrea 1:a32ccf18194d 330
protopapaandrea 1:a32ccf18194d 331
protopapaandrea 1:a32ccf18194d 332 drawButton(infer,White);
protopapaandrea 1:a32ccf18194d 333 }
protopapaandrea 1:a32ccf18194d 334 else{
protopapaandrea 1:a32ccf18194d 335 if(display.y >= 283 && display.y <= 315 && display.x >=153 && display.x <= 232 && startGame &&!inferenceStarted){//punto in tasto Delete
protopapaandrea 1:a32ccf18194d 336 //wait flag to able
protopapaandrea 1:a32ccf18194d 337
protopapaandrea 1:a32ccf18194d 338 drawButton(del,Yellow);
protopapaandrea 1:a32ccf18194d 339
protopapaandrea 1:a32ccf18194d 340 if(isWritten){ //delete operation - handwriting on pad, before inference: clear the pad
protopapaandrea 1:a32ccf18194d 341 clearPad();
protopapaandrea 1:a32ccf18194d 342 isWritten=0;
protopapaandrea 1:a32ccf18194d 343 }
protopapaandrea 1:a32ccf18194d 344 else{ //delete operation - no handwriting on pad, after inference: delete last char printed on the topbar
protopapaandrea 1:a32ccf18194d 345 //--TO BE COMPLETED--//
protopapaandrea 1:a32ccf18194d 346 clearPad(); //useful only to see the same response time of the other cases
protopapaandrea 1:a32ccf18194d 347 if(charPos!=0){
protopapaandrea 1:a32ccf18194d 348 LCD_DrawLine(15+charPos-8, 35, 15+charPos+8-8, 35, White); //delete last cursor
protopapaandrea 1:a32ccf18194d 349 GUI_Text(15+charPos-8, 20, (uint8_t *)" ", Black, White,1); //testing text on topbar
protopapaandrea 1:a32ccf18194d 350 if(charPos!=8){ //otherwise we are going to the first character, no cursor
protopapaandrea 1:a32ccf18194d 351 LCD_DrawLine(15+charPos-16, 35, 15+charPos-8, 35, Black); //cursor
protopapaandrea 1:a32ccf18194d 352 }
protopapaandrea 1:a32ccf18194d 353 charPos-=8;
protopapaandrea 1:a32ccf18194d 354 }
protopapaandrea 1:a32ccf18194d 355 }
protopapaandrea 1:a32ccf18194d 356
protopapaandrea 1:a32ccf18194d 357 drawButton(del,White);
protopapaandrea 1:a32ccf18194d 358 }
protopapaandrea 1:a32ccf18194d 359 }
protopapaandrea 1:a32ccf18194d 360 }
protopapaandrea 1:a32ccf18194d 361 }
protopapaandrea 1:a32ccf18194d 362 }
protopapaandrea 1:a32ccf18194d 363 else{
protopapaandrea 1:a32ccf18194d 364 //do nothing if touch returns values out of bounds
protopapaandrea 1:a32ccf18194d 365 }
protopapaandrea 1:a32ccf18194d 366 return;
montie97 0:9ae27a35a771 367 }