forked from dEskoG/rDUINOScope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtouch_inputs.ino
954 lines (927 loc) · 35.6 KB
/
touch_inputs.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
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
//
// rDUINOScope - Arduino based telescope control system (GOTO).
// Copyright (C) 2016 Dessislav Gouzgounov (Desso)
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// PROJECT Website: http://rduinoscope.byethost24.com
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// ......................................................................
// This part of the code take care of:
// - Handles ALL TOUCH SCREEN Inputs;
// - Screens are separated like:
// * CURRENT_SCREEN==0 - drawGPSScreen() Where the GPS coordinates are displayed
// * CURRENT_SCREEN==1 - drawClockScreen() Captures updates on the time and date
// * CURRENT_SCREEN==2 - - not used
// * CURRENT_SCREEN==3 - Select Alignment method (only have 3 buttons)
// * CURRENT_SCREEN==4 - drawMainScreen() Captures all clicks on the MAIN Screen of the application
// * CURRENT_SCREEN==5 - drawCoordinatesScreen() Only have "back" button
// * CURRENT_SCREEN==6 - drawLoadScreen() Captures input on Load screen (all of them: Messier && Treasurres)
// * CURRENT_SCREEN==7 - drawOptionsScreen();
// * CURRENT_SCREEN==8 - - not used
// * CURRENT_SCREEN==9 - - not used
// * CURRENT_SCREEN==10 - drawSTATScreen()
// * CURRENT_SCREEN==11 - - not used
// * CURRENT_SCREEN==12 - drawStarSyncScreen() - To Select Alignment Star;
// * CURRENT_SCREEN==13 - drawConstelationScreen(int indx) - to actually align on Star. Called few times per alignment procedure.
//
// - Please note, that Touches are separated in 2 section to capture OnPress && OnRelease!
// You will notice that "if (lx > 0 && ly > 0 )" this part defines OnPress activities.
void considerTouchInput(int lx, int ly){
//**************************************************************
//
// BUTTON DOWN Events start here
//
// - only executed when the user touches the screen - PRESS
//**************************************************************
if (lx > 0 && ly > 0 ){
// Make sure you WakeUp the TFT
// in case the lid is OFF
if (IS_TFT_ON == false){
analogWrite(TFTBright, TFT_Brightness);
IS_TFT_ON = true;
TFT_Timer = millis();
delay(200);
return;
}
TFT_Timer = millis();
if (CURRENT_SCREEN == 0){ // captures touches on drawGPSScreen()
if (lx > 46 && lx < 192 && ly > 317 && ly < 371){
last_button = 1;
tft.fillRect(45,316,148,58, btn_l_border);
}
}else if (CURRENT_SCREEN == 1){ // captures touches on drawClockScreen()
if (lx > 160 && lx < 230 && ly > 336 && ly < 393){
// BTN OK pressed
tft.fillRect(160,336,72,57, btn_l_border);
int changes=0;
for (int y=0; y<12; y++){
if (w_DateTime[y]!=0){
changes=1;
}
}
if (changes == 1){
// Do the magic as the date and time has been updated... Update the RTC accordingly
int hh = (w_DateTime[8]*10) + w_DateTime[9];
int mm = (w_DateTime[10]*10) + w_DateTime[11];
int dd = (w_DateTime[0]*10) + w_DateTime[1];
int mo = (w_DateTime[2]*10) + w_DateTime[3];
int yy = (w_DateTime[4]*1000) + (w_DateTime[5]*100) + (w_DateTime[6]*10) + w_DateTime[7];
rtc.setTime(hh,mm,00);
rtc.setDate(dd,mo,yy);
}
Start_date = String(rtc.getDateStr()).substring(0,2)+" "+rtc.getMonthStr(FORMAT_SHORT)+" "+String(rtc.getDateStr()).substring(6);
old_d = rtc.getDateStr(FORMAT_LONG, FORMAT_LITTLEENDIAN, '/');
START_TIME = rtc.getTimeStr(FORMAT_SHORT);
_Stemp = dht.readTemperature();;
_Shumid = dht.readHumidity();
drawSelectAlignment();
//drawStarSyncScreen();
//drawMainScreen();
}else if (lx > 11 && lx < 83 && ly > 156 && ly < 213){
// BTN 1 pressed
tft.drawRect(10,155,73,58, btn_l_border);
last_button = 1;
removeTime_addXX();
}else if (lx > 86 && lx < 158 && ly > 156 && ly < 213){
// BTN 2 pressed
tft.drawRect(85,155,73,58, btn_l_border);
last_button = 2;
removeTime_addXX();
}else if (lx > 161 && lx < 233 && ly > 156 && ly < 213){
// BTN 3 pressed
tft.drawRect(160,155,73,58, btn_l_border);
last_button = 3;
removeTime_addXX();
}else if (lx > 11 && lx < 83 && ly > 216 && ly < 273){
// BTN 4 pressed
tft.drawRect(10,215,73,58, btn_l_border);
last_button = 4;
removeTime_addXX();
}else if (lx > 86 && lx < 158 && ly > 216 && ly < 273){
// BTN 5 pressed
tft.drawRect(85,215,73,58, btn_l_border);
last_button = 5;
removeTime_addXX();
}else if (lx > 161 && lx < 233 && ly > 216 && ly < 273){
// BTN 6 pressed
tft.drawRect(160,215,73,58, btn_l_border);
last_button = 6;
removeTime_addXX();
}else if (lx > 11 && lx < 83 && ly > 276 && ly < 333){
// BTN 7 pressed
tft.drawRect(10,275,73,58, btn_l_border);
last_button = 7;
removeTime_addXX();
}else if (lx > 86 && lx < 158 && ly > 276 && ly < 333){
// BTN 8 pressed
tft.drawRect(85,275,73,58, btn_l_border);
last_button = 8;
removeTime_addXX();
}else if (lx > 161 && lx < 233 && ly > 276 && ly < 333){
// BTN 9 pressed
tft.drawRect(160,275,73,58, btn_l_border);
last_button = 9;
removeTime_addXX();
}else if (lx > 86 && lx < 158 && ly > 336 && ly < 393){
// BTN 0 pressed
tft.drawRect(85,335,73,58, btn_l_border);
last_button = 10;
removeTime_addXX();
} else if (lx > 11 && lx < 83 && ly > 336 && ly < 393){
// BTN SummerTime pressed
last_button = 22;
}
}else if (CURRENT_SCREEN == 3){
if (lx > 20 && lx < 200 && ly > 100 && ly < 155){
// BTN "1 Star Alignment" pressed
DrawButton(20,100,200,55, "1 Star Alignment", btn_l_border, 0, btn_l_text, 2);
ALLIGN_TYPE = 1;
drawStarSyncScreen();
}else if (lx > 20 && lx < 200 && ly > 170 && ly < 225){
// BTN "Iterative Alignment" pressed
DrawButton(20,170,200,55, "Iterative Align", btn_l_border, 0, btn_l_text, 2);
ALLIGN_TYPE = 3;
// I'll take some time to Initialize the Sub ARRAY with suitable stars (only for Northern Hemi)
tft.setCursor(0, 5);
int cc = 0;
for (int t=0; t < 203; t++){
int i1 = Stars[t].indexOf(';');
int i2 = Stars[t].indexOf(';',i1+1);
int i3 = Stars[t].indexOf(';',i2+1);
OBJECT_NAME = Stars[t].substring(i1+1,i2)+" from "+Stars[t].substring(0,i1);
String OBJ_RA = Stars[t].substring(i2+1,i3);
OBJECT_RA_H = OBJ_RA.substring(0,OBJ_RA.indexOf('h')).toFloat();
OBJECT_RA_M = OBJ_RA.substring(OBJ_RA.indexOf('h')+1,OBJ_RA.length()-1).toFloat();
float ts_RA = OBJECT_RA_H + OBJECT_RA_M/100;
String OBJ_DEC = Stars[t].substring(i3,Stars[t].length());
String sign = OBJ_DEC.substring(0, 1);
OBJECT_DEC_D = OBJ_DEC.substring(1,OBJ_DEC.indexOf('°')).toFloat();
if (sign == "-"){
OBJECT_DEC_D *= (-1);
}
OBJECT_DEC_M = 0;
if (ts_RA > 5.3 && ts_RA < 23.3){
calculateLST_HA();
if (AZ > 90 && AZ < 270 && ALT > 20){
Iter_Stars[cc] = Stars[t];
cc += 1;
if (cc > 49){
break;
}
}
}
int_star_count = floor(cc/15) + 1;
}
drawStarSyncScreen();
}else if (lx > 20 && lx < 200 && ly > 320 && ly < 365){
// BTN "Skip Alignment" pressed
DrawButton(20,320,200,45, "Skip Alignment", btn_l_border, 0, btn_l_text, 2);
IS_IN_OPERATION = true;
drawMainScreen();
}
}else if (CURRENT_SCREEN == 4){ // captures touches on drawMainScreen()
if (lx > 0 && lx < 55 && ly > 0 && ly < 55){
// Load the GPS screen to capture new data && correct time if needed on the next screen (Time Screen)
tft.drawRect(0,0,55,55, btn_l_border);
CURRENT_SCREEN =0;
GPS_iterrations = 0;
IS_IN_OPERATION = false;
ALLIGN_STEP = 0;
ALLIGN_TYPE = 0;
drawGPSScreen();
}
if (lx > 2 && lx < 78 && ly > 282 && ly < 335 && IS_BT_MODE_ON == false){
// BTN 1 pressed
tft.fillRect(1,280,78,55, btn_l_border);
if (MAIN_SCREEN_MENU == 0){
last_button = 1;
}else{
last_button = 7;
}
} else if (lx > 2 && lx < 78 && ly > 341 && ly < 400 && IS_BT_MODE_ON == false){
// BTN 4 pressed
tft.fillRect(1,339,78,55, btn_l_border);
if (MAIN_SCREEN_MENU == 0){
last_button = 4;
}else{
last_button = 10;
}
} else if (lx > 83 && lx < 148 && ly > 280 && ly < 335 && IS_BT_MODE_ON == false){
// BTN 2 pressed
tft.fillRect(81,280,78,55, btn_l_border);
if (MAIN_SCREEN_MENU == 0){
last_button = 2;
}else{
last_button = 8;
}
} else if (lx > 83 && lx < 148 && ly > 341 && ly < 400){
// BTN 5 pressed
tft.fillRect(81,339,78,55, btn_l_border);
if (MAIN_SCREEN_MENU == 0){
last_button = 5;
}else{
last_button = 11;
}
} else if (lx > 163 && lx < 239 && ly > 282 && ly < 335){
// BTN 3 pressed
tft.fillRect(161,280,78,55, btn_l_border);
if (MAIN_SCREEN_MENU == 0){
last_button = 3;
}else{
last_button = 9;
}
} else if (lx > 163 && lx < 239 && ly > 341 && ly < 400){
// BTN 6 pressed
tft.fillRect(161,339,78,55, btn_l_border);
if (MAIN_SCREEN_MENU == 0){
last_button = 6;
}else{
last_button = 12;
}
}
}else if (CURRENT_SCREEN == 5){ // captures touches on drawCoordinatesScreen()
if (lx > 181 && lx < 238 && ly > 5 && ly < 35){
// BTN Cancel pressed
drawMainScreen();
}
}else if (CURRENT_SCREEN == 6){ // captures touches on drawLoadScreen() .. the one that loads objects from DB
if (lx > 181 && lx < 238 && ly > 5 && ly < 35){
// BTN Cancel pressed
drawMainScreen();
}
if (lx > 157 && lx < 238 && ly > 360 && ly < 400){
// BTN next> pressed TREAS_PAGER
if (LOAD_SELECTOR == 1){
MESS_PAGER += 1;
if (MESS_PAGER < 8){
drawLoadScreen();
}else{
MESS_PAGER = 6;
}
}else {
TREAS_PAGER += 1;
if (TREAS_PAGER < 9){
drawLoadScreen();
}else{
TREAS_PAGER = 8;
}
}
}
if (lx > 5 && lx < 85 && ly > 360 && ly < 400){
// BTN <prev pressed
if (LOAD_SELECTOR == 1){
MESS_PAGER -= 1;
if (MESS_PAGER >= 0){
drawLoadScreen();
}else{
MESS_PAGER = 0;
}
}else{
TREAS_PAGER -= 1;
if (TREAS_PAGER >= 0){
drawLoadScreen();
}else{
TREAS_PAGER = 0;
}
}
}
if (lx > 1 && lx < 117 && ly > 40 && ly < 70){
// BTN Messier pressed
LOAD_SELECTOR = 1;
drawLoadScreen();
}
if (lx > 120 && lx < 240 && ly > 40 && ly < 70){
// BTN File pressed
LOAD_SELECTOR = 2;
drawLoadScreen();
}
if (LOAD_SELECTOR == 1){
// I'm in MESSIER selector and need to check which Messier object is pressed
for (int i=0; i<5; i++){
for (int j=0; j<3; j++){
if (lx > ((j*75)+10) && lx < ((j*75)+79) && ly > ((i*50)+86) && ly < ((i*50)+129)){
// found button pressed.... now I need to get his ID and link to the ARRAY;
int zz = (MESS_PAGER*15) + (i*3) + j;
if (Messier_Array[zz] != ""){
selectOBJECT_M(zz,0);
calculateLST_HA();
if (ALT > 0){
OnScreenMsg(1);
if (IS_SOUND_ON){
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(1000);
}
// Stop Interrupt procedure for tracking.
Timer3.stop(); //
IS_TRACKING = false;
IS_OBJ_FOUND = false;
IS_OBJECT_RA_FOUND = false;
IS_OBJECT_DEC_FOUND = false;
Slew_timer = millis();
Slew_RA_timer = Slew_timer + 20000; // Give 20 sec. advance to the DEC. We will revise later.
}
UpdateObservedObjects();
MESS_PAGER == 0;
drawMainScreen();
}
}
}
}
}else if (LOAD_SELECTOR == 2){
// I'm in TREASURES selector and need to check which Treasure object is pressed
for (int i=0; i<5; i++){
for (int j=0; j<3; j++){
if (lx > ((j*75)+10) && lx < ((j*75)+79) && ly > ((i*50)+86) && ly < ((i*50)+129)){
// found button pressed.... now I need to get his ID and link to the ARRAY;
int zz = (TREAS_PAGER*15) + (i*3) + j;
if (Treasure_Array[zz] != ""){
selectOBJECT_M(zz,1);
calculateLST_HA();
if (ALT > 0){
OnScreenMsg(1);
if (IS_SOUND_ON){
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(1000);
}
// Stop Interrupt procedure for tracking.
Timer3.stop(); //
IS_TRACKING = false;
IS_OBJ_FOUND = false;
IS_OBJECT_RA_FOUND = false;
IS_OBJECT_DEC_FOUND = false;
Slew_timer = millis();
Slew_RA_timer = Slew_timer + 20000; // Give 20 sec. advance to the DEC. We will revise later.
}
UpdateObservedObjects();
TREAS_PAGER == 0;
drawMainScreen();
}
}
}
}
}
}else if (CURRENT_SCREEN == 7){ // captures touches on drawOptionsScreen()
if (lx > 181 && lx < 238 && ly > 5 && ly < 35){
// BTN <Back pressed
drawMainScreen();
}
if (lx > 5 && lx < 79 && ly > 65 && ly < 95){
// Celestial Tracking Selected
Tracking_type = 1;
drawOptionsScreen();
}
if (lx > 83 && lx < 156 && ly > 65 && ly < 95){
// Lunar Tracking Selected
Tracking_type = 0;
drawOptionsScreen();
}
if (lx > 161 && lx < 234 && ly > 65 && ly < 95){
// Solar Tracking Selected
Tracking_type = 2;
drawOptionsScreen();
}
if (lx > 200 && lx < 235 && ly > 125 && ly < 155){
// Screen MAX Brightness
analogWrite(TFTBright, 255);
}
if (lx > 5 && lx < 198 && ly > 125 && ly < 155){
// Screen REDUCE Brightness
TFT_Brightness = 190 +((lx - 5)*0.33);
analogWrite(TFTBright, TFT_Brightness);
//Serial.println(BRIGHTNESS);
}
if (lx > 5 && lx < 45 && ly > 185 && ly < 215){
// ECO Mode - Timeout in seconds
TFT_timeout = 0;
drawOptionsScreen();
}
if (lx > 48 && lx < 83 && ly > 185 && ly < 215){
// ECO Mode - Timeout in seconds
TFT_timeout = 30000;
drawOptionsScreen();
}
if (lx > 86 && lx < 121 && ly > 185 && ly < 215){
// ECO Mode - Timeout in seconds
TFT_timeout = 60000;
drawOptionsScreen();
}
if (lx > 124 && lx < 159 && ly > 185 && ly < 215){
// ECO Mode - Timeout in seconds
TFT_timeout = 120000;
drawOptionsScreen();
}
if (lx > 162 && lx < 197 && ly > 185 && ly < 215){
// ECO Mode - Timeout in seconds
TFT_timeout = 300000;
drawOptionsScreen();
}
if (lx > 200 && lx < 235 && ly > 185 && ly < 215){
// ECO Mode - Timeout in seconds
TFT_timeout = 600000;
drawOptionsScreen();
}
if (lx > 5 && lx < 78 && ly > 245 && ly < 275){
// ON Meridian Flip
IS_MERIDIAN_FLIP_AUTOMATIC = true;
drawOptionsScreen();
}
if (lx > 83 && lx < 156 && ly > 245 && ly < 275){
// OFF Meridian Flip
IS_MERIDIAN_FLIP_AUTOMATIC = false;
drawOptionsScreen();
}
if (lx > 5 && lx < 78 && ly > 305 && ly < 335){
// ON Sound
IS_SOUND_ON = true;
drawOptionsScreen();
}
if (lx > 83 && lx < 156 && ly > 305 && ly < 335){
// OFF Sound
IS_SOUND_ON = false;
drawOptionsScreen();
}
if (lx > 5 && lx < 78 && ly > 365 && ly < 395){
// ON Stepper Motors
IS_STEPPERS_ON = true;
digitalWrite(POWER_DRV8825, HIGH);
drawOptionsScreen();
}
if (lx > 83 && lx < 156 && ly > 365 && ly < 395){
// OFF Stepper Motors
IS_STEPPERS_ON = false;
digitalWrite(POWER_DRV8825, LOW);
drawOptionsScreen();
}
}else if (CURRENT_SCREEN == 10){ // captures touches on drawSTATScreen()
if (lx > 181 && lx < 238 && ly > 5 && ly < 35){
// BTN Cancel pressed
IS_IN_OPERATION = true;
drawMainScreen();
}
}else if (CURRENT_SCREEN == 11){ // captures touches on drawStarMap()
if (lx > 181 && lx < 238 && ly > 5 && ly < 35){
// BTN Cancel pressed
IS_IN_OPERATION = true;
drawMainScreen();
}
// Take care of Map move...
// When user touches left, right, top and bottom part of the image,
// the system loads the corresponding Star Map - moving left, right, top and bottom.
if (lx > 0 && lx < 50 && ly > 90 && ly < 350){
// Left side touched... show next StarMap image
if (map_c < 8){
map_c += 1;
IS_CUSTOM_MAP_SELECTED = true;
drawStarMap();
}
}
if (lx > 190 && lx < 240 && ly > 90 && ly < 350){
// Right side touched... show next StarMap image
if (map_c > 1){
map_c -= 1;
IS_CUSTOM_MAP_SELECTED = true;
drawStarMap();
}
}
if (lx > 0 && lx < 240 && ly > 40 && ly < 90){
// Top side touched... show next StarMap image
if (map_r > 1){
map_r -= 1;
IS_CUSTOM_MAP_SELECTED = true;
drawStarMap();
}
}
if (lx > 0 && lx < 240 && ly > 350 && ly < 400){
// Bottom side touched... show next StarMap image
if (map_r < 3){
map_r += 1;
IS_CUSTOM_MAP_SELECTED = true;
drawStarMap();
}
}
}else if (CURRENT_SCREEN == 12){ // captures touches on drawStarSyncScreen() - Alignment Procedure to Check which STAR is selected !
if (lx > 181 && lx < 238 && ly > 5 && ly < 35){
// BTN SKIP pressed
IS_IN_OPERATION = true;
drawMainScreen();
}
int do_kolko = 0;
if (ALLIGN_TYPE == 3){
do_kolko = int_star_count;
}else{
do_kolko = 14;
}
if (lx > 157 && lx < 238 && ly > 360 && ly < 400){
// BTN next> pressed
STARS_PAGER += 1;
if (STARS_PAGER < do_kolko){
drawStarSyncScreen();
}else{
STARS_PAGER = do_kolko - 1;
}
}
if (lx > 5 && lx < 85 && ly > 360 && ly < 400){
// BTN <prev pressed
STARS_PAGER -= 1;
if (STARS_PAGER >= 0){
drawStarSyncScreen();
}else{
STARS_PAGER = 0;
}
}
if (ALLIGN_TYPE < 3){
// I'm in STARS selector and need to check which Star object is pressed
for (int i=0; i<5; i++){
for (int j=0; j<3; j++){
if (lx > ((j*75)+10) && lx < ((j*75)+79) && ly > ((i*50)+86) && ly < ((i*50)+129)){
// found button pressed.... now I need to get his ID and link to the ARRAY;
int zz = (STARS_PAGER*15) + (i*3) + j;
if (Stars[zz] != ""){
selectOBJECT_M(zz,2);
calculateLST_HA();
if (ALT < 0){
OnScreenMsg(3);
if (IS_SOUND_ON){
SoundOn(note_C,96);
delay(2000);
}
drawStarSyncScreen();
}else{
OnScreenMsg(1);
if (IS_SOUND_ON){
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
}
// Stop Interrupt procedure for tracking.
Timer3.stop(); //
IS_TRACKING = false;
IS_OBJ_FOUND = false;
IS_OBJECT_RA_FOUND = false;
IS_OBJECT_DEC_FOUND = false;
Slew_timer = millis();
Slew_RA_timer = Slew_timer + 20000; // Give 20 sec. advance to the DEC. We will revise later.
STARS_PAGER == 0;
SELECTED_STAR = zz;
ALLIGN_STEP += 1;
//drawConstelationScreen(zz);
}
}
}
}
}
}else{
// I'm in STARS selector and need to check which Star object is pressed
for (int i=0; i<5; i++){
for (int j=0; j<3; j++){
if (lx > ((j*75)+10) && lx < ((j*75)+79) && ly > ((i*50)+86) && ly < ((i*50)+129)){
// found button pressed.... now I need to get his ID and link to the ARRAY;
int zz = (STARS_PAGER*15) + (i*3) + j;
if (Iter_Stars[zz] != ""){
// selectOBJECT_M(zz,3);
Iterative_Star_Index = zz;
// replaced the above with the below row...
// to make sure each press selects the same star (inital or on Step 2)
// change made after Test on 17th March.
selectOBJECT_M(Iterative_Star_Index,3);
calculateLST_HA();
OnScreenMsg(1);
if (IS_SOUND_ON){
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
}
// Stop Interrupt procedure for tracking.
Timer3.stop(); //
IS_TRACKING = false;
IS_OBJ_FOUND = false;
IS_OBJECT_RA_FOUND = false;
IS_OBJECT_DEC_FOUND = false;
Slew_timer = millis();
Slew_RA_timer = Slew_timer + 20000; // Give 20 sec. advance to the DEC. We will revise later.
STARS_PAGER == 0;
SELECTED_STAR = zz;
ALLIGN_STEP += 1;
// drawConstelationScreen(zz);
}
}
}
}
}
}else if (CURRENT_SCREEN==13){ // captures touches on drawConstelationScreen(int indx) -- DO THE ALIGNMENT ACTIVITIES (SYNC and NEXT STEP in Alignment)
if (lx > 5 && lx < 105 && ly > 360 && ly < 400){
// BTN "<Repeat" or "<EXIT" pressed
if (ALLIGN_TYPE == 3){
// delta_a_RA = 0;
// delta_a_DEC = 0;
STARS_PAGER = 0;
IS_TRACKING = false;
IS_IN_OPERATION = true;
drawMainScreen();
}else{
ALLIGN_STEP -= 1;
drawStarSyncScreen();
}
}
if (lx > 128 && lx < 240 && ly > 360 && ly < 400){
// BTN "ALIGN!" or "SYNC" pressed
// Here we need to know which Star is this - 1st, 2nd, 3rd... etc ?
// In order to use Ralph Pass alignment procedure described on http://rppass.com/
// http://rppass.com/align.pdf - the actual PDF
if (ALLIGN_STEP == 1){
if (ALLIGN_TYPE == 1){
IS_TRACKING = false;
IS_IN_OPERATION = true;
drawMainScreen();
}else if (ALLIGN_TYPE == 3){
// Select Polaris and SlewTo...
IS_TRACKING = false;
//
//
// NOW I have to SYNC on that STAR!
// Assign Values calculated for
// SLEW_RA_microsteps and SLEW_DEC_microsteps
//
selectOBJECT_M(192,2); // Polaris in on Index 192 in the Stars Array
calculateLST_HA();
OnScreenMsg(1);
if (IS_SOUND_ON){
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
}
// Stop Interrupt procedure for tracking.
Timer3.stop(); //
IS_TRACKING = false;
IS_OBJ_FOUND = false;
IS_OBJECT_RA_FOUND = false;
IS_OBJECT_DEC_FOUND = false;
Slew_timer = millis();
Slew_RA_timer = Slew_timer + 20000; // Give 20 sec. advance to the DEC. We will revise later.
//drawConstelationScreen(0);
ALLIGN_STEP = 2;
}
}else if (ALLIGN_STEP == 2){
if(ALLIGN_TYPE == 3){
// Select First Star Again and SlewTo...
IS_TRACKING = false;
selectOBJECT_M(Iterative_Star_Index,3); // Load First Star from the Stars Array
calculateLST_HA();
OnScreenMsg(1);
if (IS_SOUND_ON){
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
SoundOn(note_C,32);
delay(200);
}
// Stop Interrupt procedure for tracking.
Timer3.stop(); //
IS_TRACKING = false;
IS_OBJ_FOUND = false;
IS_OBJECT_RA_FOUND = false;
IS_OBJECT_DEC_FOUND = false;
Slew_timer = millis();
Slew_RA_timer = Slew_timer + 20000; // Give 20 sec. advance to the DEC. We will revise later.
//drawConstelationScreen(0);
ALLIGN_STEP = 1;
}
}
}
}
}else{
//**************************************************************
//
// BUTTON UP Events start here
//
// - only executed when the user touches the screen - RELEASE
//**************************************************************
if (CURRENT_SCREEN == 0){
if (last_button == 1){
last_button = 0;
// Set the earth rotation direction depending on the Hemisphere...
// HIGH and LOW are substituted
if (OBSERVATION_LATTITUDE > 0){
STP_FWD = LOW;
STP_BACK = HIGH;
}else{
STP_FWD = HIGH;
STP_BACK = LOW;
}
Serial.println(OBSERVATION_LATTITUDE);
Serial.print("STP_FWD = ");
Serial.println(STP_FWD);
Serial.print("STP_BACK = ");
Serial.println(STP_BACK);
CURRENT_SCREEN = 1;
drawClockScreen();
}
}else if (CURRENT_SCREEN == 1){
if (last_button == 1){
last_button = 0;
tft.drawRect(10,155,73,58, BLACK);
TimerUpdateDraw(1);
}
if (last_button == 2){
last_button = 0;
tft.drawRect(85,155,73,58, BLACK);
TimerUpdateDraw(2);
}
if (last_button == 3){
last_button = 0;
tft.drawRect(160,155,73,58, BLACK);
TimerUpdateDraw(3);
}
if (last_button == 4){
last_button = 0;
tft.drawRect(10,215,73,58, BLACK);
TimerUpdateDraw(4);
}
if (last_button == 5){
last_button = 0;
tft.drawRect(85,215,73,58, BLACK);
TimerUpdateDraw(5);
}
if (last_button == 6){
last_button = 0;
tft.drawRect(160,215,73,58, BLACK);
TimerUpdateDraw(6);
}
if (last_button == 7){
last_button = 0;
tft.drawRect(10,275,73,58, BLACK);
TimerUpdateDraw(7);
}
if (last_button == 8){
last_button = 0;
tft.drawRect(85,275,73,58, BLACK);
TimerUpdateDraw(8);
}
if (last_button == 9){
last_button = 0;
tft.drawRect(160,275,73,58, BLACK);
TimerUpdateDraw(9);
}
if (last_button == 10){
last_button = 0;
tft.drawRect(85,335,73,58, BLACK);
TimerUpdateDraw(0);
}
if (last_button == 22){
if (Summer_Time == 1){
Summer_Time = 0;
tft.fillRect(11, 336, 71, 56,BLACK);
DrawButton(11,336,71,56, "SUMMER", 0, btn_l_border, btn_l_text, 1);
}else{
Summer_Time = 1;
DrawButton(11,336,71,56, "SUMMER", btn_d_border, btn_l_border, btn_l_text, 1);
}
tft.setTextColor(btn_l_text);
tft.setTextSize(3);
last_button = 0;
}
}else if (CURRENT_SCREEN == 4){
tft.setTextColor(btn_l_text);
if (last_button == 1 && IS_BT_MODE_ON == false){
last_button = 0;
DrawButton( 1, 280, 78, 55, "LOAD", btn_l_text, 0, btn_d_text, 2);
drawLoadScreen();
}
if (last_button == 4 && IS_BT_MODE_ON == false){
last_button = 0;
drawSTATScreen();
}
if (last_button == 2 && IS_BT_MODE_ON == false){
last_button = 0;
IS_TRACKING = false;
Timer3.stop();
DrawButton( 81, 280, 78, 55, "HOME", btn_l_text, 0, btn_d_text, 2);
OBJECT_NAME = "CP";
OBJECT_DESCR = "Celestial pole";
OBJECT_RA_H = 12;
OBJECT_RA_M = 0;
OBJECT_DEC_D = 90;
OBJECT_DEC_M = 0;
IS_OBJ_FOUND = false;
IS_OBJECT_RA_FOUND = false;
IS_OBJECT_DEC_FOUND = false;
Slew_timer = millis();
Slew_RA_timer = Slew_timer + 20000; // Give 20 sec. advance to the DEC. We will revise later.
OBJECT_DETAILS="The north and south celestial poles are the two imaginary points in the sky where the Earth's axis of rotation, intersects the celestial sphere";
}
if ((last_button == 5)||(last_button == 11)){
last_button = 0;
if (MAIN_SCREEN_MENU == 0){
MAIN_SCREEN_MENU = 1;
}else{
MAIN_SCREEN_MENU = 0;
}
drawMainScreen_Menu(1);
}
if (last_button == 3){
last_button = 0;
if (IS_TRACKING == false){
IS_TRACKING = true;
DrawButton( 161, 280, 78, 55, "TRACK", btn_d_border, btn_l_border, btn_l_text, 2);
setmStepsMode("R",MICROSteps);
if (Tracking_type == 1){ // 1: Sidereal, 2: Solar, 0: Lunar;
Timer3.start(Clock_Sidereal);
}else if (Tracking_type == 2){
Timer3.start(Clock_Solar);
}else if (Tracking_type == 0){
Timer3.start(Clock_Lunar);
}
}else{
IS_TRACKING = false;
tft.fillRect(161, 280, 78, 55,BLACK);
DrawButton( 161, 280, 78, 55, "TRACK", 0, btn_l_border, btn_l_text, 2);
setmStepsMode("R",1);
Timer3.stop(); //
}
}
if (last_button == 6){ // BlueTooth Mode
if (IS_BT_MODE_ON == true){
IS_BT_MODE_ON = false;
}else{
IS_BT_MODE_ON = true;
// Initialize Bluetooth communication on PINs: 15 (RX) and 14 (TX)
}
last_button = 0;
drawMainScreen();
}
if (last_button == 7 && IS_BT_MODE_ON == false){
last_button = 0;
//DrawButton( 1, 280, 78, 55, "LOAD", btn_l_text, 0, btn_d_text, 2);
if ((IS_TRACKING == true) && (IS_SOUND_ON)){
SoundOn(note_C,32);
}
drawCoordinatesScreen();
}
if (last_button == 8 && IS_BT_MODE_ON == false){
last_button = 0;
//DrawButton( 81, 280, 78, 55, "MAP", btn_l_text, 0, btn_d_text, 2);
drawStarMap();
}
if (last_button == 9){
last_button = 0;
if (IS_DEV1_ON){
IS_DEV1_ON = false;
tft.fillRect(161, 280, 78, 55,BLACK);
DrawButton( 161, 280, 78, 55, "DEV 1", 0, btn_l_border, btn_l_text, 2);
digitalWrite(DEV1,LOW);
}else{
IS_DEV1_ON = true;
tft.fillRect(161, 280, 78, 55,BLACK);
DrawButton( 161, 280, 78, 55, "DEV 1", btn_d_border, btn_l_border, btn_l_text, 2);
digitalWrite(DEV1,HIGH);
}
}
if (last_button == 10){
last_button = 0;
drawOptionsScreen();
}
if (last_button == 12){
last_button = 0;
if (IS_DEV2_ON){
IS_DEV2_ON = false;
tft.fillRect(161, 339, 78, 55,BLACK);
DrawButton( 161, 339, 78, 55, "DEV 2", 0, btn_l_border, btn_l_text, 2);
digitalWrite(DEV2,LOW);
}else{
IS_DEV2_ON = true;
tft.fillRect(161, 339, 78, 55,BLACK);
DrawButton( 161, 339, 78, 55, "DEV 2", btn_d_border, btn_l_border, btn_l_text, 2);
digitalWrite(DEV2,HIGH);
}
}
}
}
}