-
Notifications
You must be signed in to change notification settings - Fork 0
/
Thermostat.ino.bak
720 lines (610 loc) · 29.2 KB
/
Thermostat.ino.bak
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
709
710
711
712
713
714
715
716
717
718
719
//<File !Start!>
// FILE: [Thermostat.ino]
// Created by GUIslice Builder version: [0.13.b009]
//
// GUIslice Builder Generated File
//
// For the latest guides, updates and support view:
// https://github.com/ImpulseAdventure/GUIslice
//
//<File !End!>
//
// ARDUINO NOTES:
// - GUIslice_config.h must be edited to match the pinout connections
// between the Arduino CPU and the display controller (see ADAGFX_PIN_*).
//
// ------------------------------------------------
// Headers to include
// ------------------------------------------------
#include "GUIslice.h"
#include "GUIslice_drv.h"
// Include any extended elements
//<Includes !Start!>
// Ensure optional features are enabled in the configuration
#if !(GSLC_SD_EN)
#error "Config: GSLC_SD_EN required for this program but not enabled. Please update GUIslice/config/"
#endif
//<Includes !End!>
// ------------------------------------------------
// Headers and Defines for fonts
// Note that font files are located within the Adafruit-GFX library folder:
// ------------------------------------------------
//<Fonts !Start!>
//<Fonts !End!>
// ------------------------------------------------
// Defines for resources
// ------------------------------------------------
//<Resources !Start!>
#define IMG_FIRE "/fire.bmp"
#define IMG_GREEN_LIGHT "/green_light.bmp"
#define IMG_PIXILFRAME0 "/pixil-frame-0.bmp"
#define IMG_PIXILFRAME0_SEL "/pixil-frame-0.bmp"
#define IMG_RED_LIGHT "/red_light.bmp"
#define IMG_SNOWFLAKE "/snowflake.bmp"
//<Resources !End!>
// ------------------------------------------------
// Enumerations for pages, elements, fonts, images
// ------------------------------------------------
//<Enum !Start!>
enum {E_PG_MAIN,E_PG2,E_PG3,E_PG4};
enum {AC_BTN,AM_PM_DOWN,AM_PM_TEXT,AM_PM_UP,AUTO_BTN,CUR_TEMP_TEXT
,DATE_TEXT,DAY_DOWN,DAY_TEXT,DAY_UP,DOWN_BTN,ENABLE_BTN
,E_DRAW_LINE1,E_ELEM_IBTN10,E_ELEM_IBTN11,E_ELEM_IBTN12
,E_ELEM_IBTN5,E_ELEM_IBTN9,E_ELEM_IMAGE9,E_ELEM_TEXT16
,E_ELEM_TEXT17,E_ELEM_TEXT7,E_ELEM_TEXT8,FIRE_IMG,HEAT_BTN
,HOLD_BTN,HOME_BTN_1,HOME_BTN_2,HOUR_DOWN,HOUR_TEXT,HOUR_UP
,MIN_DOWN,MIN_TEXT,MIN_UP,MONTH_DOWN,MONTH_TEXT,MONTH_UP,OFF_BTN
,PRGM_BTN,SAVE_BTN,SETTINGS_BTN,SET_PROGRAM_TEMP_TEXT
,SET_TEMP_TEXT,SNOW_IMG,WK1_PRG_LIGHT,WK2_PRG_LIGHT,WK3_PRG_LIGHT
,WK4_PRG_LIGHT,WKND1_PRG_LIGHT,WKND2_PRG_LIGHT,WKND3_PRG_LIGHT
,WKND_1_BTN,WKND_2_BTN,WKND_3_BTN,WKND_4_BTN,WK_1_BTN,WK_2_BTN
,WK_3_BTN,WK_4_BTN,YEAR_DOWN,YEAR_TEXT,YEAR_UP};
// Must use separate enum for fonts with MAX_FONT at end to use gslc_FontSet.
enum {E_FONT_TXT5,MAX_FONT};
//<Enum !End!>
// ------------------------------------------------
// Instantiate the GUI
// ------------------------------------------------
// ------------------------------------------------
// Define the maximum number of elements and pages
// ------------------------------------------------
//<ElementDefines !Start!>
#define MAX_PAGE 4
#define MAX_ELEM_PG_MAIN 14 // # Elems total on page
#define MAX_ELEM_PG_MAIN_RAM MAX_ELEM_PG_MAIN // # Elems in RAM
#define MAX_ELEM_PG2 20 // # Elems total on page
#define MAX_ELEM_PG2_RAM MAX_ELEM_PG2 // # Elems in RAM
#define MAX_ELEM_PG3 19 // # Elems total on page
#define MAX_ELEM_PG3_RAM MAX_ELEM_PG3 // # Elems in RAM
#define MAX_ELEM_PG4 9 // # Elems total on page
#define MAX_ELEM_PG4_RAM MAX_ELEM_PG4 // # Elems in RAM
//<ElementDefines !End!>
// ------------------------------------------------
// Create element storage
// ------------------------------------------------
gslc_tsGui m_gui;
gslc_tsDriver m_drv;
gslc_tsFont m_asFont[MAX_FONT];
gslc_tsPage m_asPage[MAX_PAGE];
//<GUI_Extra_Elements !Start!>
gslc_tsElem m_asPage1Elem[MAX_ELEM_PG_MAIN_RAM];
gslc_tsElemRef m_asPage1ElemRef[MAX_ELEM_PG_MAIN];
gslc_tsElem m_asPage2Elem[MAX_ELEM_PG2_RAM];
gslc_tsElemRef m_asPage2ElemRef[MAX_ELEM_PG2];
gslc_tsElem m_asPage3Elem[MAX_ELEM_PG3_RAM];
gslc_tsElemRef m_asPage3ElemRef[MAX_ELEM_PG3];
gslc_tsElem m_asPage4Elem[MAX_ELEM_PG4_RAM];
gslc_tsElemRef m_asPage4ElemRef[MAX_ELEM_PG4];
#define MAX_STR 100
//<GUI_Extra_Elements !End!>
// ------------------------------------------------
// Program Globals
// ------------------------------------------------
// Save some element references for direct access
//<Save_References !Start!>
gslc_tsElemRef* m_pElemOutTxt1 = NULL;
gslc_tsElemRef* m_pElemOutTxt4 = NULL;
//<Save_References !End!>
// Define debug message function
static int16_t DebugOut(char ch) { if (ch == (char)'\n') Serial.println(""); else Serial.write(ch); return 0; }
// ------------------------------------------------
// Callback Methods
// ------------------------------------------------
// Common Button callback
bool CbBtnCommon(void* pvGui,void *pvElemRef,gslc_teTouch eTouch,int16_t nX,int16_t nY)
{
gslc_tsElemRef* pElemRef = (gslc_tsElemRef*)(pvElemRef);
gslc_tsElem* pElem = pElemRef->pElem;
if ( eTouch == GSLC_TOUCH_UP_IN ) {
// From the element's ID we can determine which button was pressed.
switch (pElem->nId) {
//<Button Enums !Start!>
case DOWN_BTN:
//TODO- Replace with button handling code
break;
case PRGM_BTN:
//TODO- Check the code to see what else you may need to add
gslc_SetPageCur(&m_gui,E_PG2);
break;
case SETTINGS_BTN:
//TODO- Replace with button handling code
break;
case HOLD_BTN:
//TODO- Replace with button handling code
break;
case HEAT_BTN:
//TODO- Replace with button handling code
break;
case AC_BTN:
//TODO- Replace with button handling code
break;
case AUTO_BTN:
//TODO- Replace with button handling code
break;
case OFF_BTN:
//TODO- Replace with button handling code
break;
case WK_1_BTN:
//TODO- Replace with button handling code
break;
case WK_2_BTN:
//TODO- Replace with button handling code
break;
case WK_3_BTN:
//TODO- Replace with button handling code
break;
case WK_4_BTN:
//TODO- Replace with button handling code
break;
case WKND_1_BTN:
//TODO- Replace with button handling code
break;
case WKND_2_BTN:
//TODO- Replace with button handling code
break;
case WKND_3_BTN:
//TODO- Replace with button handling code
break;
case WKND_4_BTN:
//TODO- Replace with button handling code
break;
case E_ELEM_IBTN5:
//TODO- Replace with button handling code
break;
case HOME_BTN_1:
//TODO- Replace with button handling code
break;
case E_ELEM_IBTN9:
//TODO- Replace with button handling code
break;
case E_ELEM_IBTN10:
//TODO- Replace with button handling code
break;
case E_ELEM_IBTN11:
//TODO- Replace with button handling code
break;
case E_ELEM_IBTN12:
//TODO- Replace with button handling code
break;
case MIN_UP:
//TODO- Replace with button handling code
break;
case AM_PM_UP:
//TODO- Replace with button handling code
break;
case HOME_BTN_2:
//TODO- Replace with button handling code
break;
case MONTH_DOWN:
//TODO- Replace with button handling code
break;
case DAY_DOWN:
//TODO- Replace with button handling code
break;
case YEAR_DOWN:
//TODO- Replace with button handling code
break;
case HOUR_DOWN:
//TODO- Replace with button handling code
break;
case MIN_DOWN:
//TODO- Replace with button handling code
break;
case AM_PM_DOWN:
//TODO- Replace with button handling code
break;
case SAVE_BTN:
//TODO- Replace with button handling code
break;
case ENABLE_BTN:
//TODO- Replace with button handling code
break;
case MONTH_UP:
//TODO- Replace with button handling code
break;
case DAY_UP:
//TODO- Replace with button handling code
break;
case YEAR_UP:
//TODO- Replace with button handling code
break;
case HOUR_UP:
//TODO- Replace with button handling code
break;
//<Button Enums !End!>
default:
break;
}
}
return true;
}
//<Checkbox Callback !Start!>
//<Checkbox Callback !End!>
//<Keypad Callback !Start!>
//<Keypad Callback !End!>
//<Spinner Callback !Start!>
//<Spinner Callback !End!>
//<Listbox Callback !Start!>
//<Listbox Callback !End!>
//<Draw Callback !Start!>
//<Draw Callback !End!>
//<Slider Callback !Start!>
//<Slider Callback !End!>
//<Tick Callback !Start!>
//<Tick Callback !End!>
// ------------------------------------------------
// Create page elements
// ------------------------------------------------
bool InitGUI()
{
gslc_tsElemRef* pElemRef = NULL;
//<InitGUI !Start!>
gslc_PageAdd(&m_gui,E_PG_MAIN,m_asPage1Elem,MAX_ELEM_PG_MAIN_RAM,m_asPage1ElemRef,MAX_ELEM_PG_MAIN);
gslc_PageAdd(&m_gui,E_PG2,m_asPage2Elem,MAX_ELEM_PG2_RAM,m_asPage2ElemRef,MAX_ELEM_PG2);
gslc_PageAdd(&m_gui,E_PG3,m_asPage3Elem,MAX_ELEM_PG3_RAM,m_asPage3ElemRef,MAX_ELEM_PG3);
gslc_PageAdd(&m_gui,E_PG4,m_asPage4Elem,MAX_ELEM_PG4_RAM,m_asPage4ElemRef,MAX_ELEM_PG4);
// NOTE: The current page defaults to the first page added. Here we explicitly
// ensure that the main page is the correct page no matter the add order.
gslc_SetPageCur(&m_gui,E_PG_MAIN);
// Set Background to a flat color
gslc_SetBkgndColor(&m_gui,GSLC_COL_WHITE);
// -----------------------------------
// PAGE: E_PG_MAIN
// Create SET_TEMP_TEXT runtime modifiable text
static char m_sDisplayText1[10] = "Temp";
pElemRef = gslc_ElemCreateTxt(&m_gui,SET_TEMP_TEXT,E_PG_MAIN,(gslc_tsRect){130,110,48,10},
(char*)m_sDisplayText1,10,E_FONT_TXT5);
gslc_ElemSetTxtAlign(&m_gui,pElemRef,GSLC_ALIGN_MID_MID);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_BLACK,GSLC_COL_WHITE,GSLC_COL_BLACK);
m_pElemOutTxt1 = pElemRef;
// Create CUR_TEMP_TEXT text label
pElemRef = gslc_ElemCreateTxt(&m_gui,CUR_TEMP_TEXT,E_PG_MAIN,(gslc_tsRect){20,110,72,10},
(char*)"Current Temp",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY_DK3,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create DATE_TEXT runtime modifiable text
static char m_sDisplayText4[11] = "Date";
pElemRef = gslc_ElemCreateTxt(&m_gui,DATE_TEXT,E_PG_MAIN,(gslc_tsRect){10,25,54,10},
(char*)m_sDisplayText4,11,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
m_pElemOutTxt4 = pElemRef;
// create PRGM_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,PRGM_BTN,E_PG_MAIN,
(gslc_tsRect){260,10,50,40},(char*)"Program",0,E_FONT_TXT5,&CbBtnCommon);
// create HOLD_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,HOLD_BTN,E_PG_MAIN,
(gslc_tsRect){240,90,50,40},(char*)"Hold",0,E_FONT_TXT5,&CbBtnCommon);
// create HEAT_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,HEAT_BTN,E_PG_MAIN,
(gslc_tsRect){80,190,50,40},(char*)"Heat",0,E_FONT_TXT5,&CbBtnCommon);
// create AC_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,AC_BTN,E_PG_MAIN,
(gslc_tsRect){140,190,50,40},(char*)"AC",0,E_FONT_TXT5,&CbBtnCommon);
// create AUTO_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,AUTO_BTN,E_PG_MAIN,
(gslc_tsRect){200,190,50,40},(char*)"Auto",0,E_FONT_TXT5,&CbBtnCommon);
// create OFF_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,OFF_BTN,E_PG_MAIN,
(gslc_tsRect){260,190,50,40},(char*)"Off",0,E_FONT_TXT5,&CbBtnCommon);
// Create E_ELEM_IBTN5 button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,E_ELEM_IBTN5,E_PG_MAIN,(gslc_tsRect){130,50,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create DOWN_BTN button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,DOWN_BTN,E_PG_MAIN,(gslc_tsRect){130,130,50,40},
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create SETTINGS_BTN button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,SETTINGS_BTN,E_PG_MAIN,(gslc_tsRect){60,10,50,40},
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create E_ELEM_IMAGE9 using Image
pElemRef = gslc_ElemCreateImg(&m_gui,E_ELEM_IMAGE9,E_PG_MAIN,(gslc_tsRect){40,200,20,20},
gslc_GetImageFromSD((const char*)IMG_SNOWFLAKE,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create FIRE_IMG using Image
pElemRef = gslc_ElemCreateImg(&m_gui,FIRE_IMG,E_PG_MAIN,(gslc_tsRect){10,200,20,20},
gslc_GetImageFromSD((const char*)IMG_FIRE,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// -----------------------------------
// PAGE: E_PG2
// Create E_ELEM_TEXT7 text label
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT7,E_PG2,(gslc_tsRect){30,10,42,10},
(char*)"Weekday",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create E_ELEM_TEXT8 text label
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT8,E_PG2,(gslc_tsRect){220,10,42,10},
(char*)"Weekend",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create E_DRAW_LINE1 line
pElemRef = gslc_ElemCreateLine(&m_gui,E_DRAW_LINE1,E_PG2,0,22,320,22);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_BLACK,GSLC_COL_BLACK,GSLC_COL_BLACK);
// create WK_1_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,WK_1_BTN,E_PG2,
(gslc_tsRect){10,30,80,30},(char*)"Program 1",0,E_FONT_TXT5,&CbBtnCommon);
// create WK_2_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,WK_2_BTN,E_PG2,
(gslc_tsRect){10,70,80,30},(char*)"Program 2",0,E_FONT_TXT5,&CbBtnCommon);
// create WK_3_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,WK_3_BTN,E_PG2,
(gslc_tsRect){10,110,80,30},(char*)"Program 3",0,E_FONT_TXT5,&CbBtnCommon);
// create WK_4_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,WK_4_BTN,E_PG2,
(gslc_tsRect){10,150,80,30},(char*)"Program 4",0,E_FONT_TXT5,&CbBtnCommon);
// create WKND_1_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,WKND_1_BTN,E_PG2,
(gslc_tsRect){180,30,80,30},(char*)"Program 1",0,E_FONT_TXT5,&CbBtnCommon);
// create WKND_2_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,WKND_2_BTN,E_PG2,
(gslc_tsRect){180,70,80,30},(char*)"Program 2",0,E_FONT_TXT5,&CbBtnCommon);
// create WKND_3_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,WKND_3_BTN,E_PG2,
(gslc_tsRect){180,110,80,30},(char*)"Program 3",0,E_FONT_TXT5,&CbBtnCommon);
// create WKND_4_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,WKND_4_BTN,E_PG2,
(gslc_tsRect){180,150,80,30},(char*)"Program 4",0,E_FONT_TXT5,&CbBtnCommon);
// Create HOME_BTN_1 button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,HOME_BTN_1,E_PG2,(gslc_tsRect){140,190,50,40},
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create WKND1_PRG_LIGHT using Image
pElemRef = gslc_ElemCreateImg(&m_gui,WKND1_PRG_LIGHT,E_PG2,(gslc_tsRect){270,30,30,30},
gslc_GetImageFromProg((const unsigned char*)IMG_RED_LIGHT,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create WK1_PRG_LIGHT using Image
pElemRef = gslc_ElemCreateImg(&m_gui,WK1_PRG_LIGHT,E_PG2,(gslc_tsRect){100,30,30,30},
gslc_GetImageFromProg((const unsigned char*)IMG_RED_LIGHT,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create WK2_PRG_LIGHT using Image
pElemRef = gslc_ElemCreateImg(&m_gui,WK2_PRG_LIGHT,E_PG2,(gslc_tsRect){100,70,30,30},
gslc_GetImageFromProg((const unsigned char*)IMG_GREEN_LIGHT,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create WK3_PRG_LIGHT using Image
pElemRef = gslc_ElemCreateImg(&m_gui,WK3_PRG_LIGHT,E_PG2,(gslc_tsRect){100,110,30,30},
gslc_GetImageFromProg((const unsigned char*)IMG_GREEN_LIGHT,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create WK4_PRG_LIGHT using Image
pElemRef = gslc_ElemCreateImg(&m_gui,WK4_PRG_LIGHT,E_PG2,(gslc_tsRect){100,150,30,30},
gslc_GetImageFromProg((const unsigned char*)IMG_RED_LIGHT,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create WKND2_PRG_LIGHT using Image
pElemRef = gslc_ElemCreateImg(&m_gui,WKND2_PRG_LIGHT,E_PG2,(gslc_tsRect){270,70,30,30},
gslc_GetImageFromProg((const unsigned char*)IMG_RED_LIGHT,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create WKND3_PRG_LIGHT using Image
pElemRef = gslc_ElemCreateImg(&m_gui,WKND3_PRG_LIGHT,E_PG2,(gslc_tsRect){270,110,30,30},
gslc_GetImageFromProg((const unsigned char*)IMG_GREEN_LIGHT,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create SNOW_IMG using Image
pElemRef = gslc_ElemCreateImg(&m_gui,SNOW_IMG,E_PG2,(gslc_tsRect){270,150,30,30},
gslc_GetImageFromProg((const unsigned char*)IMG_GREEN_LIGHT,GSLC_IMGREF_FMT_BMP24));
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// -----------------------------------
// PAGE: E_PG3
// Create MONTH_TEXT text label
pElemRef = gslc_ElemCreateTxt(&m_gui,MONTH_TEXT,E_PG3,(gslc_tsRect){30,120,12,10},
(char*)"12",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create DAY_TEXT text label
pElemRef = gslc_ElemCreateTxt(&m_gui,DAY_TEXT,E_PG3,(gslc_tsRect){80,120,12,10},
(char*)"05",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create YEAR_TEXT text label
pElemRef = gslc_ElemCreateTxt(&m_gui,YEAR_TEXT,E_PG3,(gslc_tsRect){120,120,24,10},
(char*)"2019",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create HOUR_TEXT text label
pElemRef = gslc_ElemCreateTxt(&m_gui,HOUR_TEXT,E_PG3,(gslc_tsRect){180,120,6,10},
(char*)"2",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create MIN_TEXT text label
pElemRef = gslc_ElemCreateTxt(&m_gui,MIN_TEXT,E_PG3,(gslc_tsRect){230,120,12,10},
(char*)"58",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create AM_PM_TEXT text label
pElemRef = gslc_ElemCreateTxt(&m_gui,AM_PM_TEXT,E_PG3,(gslc_tsRect){280,120,12,10},
(char*)"AM",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create E_ELEM_IBTN9 button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,E_ELEM_IBTN9,E_PG3,(gslc_tsRect){10,60,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create E_ELEM_IBTN10 button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,E_ELEM_IBTN10,E_PG3,(gslc_tsRect){60,60,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create E_ELEM_IBTN11 button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,E_ELEM_IBTN11,E_PG3,(gslc_tsRect){110,60,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create E_ELEM_IBTN12 button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,E_ELEM_IBTN12,E_PG3,(gslc_tsRect){160,60,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create MIN_UP button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,MIN_UP,E_PG3,(gslc_tsRect){210,60,50,40},
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create AM_PM_UP button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,AM_PM_UP,E_PG3,(gslc_tsRect){260,60,50,40},
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create HOME_BTN_2 button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,HOME_BTN_2,E_PG3,(gslc_tsRect){260,10,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create MONTH_DOWN button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,MONTH_DOWN,E_PG3,(gslc_tsRect){10,150,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create DAY_DOWN button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,DAY_DOWN,E_PG3,(gslc_tsRect){60,150,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create YEAR_DOWN button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,YEAR_DOWN,E_PG3,(gslc_tsRect){110,150,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create HOUR_DOWN button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,HOUR_DOWN,E_PG3,(gslc_tsRect){160,150,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create MIN_DOWN button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,MIN_DOWN,E_PG3,(gslc_tsRect){210,150,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create AM_PM_DOWN button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,AM_PM_DOWN,E_PG3,(gslc_tsRect){260,150,50,40},
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromSD((const char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// -----------------------------------
// PAGE: E_PG4
// Create SET_PROGRAM_TEMP_TEXT text label
pElemRef = gslc_ElemCreateTxt(&m_gui,SET_PROGRAM_TEMP_TEXT,E_PG4,(gslc_tsRect){190,110,24,10},
(char*)"Temp",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// create SAVE_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,SAVE_BTN,E_PG4,
(gslc_tsRect){100,160,50,40},(char*)"Save",0,E_FONT_TXT5,&CbBtnCommon);
// create ENABLE_BTN button with text label
pElemRef = gslc_ElemCreateBtnTxt(&m_gui,ENABLE_BTN,E_PG4,
(gslc_tsRect){30,160,50,40},(char*)"Enable",0,E_FONT_TXT5,&CbBtnCommon);
// Create E_ELEM_TEXT16 text label
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT16,E_PG4,(gslc_tsRect){40,120,84,10},
(char*)"Enabled Status",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create E_ELEM_TEXT17 text label
pElemRef = gslc_ElemCreateTxt(&m_gui,E_ELEM_TEXT17,E_PG4,(gslc_tsRect){130,10,78,10},
(char*)"Program Title",0,E_FONT_TXT5);
gslc_ElemSetTxtCol(&m_gui,pElemRef,GSLC_COL_BLACK);
gslc_ElemSetCol(&m_gui,pElemRef,GSLC_COL_GRAY,GSLC_COL_WHITE,GSLC_COL_BLACK);
// Create MONTH_UP button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,MONTH_UP,E_PG4,(gslc_tsRect){180,135,50,40},
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create DAY_UP button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,DAY_UP,E_PG4,(gslc_tsRect){180,50,50,40},
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create YEAR_UP button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,YEAR_UP,E_PG4,(gslc_tsRect){260,190,50,40},
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
// Create HOUR_UP button with image label
pElemRef = gslc_ElemCreateBtnImg(&m_gui,HOUR_UP,E_PG4,(gslc_tsRect){260,10,50,40},
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0,GSLC_IMGREF_FMT_BMP24),
gslc_GetImageFromProg((const unsigned char*)IMG_PIXILFRAME0_SEL,GSLC_IMGREF_FMT_BMP24),
&CbBtnCommon);
gslc_ElemSetFillEn(&m_gui,pElemRef,false);
//<InitGUI !End!>
return true;
}
void setup()
{
// ------------------------------------------------
// Initialize
// ------------------------------------------------
Serial.begin(9600);
// Wait for USB Serial
//delay(1000); // NOTE: Some devices require a delay after Serial.begin() before serial port can be used
gslc_InitDebug(&DebugOut);
if (!gslc_Init(&m_gui,&m_drv,m_asPage,MAX_PAGE,m_asFont,MAX_FONT)) { return; }
// ------------------------------------------------
// Load Fonts
// ------------------------------------------------
//<Load_Fonts !Start!>
if (!gslc_FontSet(&m_gui,E_FONT_TXT5,GSLC_FONTREF_PTR,NULL,1)) { return; }
//<Load_Fonts !End!>
// ------------------------------------------------
// Create graphic elements
// ------------------------------------------------
InitGUI();
//<Startup !Start!>
//<Startup !End!>
}
// -----------------------------------
// Main event loop
// -----------------------------------
void loop()
{
// ------------------------------------------------
// Update GUI Elements
// ------------------------------------------------
//TODO - Add update code for any text, gauges, or sliders
// ------------------------------------------------
// Periodically call GUIslice update function
// ------------------------------------------------
gslc_Update(&m_gui);
}