-
Notifications
You must be signed in to change notification settings - Fork 0
/
mode2.cpp
74 lines (71 loc) · 1.92 KB
/
mode2.cpp
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
#include "uni_keypad.h"
#include "uni_gps.h"
#include "uni_display.h"
#include "uni_sd.h"
#include "modes.h"
extern UniKeypad keypad;
extern UniGps gps;
extern UniDisplay display;
extern UniSd sd;
//### Mode 2 - GPS/SD Test
//
//- If you press A, it will show the GPS time, and beep positively.
// - If you press B, it will display the # chars received from GPS
// - If you press A, it will show the GPS time (if GPS signal found), otherwise it will wait for lock, and beep positively.
//- If you press C, it will test writing/reading from the SD card, and display either 6ood or bAd
unsigned long gps_millis = 0;
char last_key2 = NO_KEY;
int subMode = 0;
void mode2_loop() {
if (gps_millis == 0 || (millis() - gps_millis > 1000)) {
// Run inner loop periodically
if (subMode == 1) {
// A - show GPS date, if locked
if (gps.lock()) {
TimeResult time;
gps.current_time(&time, millis());
display.showNumber((time.minute * 100) + time.second, DEC);
} else {
// no lock
display.waiting(false);
gps.printPeriodically();
}
} else if (subMode == 2) {
// B
// B - show # chars from GPS
long chars = gps.charactersReceived();
display.showNumber(chars % 10000, DEC);
char stuff[100];
sprintf(stuff, "Outputting %ld", chars);
Serial.println(stuff);
} else if (subMode == 3) {
// C - show SD Good/bad (TBD)
}
gps_millis = millis();
}
char key = keypad.readChar();
if (key != NO_KEY) {
if (key != last_key2) {
// New Keypress
int keynum = keypad.intFromChar(key);
if (keynum == 17) {
// A
subMode = 1;
}
if (keynum == 18) {
// B
subMode = 2;
}
if (keynum == 19) {
// C
subMode = 3;
if (sd.status()) {
display.good();
} else {
display.bad();
}
}
}
}
last_key2 = key;
}