Touchscreen digit recognition.

Dependencies:   mbed TFT_fonts SPI_TFT_ILI9341 Adafruit_GFX FT6206 MMA8451Q

Committer:
atomicle
Date:
Fri Jan 17 08:33:46 2020 +0000
Revision:
2:1ab6ba7c2c90
Parent:
1:c44001c6bbf8
Project demo finished.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
atomicle 2:1ab6ba7c2c90 1 #include <algorithm>
atomicle 2:1ab6ba7c2c90 2 #include <string>
atomicle 2:1ab6ba7c2c90 3
atomicle 2:1ab6ba7c2c90 4 // Vendor
JackB 0:5264c6cecce9 5 #include "mbed.h"
JackB 0:5264c6cecce9 6 #include "SPI_TFT_ILI9341.h"
JackB 0:5264c6cecce9 7 #include "FT6206.h"
atomicle 2:1ab6ba7c2c90 8 #include "MMA8451Q.h"
atomicle 2:1ab6ba7c2c90 9 #include "Arial12x12.h"
atomicle 2:1ab6ba7c2c90 10 #include "Arial24x23.h"
atomicle 2:1ab6ba7c2c90 11 #include "Arial28x28.h"
atomicle 2:1ab6ba7c2c90 12
rankedss 1:c44001c6bbf8 13 #include "weigths.hpp"
atomicle 2:1ab6ba7c2c90 14 #include "orientation.hpp"
rankedss 1:c44001c6bbf8 15
rankedss 1:c44001c6bbf8 16 // Accelorameter
rankedss 1:c44001c6bbf8 17 #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
rankedss 1:c44001c6bbf8 18 PinName const SDA = PTE25;
rankedss 1:c44001c6bbf8 19 PinName const SCL = PTE24;
rankedss 1:c44001c6bbf8 20 #elif defined (TARGET_KL05Z)
rankedss 1:c44001c6bbf8 21 PinName const SDA = PTB4;
rankedss 1:c44001c6bbf8 22 PinName const SCL = PTB3;
rankedss 1:c44001c6bbf8 23 #elif defined (TARGET_K20D50M)
rankedss 1:c44001c6bbf8 24 PinName const SDA = PTB1;
rankedss 1:c44001c6bbf8 25 PinName const SCL = PTB0;
rankedss 1:c44001c6bbf8 26 #else
rankedss 1:c44001c6bbf8 27 #error TARGET NOT DEFINED
rankedss 1:c44001c6bbf8 28 #endif
atomicle 2:1ab6ba7c2c90 29
rankedss 1:c44001c6bbf8 30 #define MMA8451_I2C_ADDRESS (0x1d<<1)
JackB 0:5264c6cecce9 31
atomicle 2:1ab6ba7c2c90 32 // Pin Configuration
JackB 0:5264c6cecce9 33 #define PIN_XP A3
JackB 0:5264c6cecce9 34 #define PIN_XM A1
JackB 0:5264c6cecce9 35 #define PIN_YP A2
JackB 0:5264c6cecce9 36 #define PIN_YM A0
JackB 0:5264c6cecce9 37 #define PIN_SCLK D13
JackB 0:5264c6cecce9 38 #define PIN_MISO D12
JackB 0:5264c6cecce9 39 #define PIN_MOSI D11
atomicle 2:1ab6ba7c2c90 40 #define PIN_CS_TFT D10
atomicle 2:1ab6ba7c2c90 41 #define PIN_DC_TFT D9
JackB 0:5264c6cecce9 42 #define PIN_RESET_TFT D8
JackB 0:5264c6cecce9 43 #define PIN_CS_SD D4
JackB 0:5264c6cecce9 44
JackB 0:5264c6cecce9 45
rankedss 1:c44001c6bbf8 46 #define PIN_SCL_FT6206 A5
rankedss 1:c44001c6bbf8 47 #define PIN_SDA_FT6206 A4
JackB 0:5264c6cecce9 48 #define PIN_INT_FT6206 D7
JackB 0:5264c6cecce9 49
JackB 0:5264c6cecce9 50 #define ILI9341_TFTWIDTH 320
JackB 0:5264c6cecce9 51 #define ILI9341_TFTHEIGHT 240
JackB 0:5264c6cecce9 52
JackB 0:5264c6cecce9 53 DigitalOut led1(LED1);
JackB 0:5264c6cecce9 54 DigitalOut led2(LED2);
JackB 0:5264c6cecce9 55 DigitalOut led3(LED3);
JackB 0:5264c6cecce9 56 DigitalOut led4(LED4);
JackB 0:5264c6cecce9 57
atomicle 2:1ab6ba7c2c90 58 Ticker ticker;
atomicle 2:1ab6ba7c2c90 59
atomicle 2:1ab6ba7c2c90 60 SPI_TFT_ILI9341 TFT(PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_RESET_TFT, PIN_DC_TFT, "TFT");
atomicle 2:1ab6ba7c2c90 61 FT6206 FT6206(PIN_SDA_FT6206, PIN_SCL_FT6206, PIN_INT_FT6206);
rankedss 1:c44001c6bbf8 62 MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS);
JackB 0:5264c6cecce9 63
rankedss 1:c44001c6bbf8 64 int maxIndex(float vector_name[])
rankedss 1:c44001c6bbf8 65 {
rankedss 1:c44001c6bbf8 66 double max = vector_name[0];
rankedss 1:c44001c6bbf8 67 int index = 0;
rankedss 1:c44001c6bbf8 68 for (int i = 0; i != 10; i++) {
rankedss 1:c44001c6bbf8 69 if (max < vector_name[i]) {
rankedss 1:c44001c6bbf8 70 max = vector_name[i];
rankedss 1:c44001c6bbf8 71 index = i;
rankedss 1:c44001c6bbf8 72 }
rankedss 1:c44001c6bbf8 73 }
rankedss 1:c44001c6bbf8 74 return index;
rankedss 1:c44001c6bbf8 75 }
rankedss 1:c44001c6bbf8 76
rankedss 1:c44001c6bbf8 77 float RELU(float x)
rankedss 1:c44001c6bbf8 78 {
rankedss 1:c44001c6bbf8 79 return std::max(0.0f, x);
rankedss 1:c44001c6bbf8 80 }
rankedss 1:c44001c6bbf8 81
rankedss 1:c44001c6bbf8 82 int FeedForward()
rankedss 1:c44001c6bbf8 83 {
rankedss 1:c44001c6bbf8 84 float convImages[kernel_count][convImageSize][convImageSize] = {0.0f};
rankedss 1:c44001c6bbf8 85
rankedss 1:c44001c6bbf8 86 for (unsigned f = 0; f != kernel_count; f++) {
rankedss 1:c44001c6bbf8 87 for (unsigned i = 0; i <= image_size - kernel_size; i += stride) {
rankedss 1:c44001c6bbf8 88 for (unsigned j = 0; j <= image_size - kernel_size; j += stride) {
rankedss 1:c44001c6bbf8 89 for (unsigned k = i; k < i + kernel_size; k++) {
rankedss 1:c44001c6bbf8 90 for (unsigned l = j; l < j + kernel_size; l++) {
rankedss 1:c44001c6bbf8 91 convImages[f][i / stride][j / stride] += image[k][l] * kernels[f][k - i][l - j];
rankedss 1:c44001c6bbf8 92 }
rankedss 1:c44001c6bbf8 93 }
rankedss 1:c44001c6bbf8 94 convImages[f][i / stride][j / stride] += bias_kernels[f];
rankedss 1:c44001c6bbf8 95 }
rankedss 1:c44001c6bbf8 96 }
rankedss 1:c44001c6bbf8 97 }
rankedss 1:c44001c6bbf8 98
rankedss 1:c44001c6bbf8 99 unsigned elem = 0;
rankedss 1:c44001c6bbf8 100 for (unsigned f = 0; f != kernel_count; f++) {
rankedss 1:c44001c6bbf8 101 for (unsigned j = 0; j != convImageSize; j++) {
rankedss 1:c44001c6bbf8 102 for (unsigned k = 0; k != convImageSize; k++) {
rankedss 1:c44001c6bbf8 103 activated[elem++] = RELU(convImages[f][j][k]);
rankedss 1:c44001c6bbf8 104 }
rankedss 1:c44001c6bbf8 105 }
rankedss 1:c44001c6bbf8 106 }
rankedss 1:c44001c6bbf8 107
rankedss 1:c44001c6bbf8 108 float z[10] = {0.0f};
rankedss 1:c44001c6bbf8 109 for (unsigned i = 0; i != 10; i++) {
rankedss 1:c44001c6bbf8 110 z[i] = 0.0f;
rankedss 1:c44001c6bbf8 111 for (unsigned j = 0; j != kernel_count * convImageSize * convImageSize; j++) {
rankedss 1:c44001c6bbf8 112 z[i] += weights[i][j] * activated[j];
rankedss 1:c44001c6bbf8 113 }
rankedss 1:c44001c6bbf8 114 z[i] += bias_weights[i];
rankedss 1:c44001c6bbf8 115 }
atomicle 2:1ab6ba7c2c90 116 return maxIndex(z);
rankedss 1:c44001c6bbf8 117 }
rankedss 1:c44001c6bbf8 118
atomicle 2:1ab6ba7c2c90 119
rankedss 1:c44001c6bbf8 120 void landscapeInit()
JackB 0:5264c6cecce9 121 {
JackB 0:5264c6cecce9 122 //Configure the display driver
JackB 0:5264c6cecce9 123 TFT.claim(stdout);
rankedss 1:c44001c6bbf8 124 TFT.background(LightGrey);
rankedss 1:c44001c6bbf8 125 TFT.foreground(Green);
JackB 0:5264c6cecce9 126 TFT.set_orientation(LANDSCAPE);
JackB 0:5264c6cecce9 127 TFT.cls();
JackB 0:5264c6cecce9 128
JackB 0:5264c6cecce9 129 //Print a welcome message
rankedss 1:c44001c6bbf8 130 TFT.fillrect(240, 25, 292, 45, Red);
JackB 0:5264c6cecce9 131 TFT.set_font((unsigned char*) Arial12x12);
rankedss 1:c44001c6bbf8 132 TFT.locate(245, 30);
rankedss 1:c44001c6bbf8 133 TFT.background(Red);
rankedss 1:c44001c6bbf8 134 TFT.printf("Guess");
rankedss 1:c44001c6bbf8 135
rankedss 1:c44001c6bbf8 136 //Print a welcome message
rankedss 1:c44001c6bbf8 137 TFT.fillrect(240, 205, 292, 225, Red);
rankedss 1:c44001c6bbf8 138 TFT.set_font((unsigned char*) Arial12x12);
rankedss 1:c44001c6bbf8 139 TFT.locate(245, 210);
rankedss 1:c44001c6bbf8 140 TFT.background(Red);
rankedss 1:c44001c6bbf8 141 TFT.printf("Clear");
rankedss 1:c44001c6bbf8 142
rankedss 1:c44001c6bbf8 143 TFT.fillrect(20, 50, 160, 190, DarkGrey);
rankedss 1:c44001c6bbf8 144 }
rankedss 1:c44001c6bbf8 145
rankedss 1:c44001c6bbf8 146 void portraitInit()
rankedss 1:c44001c6bbf8 147 {
rankedss 1:c44001c6bbf8 148 //Configure the display driver
rankedss 1:c44001c6bbf8 149 TFT.claim(stdout);
rankedss 1:c44001c6bbf8 150 TFT.background(LightGrey);
rankedss 1:c44001c6bbf8 151 TFT.foreground(Green);
rankedss 1:c44001c6bbf8 152 TFT.set_orientation(PORTRAIT);
rankedss 1:c44001c6bbf8 153 TFT.cls();
rankedss 1:c44001c6bbf8 154
rankedss 1:c44001c6bbf8 155 //Print a welcome message
rankedss 1:c44001c6bbf8 156 TFT.fillrect(15, 25, 67, 45, Red);
rankedss 1:c44001c6bbf8 157 TFT.set_font((unsigned char*) Arial12x12);
rankedss 1:c44001c6bbf8 158 TFT.locate(20, 30);
rankedss 1:c44001c6bbf8 159 TFT.background(Red);
rankedss 1:c44001c6bbf8 160 TFT.printf("Guess");
JackB 0:5264c6cecce9 161
rankedss 1:c44001c6bbf8 162 //Print a welcome message
rankedss 1:c44001c6bbf8 163 TFT.fillrect(160, 25, 212, 45, Red);
rankedss 1:c44001c6bbf8 164 TFT.set_font((unsigned char*) Arial12x12);
atomicle 2:1ab6ba7c2c90 165 TFT.locate(170, 30);
rankedss 1:c44001c6bbf8 166 TFT.background(Red);
rankedss 1:c44001c6bbf8 167 TFT.printf("Clear");
rankedss 1:c44001c6bbf8 168
rankedss 1:c44001c6bbf8 169 TFT.fillrect(50, 160, 190, 300, DarkGrey);
rankedss 1:c44001c6bbf8 170 }
rankedss 1:c44001c6bbf8 171
atomicle 2:1ab6ba7c2c90 172 int current_orientation = LANDSCAPE;
atomicle 2:1ab6ba7c2c90 173
atomicle 2:1ab6ba7c2c90 174 void set_orientation()
atomicle 2:1ab6ba7c2c90 175 {
atomicle 2:1ab6ba7c2c90 176 current_orientation = get_orientation();
atomicle 2:1ab6ba7c2c90 177 }
atomicle 2:1ab6ba7c2c90 178
rankedss 1:c44001c6bbf8 179 int main(void)
rankedss 1:c44001c6bbf8 180 {
atomicle 2:1ab6ba7c2c90 181
atomicle 2:1ab6ba7c2c90 182 int orientation = get_orientation();
atomicle 2:1ab6ba7c2c90 183 ticker.attach(&set_orientation, 0.1);
atomicle 2:1ab6ba7c2c90 184
atomicle 2:1ab6ba7c2c90 185 if (orientation == LANDSCAPE)
rankedss 1:c44001c6bbf8 186 landscapeInit();
rankedss 1:c44001c6bbf8 187 else
rankedss 1:c44001c6bbf8 188 portraitInit();
rankedss 1:c44001c6bbf8 189
rankedss 1:c44001c6bbf8 190
rankedss 1:c44001c6bbf8 191 // Initialize weights
rankedss 1:c44001c6bbf8 192 for (unsigned i = 0; i != 28; i++)
rankedss 1:c44001c6bbf8 193 {
rankedss 1:c44001c6bbf8 194 for (unsigned j = 0; j != 28; j++)
rankedss 1:c44001c6bbf8 195 {
rankedss 1:c44001c6bbf8 196 image[i][j] = -0.5f;
JackB 0:5264c6cecce9 197 }
rankedss 1:c44001c6bbf8 198 }
rankedss 1:c44001c6bbf8 199
JackB 0:5264c6cecce9 200
JackB 0:5264c6cecce9 201
rankedss 1:c44001c6bbf8 202 FT6206.begin();
rankedss 1:c44001c6bbf8 203 while(1)
atomicle 2:1ab6ba7c2c90 204 {
atomicle 2:1ab6ba7c2c90 205 if (current_orientation != orientation)
rankedss 1:c44001c6bbf8 206 {
atomicle 2:1ab6ba7c2c90 207 orientation = current_orientation;
atomicle 2:1ab6ba7c2c90 208 if (orientation == LANDSCAPE)
rankedss 1:c44001c6bbf8 209 landscapeInit();
rankedss 1:c44001c6bbf8 210 else
rankedss 1:c44001c6bbf8 211 portraitInit();
rankedss 1:c44001c6bbf8 212 }
atomicle 2:1ab6ba7c2c90 213
rankedss 1:c44001c6bbf8 214 if (FT6206.dataReceived())
rankedss 1:c44001c6bbf8 215 {
rankedss 1:c44001c6bbf8 216 TS_Point p = FT6206.getPoint();
rankedss 1:c44001c6bbf8 217
atomicle 2:1ab6ba7c2c90 218 if (orientation == LANDSCAPE) {
atomicle 2:1ab6ba7c2c90 219 if (p.x >= 25 and p.x <= 155 and p.y >= 55 and p.y <= 185)
atomicle 2:1ab6ba7c2c90 220 {
atomicle 2:1ab6ba7c2c90 221 // Handwriting panel has been pressed
atomicle 2:1ab6ba7c2c90 222 TFT.fillcircle(p.x, p.y, 4, Yellow);
atomicle 2:1ab6ba7c2c90 223 int image_y = (p.x-20)/5;
atomicle 2:1ab6ba7c2c90 224 int image_x = (p.y-50)/5;
atomicle 2:1ab6ba7c2c90 225 if (image_x > 0 and image_y > 0)
atomicle 2:1ab6ba7c2c90 226 {
atomicle 2:1ab6ba7c2c90 227 image[image_x-1][image_y-1] = 0.5f;
atomicle 2:1ab6ba7c2c90 228 image[image_x-1][image_y] = 0.5f;
atomicle 2:1ab6ba7c2c90 229 image[image_x-1][image_y+1] = 0.5f;
atomicle 2:1ab6ba7c2c90 230 image[image_x][image_y-1] = 0.5f;
atomicle 2:1ab6ba7c2c90 231 image[image_x][image_y] = 0.5f;
atomicle 2:1ab6ba7c2c90 232 image[image_x][image_y+1] = 0.5f;
atomicle 2:1ab6ba7c2c90 233 image[image_x+1][image_y-1] = 0.5f;
atomicle 2:1ab6ba7c2c90 234 image[image_x+1][image_y] = 0.5f;
atomicle 2:1ab6ba7c2c90 235 image[image_x+1][image_y+1] = 0.5f;
atomicle 2:1ab6ba7c2c90 236 }
atomicle 2:1ab6ba7c2c90 237 }
atomicle 2:1ab6ba7c2c90 238 else if (p.y >= 0 and p.y <= 60 and p.x >= 200 and p.x <= 320)
rankedss 1:c44001c6bbf8 239 {
atomicle 2:1ab6ba7c2c90 240 // Guess button has been pressed
atomicle 2:1ab6ba7c2c90 241 TFT.fillrect(180, 50, 320, 190, LightGrey);
atomicle 2:1ab6ba7c2c90 242 TFT.locate(270, 110);
atomicle 2:1ab6ba7c2c90 243 TFT.background(LightGrey);
atomicle 2:1ab6ba7c2c90 244 TFT.foreground(Green);
atomicle 2:1ab6ba7c2c90 245
atomicle 2:1ab6ba7c2c90 246 TFT.set_font((unsigned char*) Arial28x28);
atomicle 2:1ab6ba7c2c90 247 switch (FeedForward())
atomicle 2:1ab6ba7c2c90 248 {
atomicle 2:1ab6ba7c2c90 249 case 0: TFT.printf("0"); break;
atomicle 2:1ab6ba7c2c90 250 case 1: TFT.printf("1"); break;
atomicle 2:1ab6ba7c2c90 251 case 2: TFT.printf("2"); break;
atomicle 2:1ab6ba7c2c90 252 case 3: TFT.printf("3"); break;
atomicle 2:1ab6ba7c2c90 253 case 4: TFT.printf("4"); break;
atomicle 2:1ab6ba7c2c90 254 case 5: TFT.printf("5"); break;
atomicle 2:1ab6ba7c2c90 255 case 6: TFT.printf("6"); break;
atomicle 2:1ab6ba7c2c90 256 case 7: TFT.printf("7"); break;
atomicle 2:1ab6ba7c2c90 257 case 8: TFT.printf("8"); break;
atomicle 2:1ab6ba7c2c90 258 case 9: TFT.printf("9"); break;
atomicle 2:1ab6ba7c2c90 259 default: TFT.printf("noidea\n");
atomicle 2:1ab6ba7c2c90 260 }
atomicle 2:1ab6ba7c2c90 261 }
atomicle 2:1ab6ba7c2c90 262 else if (p.y >= 185 and p.y <= 240 and p.x >= 220 and p.x <= 320)
atomicle 2:1ab6ba7c2c90 263 {
atomicle 2:1ab6ba7c2c90 264 // Clear button has been pressed
atomicle 2:1ab6ba7c2c90 265 TFT.fillrect(15, 45, 165, 195, LightGrey);
atomicle 2:1ab6ba7c2c90 266 TFT.fillrect(20, 50, 160, 190, DarkGrey);
atomicle 2:1ab6ba7c2c90 267 for (unsigned i = 0; i != 28; i++)
atomicle 2:1ab6ba7c2c90 268 {
atomicle 2:1ab6ba7c2c90 269 for (unsigned j = 0; j != 28; j++)
atomicle 2:1ab6ba7c2c90 270 {
atomicle 2:1ab6ba7c2c90 271 image[i][j] = -0.5f;
atomicle 2:1ab6ba7c2c90 272 }
atomicle 2:1ab6ba7c2c90 273 }
atomicle 2:1ab6ba7c2c90 274 } // LANDSCAPE END
atomicle 2:1ab6ba7c2c90 275 }
atomicle 2:1ab6ba7c2c90 276 else // PORTRAIT START
rankedss 1:c44001c6bbf8 277 {
atomicle 2:1ab6ba7c2c90 278 if (p.x >= 160 and p.x <= 300 and p.y >= 50 and p.y <= 190)
atomicle 2:1ab6ba7c2c90 279 {
atomicle 2:1ab6ba7c2c90 280 // Handwriting panel has been pressed
atomicle 2:1ab6ba7c2c90 281 TFT.fillcircle(240-p.y, p.x, 4, Yellow);
atomicle 2:1ab6ba7c2c90 282 int image_x = (p.x-160)/5;
atomicle 2:1ab6ba7c2c90 283 int image_y = (240- p.y-50)/5;
atomicle 2:1ab6ba7c2c90 284 if (image_x > 0 and image_y > 0)
atomicle 2:1ab6ba7c2c90 285 {
atomicle 2:1ab6ba7c2c90 286 image[image_x-1][image_y-1] = 0.5f;
atomicle 2:1ab6ba7c2c90 287 image[image_x-1][image_y] = 0.5f;
atomicle 2:1ab6ba7c2c90 288 image[image_x-1][image_y+1] = 0.5f;
atomicle 2:1ab6ba7c2c90 289 image[image_x][image_y-1] = 0.5f;
atomicle 2:1ab6ba7c2c90 290 image[image_x][image_y] = 0.5f;
atomicle 2:1ab6ba7c2c90 291 image[image_x][image_y+1] = 0.5f;
atomicle 2:1ab6ba7c2c90 292 image[image_x+1][image_y-1] = 0.5f;
atomicle 2:1ab6ba7c2c90 293 image[image_x+1][image_y] = 0.5f;
atomicle 2:1ab6ba7c2c90 294 image[image_x+1][image_y+1] = 0.5f;
atomicle 2:1ab6ba7c2c90 295 }
atomicle 2:1ab6ba7c2c90 296 }
atomicle 2:1ab6ba7c2c90 297 else if (p.y >= 140 and p.y <= 240 and p.x >= 1 and p.x <= 70)
rankedss 1:c44001c6bbf8 298 {
atomicle 2:1ab6ba7c2c90 299 // Guess button has been pressed
atomicle 2:1ab6ba7c2c90 300 TFT.fillrect(90, 0, 140, 60, LightGrey);
atomicle 2:1ab6ba7c2c90 301 char prediction = FeedForward();
atomicle 2:1ab6ba7c2c90 302 TFT.locate(110, 30);
atomicle 2:1ab6ba7c2c90 303 TFT.background(LightGrey);
atomicle 2:1ab6ba7c2c90 304 TFT.foreground(Green);
atomicle 2:1ab6ba7c2c90 305
atomicle 2:1ab6ba7c2c90 306 TFT.set_font((unsigned char*) Arial28x28);
atomicle 2:1ab6ba7c2c90 307 switch (prediction)
atomicle 2:1ab6ba7c2c90 308 {
atomicle 2:1ab6ba7c2c90 309 case 0: TFT.printf("0"); break;
atomicle 2:1ab6ba7c2c90 310 case 1: TFT.printf("1"); break;
atomicle 2:1ab6ba7c2c90 311 case 2: TFT.printf("2"); break;
atomicle 2:1ab6ba7c2c90 312 case 3: TFT.printf("3"); break;
atomicle 2:1ab6ba7c2c90 313 case 4: TFT.printf("4"); break;
atomicle 2:1ab6ba7c2c90 314 case 5: TFT.printf("5"); break;
atomicle 2:1ab6ba7c2c90 315 case 6: TFT.printf("6"); break;
atomicle 2:1ab6ba7c2c90 316 case 7: TFT.printf("7"); break;
atomicle 2:1ab6ba7c2c90 317 case 8: TFT.printf("8"); break;
atomicle 2:1ab6ba7c2c90 318 case 9: TFT.printf("9"); break;
atomicle 2:1ab6ba7c2c90 319 default: TFT.printf("noidea\n");
atomicle 2:1ab6ba7c2c90 320 }
atomicle 2:1ab6ba7c2c90 321 }
atomicle 2:1ab6ba7c2c90 322 else if (p.y >= 1 and p.y <= 80 and p.x >= 0 and p.x <= 70)
rankedss 1:c44001c6bbf8 323 {
atomicle 2:1ab6ba7c2c90 324 // Clear button has been pressed
atomicle 2:1ab6ba7c2c90 325 TFT.fillrect(45, 155, 195, 305, LightGrey);
atomicle 2:1ab6ba7c2c90 326 TFT.fillrect(50, 160, 190, 300, DarkGrey);
atomicle 2:1ab6ba7c2c90 327 for (unsigned i = 0; i != 28; i++)
rankedss 1:c44001c6bbf8 328 {
atomicle 2:1ab6ba7c2c90 329 for (unsigned j = 0; j != 28; j++)
atomicle 2:1ab6ba7c2c90 330 {
atomicle 2:1ab6ba7c2c90 331 image[i][j] = -0.5f;
atomicle 2:1ab6ba7c2c90 332 }
rankedss 1:c44001c6bbf8 333 }
rankedss 1:c44001c6bbf8 334 }
rankedss 1:c44001c6bbf8 335 }
rankedss 1:c44001c6bbf8 336 }
JackB 0:5264c6cecce9 337 }
JackB 0:5264c6cecce9 338 }