@@ -56,7 +56,7 @@ void setup()
56
56
57
57
void loop ()
58
58
{
59
- // Periodically check touchscreen
59
+ // Periodically check touchscreen and perform events based on touches
60
60
keysEvents ();
61
61
delay (20 );
62
62
}
@@ -136,19 +136,21 @@ void keysEvents()
136
136
numOfDecimalDigitsOnCurrentNumber = 0 ;
137
137
}
138
138
139
- if (display.touchInArea (900 , 650 , 100 , 100 ) && (op == ' ' ) && (rightNumPos > 0 ))
139
+ if (display.touchInArea (900 , 650 , 100 , 100 ) && (op == ' ' ) && (rightNumPos > 0 )) // Sum
140
140
{
141
141
text18_cursor_x -= X_REZ_OFFSET;
142
142
text18_content = text18_content + " + " ;
143
143
op = ' +' ;
144
144
decimalPointOnCurrentNumber = false ;
145
145
numOfDecimalDigitsOnCurrentNumber = 0 ;
146
+
147
+ // Clear screen and redraw using partialUpdate
146
148
display.clearDisplay ();
147
149
mainDraw ();
148
150
display.partialUpdate ();
149
151
}
150
152
151
- if (display.touchInArea (700 , 650 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
153
+ if (display.touchInArea (700 , 650 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 0
152
154
{
153
155
text18_cursor_x -= X_REZ_OFFSET;
154
156
text18_content = text18_content + " 0" ;
@@ -157,6 +159,8 @@ void keysEvents()
157
159
{
158
160
numOfDecimalDigitsOnCurrentNumber++;
159
161
}
162
+
163
+ // Clear screen and redraw using partialUpdate
160
164
display.clearDisplay ();
161
165
mainDraw ();
162
166
display.partialUpdate ();
@@ -167,10 +171,12 @@ void keysEvents()
167
171
}
168
172
}
169
173
170
- if (display.touchInArea (600 , 650 , 100 , 100 ) && !decimalPointOnCurrentNumber && numOfDigitsEntered < 6 )
174
+ if (display.touchInArea (600 , 650 , 100 , 100 ) && !decimalPointOnCurrentNumber && numOfDigitsEntered < 6 ) // Decimal point
171
175
{
172
176
text18_cursor_x -= X_REZ_OFFSET;
173
177
text18_content = text18_content + " ." ;
178
+
179
+ // Clear screen and redraw using partialUpdate
174
180
display.clearDisplay ();
175
181
mainDraw ();
176
182
display.partialUpdate ();
@@ -179,22 +185,26 @@ void keysEvents()
179
185
{
180
186
++rightNumPos;
181
187
}
188
+
189
+ // Set flag that decimal point has been used
182
190
decimalPointOnCurrentNumber = true ;
183
191
}
184
192
185
- if (display.touchInArea (900 , 550 , 100 , 100 ) && (op == ' ' ) && (rightNumPos > 0 ))
193
+ if (display.touchInArea (900 , 550 , 100 , 100 ) && (op == ' ' ) && (rightNumPos > 0 )) // Subtraction
186
194
{
187
195
text18_cursor_x -= X_REZ_OFFSET;
188
196
text18_content = text18_content + " - " ;
189
197
op = ' -' ;
190
198
decimalPointOnCurrentNumber = false ;
191
199
numOfDecimalDigitsOnCurrentNumber = 0 ;
200
+
201
+ // Clear screen and redraw using partialUpdate
192
202
display.clearDisplay ();
193
203
mainDraw ();
194
204
display.partialUpdate ();
195
205
}
196
206
197
- if (display.touchInArea (800 , 550 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
207
+ if (display.touchInArea (800 , 550 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 3
198
208
{
199
209
text18_cursor_x -= X_REZ_OFFSET;
200
210
text18_content = text18_content + " 3" ;
@@ -203,6 +213,8 @@ void keysEvents()
203
213
{
204
214
numOfDecimalDigitsOnCurrentNumber++;
205
215
}
216
+
217
+ // Clear screen and redraw using partialUpdate
206
218
display.clearDisplay ();
207
219
mainDraw ();
208
220
display.partialUpdate ();
@@ -213,7 +225,7 @@ void keysEvents()
213
225
}
214
226
}
215
227
216
- if (display.touchInArea (700 , 550 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
228
+ if (display.touchInArea (700 , 550 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 2
217
229
{
218
230
text18_cursor_x -= X_REZ_OFFSET;
219
231
text18_content = text18_content + " 2" ;
@@ -222,6 +234,8 @@ void keysEvents()
222
234
{
223
235
numOfDecimalDigitsOnCurrentNumber++;
224
236
}
237
+
238
+ // Clear screen and redraw using partialUpdate
225
239
display.clearDisplay ();
226
240
mainDraw ();
227
241
display.partialUpdate ();
@@ -232,7 +246,7 @@ void keysEvents()
232
246
}
233
247
}
234
248
235
- if (display.touchInArea (600 , 550 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
249
+ if (display.touchInArea (600 , 550 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 1
236
250
{
237
251
text18_cursor_x -= X_REZ_OFFSET;
238
252
text18_content = text18_content + " 1" ;
@@ -241,6 +255,8 @@ void keysEvents()
241
255
{
242
256
numOfDecimalDigitsOnCurrentNumber++;
243
257
}
258
+
259
+ // Clear screen and redraw using partialUpdate
244
260
display.clearDisplay ();
245
261
mainDraw ();
246
262
display.partialUpdate ();
@@ -251,19 +267,21 @@ void keysEvents()
251
267
}
252
268
}
253
269
254
- if (display.touchInArea (900 , 450 , 100 , 100 ) && (op == ' ' ) && (rightNumPos > 0 ))
270
+ if (display.touchInArea (900 , 450 , 100 , 100 ) && (op == ' ' ) && (rightNumPos > 0 )) // X
255
271
{
256
272
text18_cursor_x -= X_REZ_OFFSET;
257
273
text18_content = text18_content + " x " ;
258
274
op = ' x' ;
259
275
decimalPointOnCurrentNumber = false ;
260
276
numOfDecimalDigitsOnCurrentNumber = 0 ;
277
+
278
+ // Clear screen and redraw using partialUpdate
261
279
display.clearDisplay ();
262
280
mainDraw ();
263
281
display.partialUpdate ();
264
282
}
265
283
266
- if (display.touchInArea (800 , 450 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
284
+ if (display.touchInArea (800 , 450 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 6
267
285
{
268
286
text18_cursor_x -= X_REZ_OFFSET;
269
287
text18_content = text18_content + " 6" ;
@@ -272,6 +290,8 @@ void keysEvents()
272
290
{
273
291
numOfDecimalDigitsOnCurrentNumber++;
274
292
}
293
+
294
+ // Clear screen and redraw using partialUpdate
275
295
display.clearDisplay ();
276
296
mainDraw ();
277
297
display.partialUpdate ();
@@ -282,7 +302,7 @@ void keysEvents()
282
302
}
283
303
}
284
304
285
- if (display.touchInArea (700 , 450 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
305
+ if (display.touchInArea (700 , 450 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 5
286
306
{
287
307
text18_cursor_x -= X_REZ_OFFSET;
288
308
text18_content = text18_content + " 5" ;
@@ -291,6 +311,8 @@ void keysEvents()
291
311
{
292
312
numOfDecimalDigitsOnCurrentNumber++;
293
313
}
314
+
315
+ // Clear screen and redraw using partialUpdate
294
316
display.clearDisplay ();
295
317
mainDraw ();
296
318
display.partialUpdate ();
@@ -301,7 +323,7 @@ void keysEvents()
301
323
}
302
324
}
303
325
304
- if (display.touchInArea (600 , 450 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
326
+ if (display.touchInArea (600 , 450 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 4
305
327
{
306
328
text18_cursor_x -= X_REZ_OFFSET;
307
329
text18_content = text18_content + " 4" ;
@@ -310,6 +332,8 @@ void keysEvents()
310
332
{
311
333
numOfDecimalDigitsOnCurrentNumber++;
312
334
}
335
+
336
+ // Clear screen and redraw using partialUpdate
313
337
display.clearDisplay ();
314
338
mainDraw ();
315
339
display.partialUpdate ();
@@ -320,19 +344,21 @@ void keysEvents()
320
344
}
321
345
}
322
346
323
- if (display.touchInArea (900 , 350 , 100 , 100 ) && (op == ' ' ) && (rightNumPos > 0 ))
347
+ if (display.touchInArea (900 , 350 , 100 , 100 ) && (op == ' ' ) && (rightNumPos > 0 )) // Division
324
348
{
325
349
text18_cursor_x -= X_REZ_OFFSET;
326
350
text18_content = text18_content + " / " ;
327
351
op = ' /' ;
328
352
decimalPointOnCurrentNumber = false ;
329
353
numOfDecimalDigitsOnCurrentNumber = 0 ;
354
+
355
+ // Clear screen and redraw using partialUpdate
330
356
display.clearDisplay ();
331
357
mainDraw ();
332
358
display.partialUpdate ();
333
359
}
334
360
335
- if (display.touchInArea (800 , 350 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
361
+ if (display.touchInArea (800 , 350 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 9
336
362
{
337
363
text18_cursor_x -= X_REZ_OFFSET;
338
364
text18_content = text18_content + " 9" ;
@@ -341,6 +367,8 @@ void keysEvents()
341
367
{
342
368
numOfDecimalDigitsOnCurrentNumber++;
343
369
}
370
+
371
+ // Clear screen and redraw using partialUpdate
344
372
display.clearDisplay ();
345
373
mainDraw ();
346
374
display.partialUpdate ();
@@ -351,7 +379,7 @@ void keysEvents()
351
379
}
352
380
}
353
381
354
- if (display.touchInArea (700 , 350 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
382
+ if (display.touchInArea (700 , 350 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 8
355
383
{
356
384
text18_cursor_x -= X_REZ_OFFSET;
357
385
text18_content = text18_content + " 8" ;
@@ -360,6 +388,8 @@ void keysEvents()
360
388
{
361
389
numOfDecimalDigitsOnCurrentNumber++;
362
390
}
391
+
392
+ // Clear screen and redraw using partialUpdate
363
393
display.clearDisplay ();
364
394
mainDraw ();
365
395
display.partialUpdate ();
@@ -370,7 +400,7 @@ void keysEvents()
370
400
}
371
401
}
372
402
373
- if (display.touchInArea (600 , 350 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 )
403
+ if (display.touchInArea (600 , 350 , 100 , 100 ) && numOfDigitsEntered < 6 && numOfDecimalDigitsOnCurrentNumber < 2 ) // 7
374
404
{
375
405
text18_cursor_x -= X_REZ_OFFSET;
376
406
text18_content = text18_content + " 7" ;
@@ -379,6 +409,8 @@ void keysEvents()
379
409
{
380
410
numOfDecimalDigitsOnCurrentNumber++;
381
411
}
412
+
413
+ // Clear screen and redraw using partialUpdate
382
414
display.clearDisplay ();
383
415
mainDraw ();
384
416
display.partialUpdate ();
@@ -390,6 +422,7 @@ void keysEvents()
390
422
}
391
423
}
392
424
425
+ // Do calculation based on inputs
393
426
float calculate ()
394
427
{
395
428
double res = 0 ;
0 commit comments