fix: proper fallback for datetime display if no NMEA string has been received yet
This commit is contained in:
parent
78a9dfb99a
commit
913ecf3f3f
1 changed files with 13 additions and 7 deletions
20
src/main.cpp
20
src/main.cpp
|
@ -352,13 +352,18 @@ void printLocation() {
|
||||||
void printDateTime() {
|
void printDateTime() {
|
||||||
char dateTime[17];
|
char dateTime[17];
|
||||||
char speedCourse[17];
|
char speedCourse[17];
|
||||||
snprintf(dateTime, 17, "%.2s.%.2s.%.2s %.2s:%.2sz",
|
if (rmc.date[0] != 0) {
|
||||||
rmc.date, rmc.date+2, rmc.date+4,
|
snprintf(dateTime, 17, "%.2s.%.2s.%.2s %.2s:%.2sz",
|
||||||
rmc.time, rmc.time+2);
|
rmc.date, rmc.date+2, rmc.date+4,
|
||||||
uint16_t kph = (strtol(rmc.speed, NULL, 10) * 463) / 250;
|
rmc.time, rmc.time+2);
|
||||||
uint16_t hdg = strtol(rmc.course, NULL, 10);
|
uint16_t kph = (strtol(rmc.speed, NULL, 10) * 463) / 250;
|
||||||
snprintf(speedCourse, 17, "% 3d km/h% 6d \xdf",
|
uint16_t hdg = strtol(rmc.course, NULL, 10);
|
||||||
kph, hdg);
|
snprintf(speedCourse, 17, "% 3d km/h% 6d \xdf",
|
||||||
|
kph, hdg);
|
||||||
|
} else {
|
||||||
|
snprintf(dateTime, 17, "??.??.?? ??:??z");
|
||||||
|
snprintf(speedCourse, 17, "??? km/h ??? \xdf");
|
||||||
|
}
|
||||||
|
|
||||||
lcd.setCursor(0, 0);
|
lcd.setCursor(0, 0);
|
||||||
lcd.print(dateTime);
|
lcd.print(dateTime);
|
||||||
|
@ -682,6 +687,7 @@ void setup() {
|
||||||
attachInterrupt(digitalPinToInterrupt(3), isrAbc, FALLING);
|
attachInterrupt(digitalPinToInterrupt(3), isrAbc, FALLING);
|
||||||
lcd.init();
|
lcd.init();
|
||||||
lcd.noDisplay();
|
lcd.noDisplay();
|
||||||
|
lcd.noBacklight();
|
||||||
setPressed = false;
|
setPressed = false;
|
||||||
abcPressed = false;
|
abcPressed = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue