forked from scottpav/OpenDSKY
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCustomDSKY.ino
More file actions
2992 lines (2020 loc) · 81.9 KB
/
CustomDSKY.ino
File metadata and controls
2992 lines (2020 loc) · 81.9 KB
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
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// CustomDSKY - Customized implementation of the OpenDSKY interface written exclusively
// for the Apollo Education Experience Project
//
// https://www.apolloexperience.com
//
// Copyright (c) 2019-2021 by Bill Walker - bwalker@apolloexperience.com
//
// Based in part on original code by S&T Geotronics, Ron Diamond, Scott Pavlovec, and others
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// This program is free software: you can redistribute it and/or modify it under the terms of
// the GNU General Public License, version 3, as published by the Free Software Foundation
//
// 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 <https://www.gnu.org/licenses/gpl-3.0.txt>.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// PLEASE NOTE: The following lines MUST be uncommented in the NeoGPS configuration files:
// - #define GPS_FIX_LOCATION_DMS in file GPSfix_cfg.h
// - #define NMEAGPS_PARSING_SCRATCHPAD in file NMEAGPS_cfg.h
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Includes
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Required libraries
// - Adafruit NeoPixel
// - Adafruit RTClib
// - LEDcontrol (by wayoda / Eberhard Fahle)
// - NeoGPS (by SlashDevin)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include "RTClib.h"
#include "LedControl.h"
#include <NMEAGPS.h>
#include <Streamers.h>
#include <GPSport.h>
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Defines
/////////////////////////////////////////////////////////////////////////////////////////////////////////
#define PIXEL_PIN 6
#define RELAY_PIN 7
#define NUMPIXELS 18
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Externals
/////////////////////////////////////////////////////////////////////////////////////////////////////////
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
LedControl lc=LedControl(12,10,11,4);
RTC_DS1307 rtc;
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Variables and Constants
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////
// GPS-related items
//////////////////////////////////////////
bool gpsFix = 0;
int lat = 0;
int latDegrees = 0;
int latMinutes = 0;
int latSeconds = 0;
int lon = 0;
int lonDegrees = 0;
int lonMinutes = 0;
int lonSeconds = 0;
int alt = 0;
int spd = 0;
int hdg = 0;
float range = 0;
int rangeFeet = 0;
int bearing = 0;
int32_t wpLatitude = 0;
int32_t wpLongitude = 0;
uint8_t GPSyear = 0;
uint8_t GPSmonth = 0;
uint8_t GPSdate = 0;
uint8_t GPShour = 0;
uint8_t GPSmin = 0;
uint8_t GPSsec = 0;
static NMEAGPS gps;
static gps_fix fix;
//////////////////////////////////////////
// IMU-repated items
//////////////////////////////////////////
const int MPU_addr = 0x69; // I2C address of the MPU-6050
const int tCal = -1600; // temperature calibration constant
long imuGyroX = 0;
long imuGyroY = 0;
long imuGyroZ = 0;
long imuAccelX = 0;
long imuAccelY = 0;
long imuAccelZ = 0;
long imuTemp = 0;
long temp_C;
long temp_F;
//////////////////////////////////////////
// DSKY display-related and keyboard-related items
//////////////////////////////////////////
long Register[4];
byte digitVal[4][7];
byte keyVal = 20;
byte oldKey = 20;
bool fresh = 0;
bool navActive = 0;
bool error = 0;
byte action = 0;
byte verb = 0;
byte verbNew[2];
byte verbOld[2];
byte noun = 0;
byte nounNew[2];
byte nounOld[2];
byte prog = 0;
byte progNew[2];
byte progOld[2];
byte count = 0;
byte mode = 0;
byte oldMode = 0;
bool toggle = 0;
byte togCount = 0;
bool newAct = 0;
bool VNtoggle = 0;
byte VNflash = 0;
uint32_t VNmillis = 0;
uint32_t compActMillis = 0;
uint32_t cmdHeadMillis = 0;
bool GPStoggle = 0;
uint32_t GPSmillis = 0;
bool setupFlag = 0;
byte refreshInt = 15;
byte refreshCount = 0;
//////////////////////////////////////////
// Time and timer-related items
//////////////////////////////////////////
unsigned long previousMillis = 0;
int oldSecond = 0;
DateTime now;
DateTime simNow;
TimeSpan elapsedCurr(0);
int elapsedSec = 0;
int elapsedMin = 0;
int elapsedHr = 0;
TimeSpan AGCcurrent(0);
long AGCstart = 0;
TimeSpan METcurrent(0);
long METstart = 0;
bool METrunning = 0;
TimeSpan N34current(0);
long N34start = 0;
int N34currhr = 0;
int N34currmin = 0;
int N34currsec = 0;
bool N34running = 0;
TimeSpan N35current(0);
long N35end = 0;
int N35currhr = 0;
int N35currmin = 0;
int N35currsec = 0;
bool N35running = 0;
//////////////////////////////////////////
// Data for lunar landing simulation
//////////////////////////////////////////
const int timePoint[] = { 0, 9, 26, 61, 66, 70, 75, 86, 91, 95,105,116,126,136,143,150,159,164,173,195,218,220,999};
const int alt_Point[] = {3500,3000,2000,800,700,600,540,400,350,330,300,270,250,220,200,160,120,100, 75, 40, 8, 0, 0};
const int vel_Point[] = { 750, 700, 500,230,210,190,150, 90, 40, 35, 35, 15, 25, 35, 45, 65, 45, 35, 25, 25, 15, 0, 0};
const byte maxPtr = 22;
const int totalSeconds = 252;
//////////////////////////////////////////
// Data for Saturn V launch simulation
//////////////////////////////////////////
const int ltimePoint[] = {0,35,40,45, 55, 64, 94, 100, 117, 124, 154, 169, 184, 195, 196, 214, 244, 274, 304, 334, 364, 394, 424, 454, 484, 494, 514, 544, 574, 586, 587, 604, 634, 664, 694, 724, 737, 743, 999};
const int lvel_Point[] = {0, 0,11,33,137,496,1192,1340,2671,3123,5226,6492,8073,9068,9100,9222,9763,10424,11191,12063,13041,14133,15351,16713,18244,18725,19709,21016,22439,22690,22699,23178,23703,24252,24824,25420,25562,25567,25567};
const int lvvelpoint[] = {0, 0,11,33,137,414, 857, 972,1323,1542,2321,2794,3095,3307,3307,2904,2437, 1958, 1517, 1115, 937, 716, 533, 394, 308, 288, 267, 284, 266, 279, 279, 224, 129, 56, 9, -11, 0, 0, 0};
const int lalt_Point[] = {0, 0, 0, 1, 2, 7, 35, 43, 72, 94, 189, 238, 324, 357, 360, 478, 610, 718, 804, 869, 915, 933, 948, 951, 969, 973, 985, 999, 1007, 1014, 1019, 1025, 1031, 1036, 1037, 1037, 1036, 1036, 1036};
const byte lmaxPtr = 38;
const int ltotalSeconds = 780;
const int earthOrbitPer = 5286;
uint32_t launchTime = 0;
uint32_t perigeeTime = 0;
bool v37n01Running = 0;
bool v37n01Done = 0;
TimeSpan perigeeCurrent(0);
//////////////////////////////////////////
// Data for P06 power-on simulation
//////////////////////////////////////////
const int act22LampSeq[] = {17, 4, 16, 6, 15, 8, 13};
bool prog06Ack = 0;
//////////////////////////////////////////
// Misc scratchpad items for simulations
//////////////////////////////////////////
long timeDiff = 0;
long timeCalc = 0;
int altDiff = 0;
int currAlt = 0;
long velDiff = 0;
long currVel = 0;
int vvelDiff = 0;
int currVvel = 0;
int elapsedSeconds = 0;
//////////////////////////////////////////
// Audio-related items
//////////////////////////////////////////
byte audioTrack = 1;
byte audioIndexAdj = 0;
byte newTrack = 0;
byte myTrack = 0;
const byte numTracks = 17;
const byte aud_silence = 1;
const byte aud_alarm = 2;
const byte aud_jfkbelieve = 3;
const byte aud_jfkchoose = 4;
const byte aud_a8genesis = 5;
const byte aud_a11eagle = 6;
const byte aud_a13problem = 7;
const byte aud_a11landing = 8;
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// setup - Initializes the DSKY
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
if (setupFlag == 0) { // Have we done this yet?
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH);
randomSeed(analogRead(A7));
pixels.begin();
for(int index = 0; index < 4; index++){
lc.shutdown(index,false);
lc.setIntensity(index,15);
lc.clearDisplay(index);
}
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
updateIMU();
rtc.begin();
now = rtc.now();
AGCstart = now.secondstime();
startUp();
cmdHeaders(300, false);
lampit(0,0,0, 3);
lampit(100,100,100, 16);
#ifndef NMEAGPS_RECOGNIZE_ALL
#error You must define NMEAGPS_RECOGNIZE_ALL in NMEAGPS_cfg.h!
#endif
#ifdef NMEAGPS_INTERRUPT_PROCESSING
#error You must *NOT* define NMEAGPS_INTERRUPT_PROCESSING in NMEAGPS_cfg.h!
#endif
#if !defined( NMEAGPS_PARSE_GGA ) & !defined( NMEAGPS_PARSE_GLL ) & \
!defined( NMEAGPS_PARSE_GSA ) & !defined( NMEAGPS_PARSE_GSV ) & \
!defined( NMEAGPS_PARSE_RMC ) & !defined( NMEAGPS_PARSE_VTG ) & \
!defined( NMEAGPS_PARSE_ZDA ) & !defined( NMEAGPS_PARSE_GST )
#else
if (gps.merging == NMEAGPS::NO_MERGING) {
}
#endif
gpsPort.begin(9600);
setupFlag = 1;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// loop - polls GPSloop() and continuously checks for newly-selected activities
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
// checks for various stand-alone PROG codes
// operational codes
// audio playback codes - all reset PROG to 11 after audio starts
if (prog == 61){ audioPlayback( aud_jfkbelieve); prog=11; } // Plays JFK's "I believe" clip from message to congress
if (prog == 62){ audioPlayback( aud_jfkchoose); prog=11; } // Plays JFK's "We choose" clip from Rice U speech
if (prog == 68){ audioPlayback( aud_a8genesis); prog=11; } // Plays "Genesis" recitation from Apollo 8
if (prog == 69){ audioPlayback( aud_a11eagle); prog=11; } // Plays "Eagle has landed" clip from Apollo 11
if (prog == 70){ audioPlayback( aud_a13problem); prog=11; } // Plays "We have a problem" clip from Apollo 13
// checks for various modes - mostly internal functions but some can be selected
if (mode == 0) { mode0(); } // read a key
if (mode == 1) { mode1(); } // read a verb
if (mode == 2) { mode2(); } // read a noun
if (mode == 3) { mode3(); } // read a program
if (mode == 4) { mode4(); } // V35 Lamp Test
if (mode == 5) { mode5(); } // V36 Fresh Start or V69 Force Restart
// toggles the toggle flag after 4 times thru the loop
// used to determine duration of flashing lamps
if (togCount == 4) {
togCount = 0;
toggle = !toggle;
}
togCount++;
if (action == 3){
togCount = 4;
}
// checks for various action and calls the appropriate functions
if(action == 1) { action1(); } // V16N17 ReadIMU Gyro
if(action == 2) { action2(); compTime();} // V16N36 Read Time from RTC
if(action == 3) { action3(); } // V16N43 GPS POS & ALT
if(action == 4) { action4(); } // V16N87 READ IMU WITH RANDOM 1202 ALARM
if(action == 5) { action5(); } // V25N36 Set The Time from Keypad
if(action == 6) { action6(); } // V25N37 Set The Date from Keypad
if(action == 8) { action8(); } // V16N18 ReadIMU Accel
if(action == 9) { action9(); } // V16N19 Read Temp Date & Time
if(action == 10) { action10(); } // V16N68 Apollo 11 Decent & Landing
if(action == 11) { action11(); } // V26N36 Set Time on RTC from GPS
if(action == 12) { action12(); } // V26N37 Set Date on RTC from GPS
if(action == 13) { action13(); } // V16N37 Read Date from RTC
if(action == 14) { action14(); } // V16N38 Read Time from GPS
if(action == 15) { action15(); } // V16N39 Read Date from GPS
if(action == 16) { action16(); } // V37N00 Enter P00 Idle Mode
if(action == 17) { action17(); } // V16N31 Read AGC Power-on Time, or
// V16N34 Monitor/Stop Timer from event, or
// V16N65 Read Mission Elapsed Time (MET)
if(action == 18) { action18(); } // V16N35 Monitor/Stop Timer to event
if(action == 19) { action19(); } // V25N34 or V25N35 set/Start Timer to/from event
if(action == 20) { action20(); } // V16N98 Play audio track, or
// V21N98 select track, or
// V22N98 adjust audio index
if(action == 21) { action21(); } // V37N01 Apollo 11 Launch
if(action == 22) { action22(); } // V37N06 AGC Standby - "Apollo 13" simulation
// special actions that can be called normally or from within simulations
if(action == 101) { action101();} // V16N44 or V82 Monitor Orbital Parameters
if(action == 102) { action102();} // V06N32 Display Time from Perigee, or
// V16N32 Monitor Time from Perigee
GPSloop();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Mode Routines
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// mode0 - reads keyboard during time of no activity
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void mode0() {
if (newAct == 1) {
validateAct();
} else {
if(error == 1){
flasher();
}
keyVal = readkb();
processkey0();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// mode1 - Inputs and processes a VERB
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void mode1() {
input_cmd( 2 );
processkey1();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// mode2 - Inputs and processes a NOUN
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void mode2() {
input_cmd( 0 );
processkey2();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// mode3 - Inputs and processes a PROG
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void mode3() {
if (action > 100) {
action = 0;
mode = 0;
} else {
input_cmd( 1 );
processkey3();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// input_cmd - inputs key for a command, flashes the command header, and checks for errors
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void input_cmd(int cmdPosn) {
if ( cmdHeadMillis > millis() ) cmdHeadMillis = millis();
flashkr();
if( error == 1 ){
flasher();
}
lampit(0,0,0, cmdPosn);
if ( millis() - cmdHeadMillis > 500 ) {
cmdHeadMillis = millis(); // reset the timer
lampit(0,150,0, cmdPosn);
}
keyVal = readkb();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// mode4 - Performs V35 Lamp Test
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void mode4() {
cmdHeaders(200,true);
lampit(0,150,0, 3);
for (int index = 4; index < 18; index++) {
if(index < 11){
lampit(100,100,0, index);
}
if(index <= 12){
lampit(100,100,100, 23-index);
}
delay(50);
}
for (int index = 0; index < 4; index++) {
for (int indexb = 0; indexb < 6; indexb++){
setDigits(index,indexb,8);
delay(25);
}
}
delay(1000);
for (int count = 0; count < 4; count++) {
VNtoggle = 1; flashVerbNoun();
toggle = 1; flashkr();
toggle = 1; flasher();
delay(500);
VNtoggle = 0; flashVerbNoun();
toggle = 0; flashkr();
toggle = 0; flasher();
delay(500);
}
erase_display();
delay(500);
restore_display();
for (int index = 3; index < 18; index++) {
if(index != 16){
lampit(0,0,0, index);
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// mode5 - Performs V36 Fresh Start or V69 Force Restart
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void mode5() {
lampit(0,0,0, 16);
for(int index = 0; index < 4; index++){
lampit(0,0,0,index);
lc.shutdown(index,false);
lc.clearDisplay(index);
}
if (verb == 69) {
now = rtc.now();
AGCstart = now.secondstime();
N34currhr = 0;
N34currmin = 0;
N34currsec = 0;
N34start = 0;
N34running = 0;
N35currhr = 0;
N35currmin = 0;
N35currsec = 0;
N35end = 0;
N35running = 0;
}
verb = 0;
verbNew[0]=0;
verbNew[1]=0;
verbOld[0]=0;
verbOld[1]=0;
noun = 0;
nounNew[0]=0;
nounNew[1]=0;
nounOld[0]=0;
nounOld[1]=0;
prog = 0;
progNew[0]=0;
progNew[1]=0;
progOld[0]=0;
progOld[1]=0;
startUp();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// modeSub0 - reads keyboard during execution of another function
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void modeSub0() {
if (newAct == 1) {
validateSubAct();
} else {
if(error == 1){
flasher();
}
keyVal = readkb();
processkey0();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// validateSubAct - validates activities available only during execution of another function
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void validateSubAct() {
if(verb == 82) { action = 101;newAct = 0; } // Monitor Orbital Params
else if((verb == 6) && (noun == 32)) { action = 102;newAct = 0; } // Monitor Time from Perigee
else { newAct = 0;action = 0; }
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Action Routines
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action1 - Reads and displays gyro data from IMU
// - V06N17 - runs only once then resets
// - V16N17 - runs continuously until a different command is entered
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action1() {
refreshCount = refreshInt+1;
readimuGyro();
if(verb == 6) { // prevent repeat action if V06 display single point of data
action = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action2 - Reads and displays time data from RTC
// - V06N36 - runs only once then resets
// - V16N36 - runs continuously until a different command is entered
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action2() {
DateTime now = rtc.now();
compTime();
if(oldSecond < now.second()) {
oldSecond = now.second();
previousMillis = millis();
}
setShowRegisters( now.hour(), now.minute(), (now.second()*100) + ((millis()-previousMillis)/10)%100 ); // allow space for tenths and hundredths
if(verb == 6) { // prevent repeat action if V06 display single point of data
action = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action3 - Display latitude and longitude from GPS
// - V16N43
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action3() {
if (gpsFix == 1) {
compAct();
lampit(0,0,0, 16);
lampit(0,0,0, 8);
} else {
lampit(100,100,100, 16);
}
if (GPStoggle) {
setShowRegisters(latDegrees,latMinutes,latSeconds);
setDigits(0, 3, 5);
} else {
setShowRegisters(lonDegrees,lonMinutes,lonSeconds);
setDigits(0, 3, 6);
}
setDigits(0, 2, 2);
if (VNflash <5) { flashVerbNoun(); }
if ((millis() - VNmillis) > 250) {
VNmillis = millis();
VNtoggle = !VNtoggle;
VNflash++;
}
if ((millis() - GPSmillis) > 5000) {
GPSmillis = millis();
GPStoggle = !GPStoggle;
VNflash = 0;
VNtoggle = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action4 - Monitors IMU translational speed with random 1202 errors
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action4() {
imu_1202();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action5 - Sets time for RTC using manual keypad entry, then runs V16N36
// - V25N36
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action5() {
DateTime now = rtc.now();
int NYR = now.year();
int NMO = now.month();
int NDY = now.day();
int NHR = now.hour();
int NMI = now.minute();
int NSE = now.second();
NHR = editregister( NHR, NMI, NSE, 1, 0, 23 );
NMI = editregister( NHR, NMI, NSE, 2, 0, 59 );
NSE = editregister( NHR, NMI, NSE, 3, 0, 59 );
rtc.adjust(DateTime(NYR,NMO,NDY,NHR,NMI,NSE));
action = 2;
setVerb( 16, 1, 6);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action6 - Sets date for RTC using manual keypad entry, then runs V16N19
// - V25N37
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action6() {
DateTime now = rtc.now();
int NYR = now.year();
int NMO = now.month();
int NDY = now.day();
int NHR = now.hour();
int NMI = now.minute();
int NSE = now.second();
NMO = editregister( NMO, NDY, NYR, 1, 1, 12 );
NDY = editregister( NMO, NDY, NYR, 2, 1, 31 );
NYR = editregister( NMO, NDY, NYR, 3, 1900, 2199 );
rtc.adjust(DateTime(NYR,NMO,NDY,NHR,NMI,NSE));
action = 9;
setVerb( 16, 1, 6);
setNoun( 19, 1, 9);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action8 - Reads and displays acceleration data from IMU
// - V06N18 - runs only once then resets
// - V16N18 - runs continuously until a different command is entered
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action8() {
refreshCount = refreshInt+1;
readimuAccel();
if(verb == 6) { // prevent repeat action if V06 display single point of data
action = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action9 - Reads and displays date and time from RTC, and temperature from IMU
// - V16N19
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action9() {
tempDateTime();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action10 - Runs simulation of Apollo 11 Descent and Landing coordinated with ground loop audio
// - V16N68
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action10() {
audioPlayback(aud_a11landing);
lunarDecentSim();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action11 - Reads time from GPS and uses it to set time on RTC, then runs V16n36
// - V26N36
// - NOTE: Time will be UTC
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action11() {
DateTime now = rtc.now();
int NYR = now.year();
int NMO = now.month();
int NDY = now.day();
GPSloop();
int NHR = GPShour;
int NMI = GPSmin;
int NSE = GPSsec;
rtc.adjust(DateTime(NYR,NMO,NDY,NHR,NMI,NSE));
action = 2;
setVerb( 16, 1, 6);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action12 - Reads date from GPS and uses it to set date on RTC, then runs V16n19
// - V26N37
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action12(){
DateTime now = rtc.now();
int NHR = now.hour();
int NMI = now.minute();
int NSE = now.second();
GPSloop();
int NYR = GPSyear;
int NMO = GPSmonth;
int NDY = GPSdate;
rtc.adjust(DateTime(NYR,NMO,NDY,NHR,NMI,NSE));
action = 9;
setVerb( 16, 1, 6);
setNoun( 19, 1, 9);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action13 - Reads and displays date data from RTC
// - V06N37 - runs only once then resets
// - V16N37 - runs continuously until a different command is entered
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action13() {
DateTime now = rtc.now();
Register[1] = (now.year());
Register[2] = (now.month());
Register[3] = (now.day());
set_Digits();
if(verb == 6) { // prevent repeat action if V06 display single point of data
action = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action14 - Reads and displays time data from GPS
// - V06N38 - runs only once then resets
// - V16N38 - runs continuously until a different command is entered
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action14() {
compTime();
if(oldSecond < GPSsec) {
oldSecond = GPSsec;
previousMillis - millis();
}
setShowRegisters(GPShour,GPSmin,GPSsec * 100 + ((millis()-previousMillis)/10)%100);
if(verb == 6) { // prevent repeat action if V06 display single point of data
action = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action15 - Reads and displays date data from GPS
// - V06N39 - runs only once then resets
// - V16N39 - runs continuously until a different command is entered
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action15() {
setShowRegisters(GPSyear,GPSmonth,GPSdate);
if(verb == 6) { // prevent repeat action if V06 display single point of data
action = 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action16 - Stop all commands and enter idle mode
// - V37N00 - sets PROG 00 or P00, also known as "Winnie the P00"
// - Note: timers V16N34 and V16N35 continue running
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action16() {
erase_display();
mode = 0;
action = 0;
prog = 0;
setDigits(0, 2, 0);
setDigits(0, 3, 0);
setVerb(verb,(verb/10),(verb%10));
setNoun(0,0,0);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// action17 - Displays Count-Up Timers
// - V06N31 / V16N31 - Time since DSKY power-up (or V69)
// - V16N34 - Time from event
// - V06N65 / V16N65 - MET - Mission Elapsed Time (started by V37N01)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void action17() {