-
Notifications
You must be signed in to change notification settings - Fork 5
/
TASS_touchscreen.ino
708 lines (620 loc) · 18.8 KB
/
TASS_touchscreen.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
/* TASS - Touchscreen
*
* Functions for using Adafruit ILI9341 Captouch Shield (Product ID 1947)
*
* Author: Matthew J. Wolf <[email protected]>
* Date: 18-NOV-2018
*
* - Version 0.7-n4mtt
* = Many changes
* = Remove board 5
* = Commented out command 4
* = Added to use of font FreeSans 9pt
* = Added two colors: Blue, Orange
* = Replaced individual draw_relay#() functions with
* one draw_relay() function.
* = Added functions
* -= draw_relay()
* -= draw_relays_status()
* -= draw_board_status()
* -= draw_relay_labels()
*
* - Original author is John Ackermann, N8UR
*
* Copyright (c) 2016 John Ackermann
* Copyright (c) 2018 Matthew J. Wolf
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifdef USE_TS
/* TASS_touchscreen -- functions for touchscreen (duh)
BASED ON:
This is our touchscreen painting example for the Adafruit ILI9341
captouch shield
----> http://www.adafruit.com/products/1947
Check out the links above for our tutorials and wiring diagrams
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
MIT license, all text above must be included in any redistribution.
*/
boolean get_ts_data() {
int i = -1;
int board_number = -1;
if (board == 'A') {
board_number = 1;
} else if (board == 'B') {
board_number = 2;
} else if (board == 'C') {
board_number = 3;
} else if (board == 'D') {
board_number = 4;
}
// Wait for a touch
execute = 0;
if (! ctp.touched()) {
return execute;
}
// Retrieve a point
TS_Point p = ctp.getPoint();
// flip it around to match the screen.
p.y = map(p.y, 0, 320, 320, 0);
// we're using board 90 degrees from default, I guess
int x_pos = p.y;
int y_pos = p.x;
// set board -- all choices are in left-most box space
if (x_pos <= BOXSIZE) {
draw_boards();
if ( (y_pos < BOXSIZE)
&& (NUM_TASS_BOARDS_DISPLAY > 0) ) {
draw_board1(FILL, BLUE, WHITE);
board = 'A';
draw_board_status(1);
draw_relays_status(1);
} else if ( (y_pos >= BOXSIZE && y_pos < BOXSIZE*2)
&& (NUM_TASS_BOARDS_DISPLAY > 1) ) {
draw_board2(FILL, BLUE, WHITE);
board = 'B';
draw_board_status(2);
draw_relays_status(2);
} else if ( (y_pos >= BOXSIZE*2 && y_pos < BOXSIZE*3)
&& (NUM_TASS_BOARDS_DISPLAY > 2) ) {
draw_board3(FILL, BLUE, WHITE);
board = 'C';
draw_board_status(3);
draw_relays_status(3);
} else if ( (y_pos >= BOXSIZE*3 && y_pos < BOXSIZE*4)
&& (NUM_TASS_BOARDS_DISPLAY > 3) ) {
draw_board4(FILL, BLUE, WHITE);
board = 'D';
draw_board_status(4);
draw_relays_status(4);
}
} // set board
// set relays -- choices are in the middle
if (x_pos >= RELAY_ROW_LEFT && x_pos <= RELAY_ROW_LEFT + BOXSIZE*4
&& y_pos >= RELAY_ROW_1_TOP && y_pos <= RELAY_ROW_2_TOP + BOXSIZE) {
draw_relays();
// set relay row 1
if (y_pos >=RELAY_ROW_1_TOP && y_pos <= RELAY_ROW_1_TOP + BOXSIZE) {
if (x_pos <= RELAY_ROW_LEFT + BOXSIZE) {
draw_board_relay(1, board_number, FILL, BLUE);
relay = 1;
} else if (x_pos <= RELAY_ROW_LEFT + BOXSIZE*2) {
draw_board_relay(2, board_number, FILL, BLUE);
relay = 2;
} else if (x_pos <= RELAY_ROW_LEFT + BOXSIZE*3) {
draw_board_relay(3, board_number, FILL, BLUE);
relay = 3;
} else if (x_pos <= RELAY_ROW_LEFT + BOXSIZE*4) {
draw_board_relay(4, board_number, FILL, BLUE);
relay = 4;
}
}
// set relay row 2
if (x_pos >= RELAY_ROW_LEFT && x_pos <= RELAY_ROW_LEFT + BOXSIZE*4
&& y_pos >= RELAY_ROW_2_TOP && y_pos <= RELAY_ROW_2_TOP + BOXSIZE) {
if (x_pos <= RELAY_ROW_LEFT + BOXSIZE) {
draw_board_relay(5, board_number, FILL, BLUE);
relay = 5;
} else if (x_pos <= RELAY_ROW_LEFT + BOXSIZE*2) {
draw_board_relay(6, board_number, FILL, BLUE);
relay = 6;
} else if (x_pos <= RELAY_ROW_LEFT + BOXSIZE*3) {
draw_board_relay(7, board_number, FILL, BLUE);
relay = 7;
} else if (x_pos <= RELAY_ROW_LEFT + BOXSIZE*4) {
draw_board_relay(8, board_number, FILL, BLUE);
relay = 8;
}
}
} // set relays
// set command -- all choices are in right-most box space
if (x_pos >=CMD_BOXLEFTEDGE) {
draw_cmds();
if (y_pos < BOXSIZE) {
draw_cmd1(FILL, BLUE, WHITE);
cmd = 'S';
} else if (y_pos >= BOXSIZE && y_pos < BOXSIZE*2) {
draw_cmd2(FILL, BLUE, WHITE);
cmd = 'H';
} else if (y_pos >= BOXSIZE*2 && y_pos < BOXSIZE*3) {
draw_cmd3(FILL, BLUE, WHITE);
cmd = 'U';
}
// else if (y_pos >= BOXSIZE*3 && y_pos < BOXSIZE*4) {
// draw_cmd4(FILL, BLUE, WHITE);
// cmd = ' ';
// Serial.println("Command: (not implemented)");
// }
} // set command
if (x_pos >= CMD_BOXLEFTEDGE && y_pos >= BOXSIZE*4) {
draw_boards();
draw_relays();
draw_cmds();
draw_cmd5(FILL, GREEN, WHITE);
draw_board_status(0);
execute = 1;
} else {
draw_cmd5(FILL, BLACK, BLACK);
draw_cmd5(NOFILL, GREEN, GREEN);
execute = 0;
}
draw_status();
if (execute) {
dataBuffer[0] = '<';
dataBuffer[1] = board;
dataBuffer[2] = relay+48; // convert int to ASCII number
dataBuffer[3] = cmd;
dataBuffer[4] = '>';
dataBuffer[5] = 0; //null terminate the C string
}
return execute;
} // of get_ts_data
void draw_board1 (boolean fill, int box_color, int text_color) {
tft.setFont();
if (fill) {
tft.fillRect(BOARD_BOXLEFTEDGE, 0, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(12, 12, char('A'), text_color, box_color, 4);
} else {
tft.drawRect(BOARD_BOXLEFTEDGE, 0, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(12, 12, char('A'), text_color, box_color, 4);
}
}
void draw_board2 (boolean fill, int box_color, int text_color) {
tft.setFont();
if (fill) {
tft.fillRect(BOARD_BOXLEFTEDGE, BOXSIZE, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(12, 60, char('B'), text_color, box_color, 4);
} else {
tft.drawRect(BOARD_BOXLEFTEDGE, BOXSIZE, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(12, 60, char('B'), text_color, box_color, 4);
}
}
void draw_board3 (boolean fill, int box_color, int text_color) {
tft.setFont();
if (fill) {
tft.fillRect(BOARD_BOXLEFTEDGE, BOXSIZE*2, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(12, 108, char('C'), text_color, box_color, 4);
} else {
tft.drawRect(BOARD_BOXLEFTEDGE, BOXSIZE*2, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(12, 108, char('C'), text_color, box_color, 4);
}
}
void draw_board4 (boolean fill, int box_color, int text_color) {
tft.setFont();
if (fill) {
tft.fillRect(BOARD_BOXLEFTEDGE, BOXSIZE*3, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(12, 156, char('D'), text_color, box_color, 4);
} else {
tft.drawRect(BOARD_BOXLEFTEDGE, BOXSIZE*3, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(12, 156, char('D'), text_color, box_color, 4);
}
}
void draw_cmd1 (boolean fill, int box_color, int text_color) {
tft.setFont();
if (fill) {
tft.fillRect(CMD_BOXLEFTEDGE, 0, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(CMD_BOXLEFTEDGE+12, 12, char('S'), text_color, box_color, 4);
} else {
tft.drawRect(CMD_BOXLEFTEDGE, 0, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(CMD_BOXLEFTEDGE+12, 12, char('S'), text_color, box_color, 4);
}
}
void draw_cmd2 (boolean fill, int box_color, int text_color) {
tft.setFont();
if (fill) {
tft.fillRect(CMD_BOXLEFTEDGE, BOXSIZE, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(CMD_BOXLEFTEDGE+12, 60, char('H'), text_color, box_color, 4);
} else {
tft.drawRect(CMD_BOXLEFTEDGE, BOXSIZE, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(CMD_BOXLEFTEDGE+12, 60, char('H'), text_color, box_color, 4);
}
}
void draw_cmd3 (boolean fill, int box_color, int text_color) {
tft.setFont();
if (fill) {
tft.fillRect(CMD_BOXLEFTEDGE, BOXSIZE*2, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(CMD_BOXLEFTEDGE+12, 108, char('U'), text_color, box_color, 4);
} else {
tft.drawRect(CMD_BOXLEFTEDGE, BOXSIZE*2, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(CMD_BOXLEFTEDGE+12, 108, char('U'), text_color, box_color, 4);
}
}
//// cmd_4 not implemented yet
//void draw_cmd4 (boolean fill, int box_color, int text_color) {
// tft.setFont();
// if (fill) {
// tft.fillRect(CMD_BOXLEFTEDGE, BOXSIZE*3, BOXSIZE, BOXSIZE, box_color);
// tft.drawChar(CMD_BOXLEFTEDGE+12, 156, char(' '), text_color, box_color, 4);
// } else {
// tft.drawRect(CMD_BOXLEFTEDGE, BOXSIZE*3, BOXSIZE, BOXSIZE, box_color);
// tft.drawChar(CMD_BOXLEFTEDGE+12, 156, char(' '), text_color, box_color, 4);
// }
//}
void draw_cmd5 (boolean fill, int box_color, int text_color) {
tft.setFont();
if (fill) {
tft.fillRect(CMD_BOXLEFTEDGE, BOXSIZE*4, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(CMD_BOXLEFTEDGE+12, 204, char('G'), text_color, box_color, 4);
} else {
tft.drawRect(CMD_BOXLEFTEDGE, BOXSIZE*4, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(CMD_BOXLEFTEDGE+12, 204, char('G'), text_color, box_color, 4);
}
}
void draw_relay (int relay, boolean fill, int box_color, int text_color, int text_bg) {
uint16_t x = 0;
uint16_t y = 0;
int box = 0;
switch(relay) {
case 1:
x = 12;
y = RELAY_ROW_1_TOP;
box = 0;
break;
case 2:
x = 60;
y = RELAY_ROW_1_TOP;
box = 1;
break;
case 3:
x = 108;
y = RELAY_ROW_1_TOP;
box = 2;
break;
case 4:
x = 156;
y= RELAY_ROW_1_TOP;
box = 3;
break;
case 5:
x = 12;
y = RELAY_ROW_2_TOP;
box = 0;
break;
case 6:
x = 60;
y = RELAY_ROW_2_TOP;
box = 1;
break;
case 7:
x = 108;
y = RELAY_ROW_2_TOP;
box = 2;
break;
case 8:
x = 156;
y= RELAY_ROW_2_TOP;
box = 3;
break;
}
tft.setFont();
if (fill) {
tft.fillRect(RELAY_ROW_LEFT + (BOXSIZE * box), y, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(RELAY_ROW_LEFT + x, y + 12, char(relay+48), text_color, text_bg, 4);
} else {
tft.drawRect(RELAY_ROW_LEFT + (BOXSIZE * box), y, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(RELAY_ROW_LEFT + x, y + 12, char(relay+48), text_color, text_bg, 4);
}
}
void draw_board_relay(int relay, int board, boolean fill, int box_color){
uint16_t x = 0;
uint16_t y = 0;
int box = 0;
int text_color = 0;
int text_bg = box_color;
int first_dpin = 0;
int hold_mask = 0;
switch(relay) {
case 1:
x = 12;
y = RELAY_ROW_1_TOP;
box = 0;
break;
case 2:
x = 60;
y = RELAY_ROW_1_TOP;
box = 1;
break;
case 3:
x = 108;
y = RELAY_ROW_1_TOP;
box = 2;
break;
case 4:
x = 156;
y= RELAY_ROW_1_TOP;
box = 3;
break;
case 5:
x = 12;
y = RELAY_ROW_2_TOP;
box = 0;
break;
case 6:
x = 60;
y = RELAY_ROW_2_TOP;
box = 1;
break;
case 7:
x = 108;
y = RELAY_ROW_2_TOP;
box = 2;
break;
case 8:
x = 156;
y= RELAY_ROW_2_TOP;
box = 3;
break;
}
switch(board){
case 1:
first_dpin = A_1;
hold_mask = H_mask_A;
break;
case 2:
first_dpin = B_1;
hold_mask = H_mask_B;
break;
case 3:
first_dpin = C_1;
hold_mask = H_mask_C;
break;
case 4:
first_dpin = D_1;
hold_mask = H_mask_D;
break;
}
draw_relays_status(board);
if ( digitalRead(first_dpin + ( relay - 1)) ) {
if (get_bit_mask_state(relay -1, hold_mask) == 1) {
text_color = ORANGE;
}
else {
text_color = RED;
}
}
else {
text_color = WHITE;
}
tft.setFont();
if (fill) {
tft.fillRect(RELAY_ROW_LEFT + (BOXSIZE * box), y, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(RELAY_ROW_LEFT + x, y + 12, char(relay+48), text_color, text_bg, 4);
} else {
tft.drawRect(RELAY_ROW_LEFT + (BOXSIZE * box), y, BOXSIZE, BOXSIZE, box_color);
tft.drawChar(RELAY_ROW_LEFT + x, y + 12, char(relay+48), text_color, text_bg, 4);
}
}
void draw_boards() {
// to clear previous fill, we do twice, -- once with fill with black, then nofill with colors
if (NUM_TASS_BOARDS_DISPLAY > 0) {
draw_board1(FILL, BLACK, BLACK);
draw_board1(NOFILL, WHITE, WHITE);
}
if (NUM_TASS_BOARDS_DISPLAY > 1) {
draw_board2(FILL, BLACK, BLACK);
draw_board2(NOFILL, WHITE, WHITE);
}
if (NUM_TASS_BOARDS_DISPLAY > 2) {
draw_board3(FILL, BLACK, BLACK);
draw_board3(NOFILL, WHITE, WHITE);
}
if (NUM_TASS_BOARDS_DISPLAY > 3) {
draw_board4(FILL, BLACK, BLACK);
draw_board4(NOFILL, WHITE, WHITE);
}
}
void draw_cmds() {
draw_cmd1(FILL, BLACK, BLACK);
draw_cmd2(FILL, BLACK, BLACK);
draw_cmd3(FILL, BLACK, BLACK);
//draw_cmd4(FILL, BLACK, BLACK);
draw_cmd5(FILL, BLACK, BLACK);
draw_cmd1(NOFILL, WHITE, WHITE);
draw_cmd2(NOFILL, WHITE, WHITE);
draw_cmd3(NOFILL, WHITE, WHITE);
//draw_cmd4(NOFILL, WHITE, WHITE);
draw_cmd5(NOFILL, GREEN, GREEN); // cmd5 is execute, so we give him a different color
}
void draw_relays() {
draw_relay(1, FILL, BLACK, BLACK, BLACK);
draw_relay(2, FILL, BLACK, BLACK, BLACK);
draw_relay(3, FILL, BLACK, BLACK, BLACK);
draw_relay(4, FILL, BLACK, BLACK, BLACK);
draw_relay(5, FILL, BLACK, BLACK, BLACK);
draw_relay(6, FILL, BLACK, BLACK, BLACK);
draw_relay(7, FILL, BLACK, BLACK, BLACK);
draw_relay(8, FILL, BLACK, BLACK, BLACK);
draw_relay(1, NOFILL, WHITE, WHITE, WHITE);
draw_relay(2, NOFILL, WHITE, WHITE, WHITE);
draw_relay(3, NOFILL, WHITE, WHITE, WHITE);
draw_relay(4, NOFILL, WHITE, WHITE, WHITE);
draw_relay(5, NOFILL, WHITE, WHITE, WHITE);
draw_relay(6, NOFILL, WHITE, WHITE, WHITE);
draw_relay(7, NOFILL, WHITE, WHITE, WHITE);
draw_relay(8, NOFILL, WHITE, WHITE, WHITE);
}
void draw_relays_status(int board) {
int first_dpin = -1;
int hold_mask = -1;
int i = -1;
switch(board){
case 1:
first_dpin = A_1;
hold_mask = H_mask_A;
break;
case 2:
first_dpin = B_1;
hold_mask = H_mask_B;
break;
case 3:
first_dpin = C_1;
hold_mask = H_mask_C;
break;
case 4:
first_dpin = D_1;
hold_mask = H_mask_D;
break;
}
for ( i=0; i < 8; i++ ) {
if ( digitalRead(first_dpin + i) ) {
if ( get_bit_mask_state(i, hold_mask) == 1 ) {
draw_relay(i+1,NOFILL, WHITE, ORANGE, BLACK);
}
else {
draw_relay(i+1,NOFILL, WHITE, RED, BLACK);
}
}
else {
draw_relay(i+1,NOFILL, WHITE, WHITE, BLACK);
}
}
}
void draw_status() {
int fg = 0;
int bg = BLACK;
if (!execute) {
tft.setTextColor(WHITE, BLACK);
fg = WHITE;
} else{
tft.setTextColor(GREEN, BLACK);
fg = GREEN;
}
tft.setFont(&FreeSans9pt7b);
tft.setTextSize(1);
tft.setCursor(102, 185);
tft.print("Board = ");
tft.fillRect(207,173,12,14,BLACK);
tft.drawChar(207,185,char(board),fg,bg,1);
tft.setCursor(102, 205);
tft.print("Relay = ");
tft.fillRect(207,193,12,14,BLACK);
tft.drawChar(207,205,relay+48,fg,bg,1);
tft.setCursor(102, 225);
tft.print("Command = ");
tft.fillRect(207,213,12,14,BLACK);
tft.drawChar(207,225,char(cmd),fg,bg,1);
} // draw status
void draw_board_status(int board) {
board == 0 ;
// Clear display area with a black rectangle.
tft.fillRect(57,0,205,25,BLACK);
#ifdef SPLIT
tft.setFont(&FreeSans9pt7b);
tft.setTextColor(WHITE, BLACK);
tft.setTextSize(1);
tft.setCursor(64, 20);
tft.print("K9 SPLIT");
#endif
// This need for the else if in the ifdef.
if (board == 0) {
}
#ifdef A_B_COMBINE
else if (board == 1) {
tft.setFont(&FreeSans9pt7b);
tft.setTextColor(WHITE, BLACK);
tft.setTextSize(1);
tft.setCursor(57, 20);
tft.print("Board A and B Combined");
}
else if (board == 2) {
tft.setFont(&FreeSans9pt7b);
tft.setTextColor(WHITE, BLACK);
tft.setTextSize(1);
tft.setCursor(57, 20);
tft.print("Board A and B Combined");
}
#endif
#ifdef A_DOUBLE_POLE
else if (board == 1) {
tft.setFont(&FreeSans9pt7b);
tft.setTextColor(WHITE, BLACK);
tft.setTextSize(1);
tft.setCursor(70, 20);
tft.print("Board A - Double Pole");
}
#endif
}
void draw_relay_labels() {
tft.setFont();
tft.setTextColor(RED, BLACK);
tft.setTextSize(1);
tft.setCursor(95, 85);
tft.print("RED: Relay is SET");
tft.setTextColor(ORANGE, BLACK);
tft.setCursor(95, 95);
tft.print("ORANGE: Relay is HELD");
}
void tft_setup() {
// initialize tft
tft.begin();
if (! ctp.begin(40)) { // pass in 'sensitivity' coefficient
Serial.println("Couldn't start FT6206 touchscreen controller");
while (1);
}
tft.setFont();
tft.setRotation(1);
tft.fillScreen(BLACK);
tft.setTextColor(RED);
tft.setTextSize(3);
tft.setCursor(80, 40);
tft.print("N8UR/TAPR");
tft.setTextColor(BLUE);
tft.setCursor(115, 80);
// tft.print("N4MTT");
// tft.setTextColor(WHITE);
tft.setCursor(30, 120);
tft.print("TASS Controller");
tft.setFont();
tft.setTextColor(ORANGE);
tft.setTextSize(2);
tft.setCursor(0, 220);
tft.print(version);
delay(5000);
tft.fillScreen(BLACK);
draw_boards();
draw_relays();
draw_cmds();
draw_status();
draw_relay_labels();
} // tft_setup
#endif