diff --git a/radio/src/gui/128x64/lcd.cpp b/radio/src/gui/128x64/lcd.cpp index 1ff180ac8..e6621911f 100644 --- a/radio/src/gui/128x64/lcd.cpp +++ b/radio/src/gui/128x64/lcd.cpp @@ -1062,7 +1062,7 @@ void drawDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags att) lcdDrawChar(lcdLastPos-1, y, '-', att); lcdDrawNumber(lcdNextPos-1, y, telemetryItem.datetime.month, att|LEFT, 2); lcdDrawChar(lcdLastPos-1, y, '-', att); - lcdDrawNumber(lcdNextPos-1, y, telemetryItem.datetime.year, att|LEFT); + lcdDrawNumber(lcdNextPos-1, y, telemetryItem.datetime.year-2000, att|LEFT); y += FH; lcdDrawNumber(x, y, telemetryItem.datetime.hour, att|LEADING0|LEFT, 2); lcdDrawChar(lcdLastPos, y, ':', att); diff --git a/radio/src/gui/212x64/lcd.cpp b/radio/src/gui/212x64/lcd.cpp index c783dfba5..b95a3dec4 100644 --- a/radio/src/gui/212x64/lcd.cpp +++ b/radio/src/gui/212x64/lcd.cpp @@ -850,7 +850,7 @@ void drawDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags att) lcdDrawChar(lcdLastPos-1, y, '-', att); lcdDrawNumber(lcdNextPos-1, y, telemetryItem.datetime.month, att|LEFT, 2); lcdDrawChar(lcdLastPos-1, y, '-', att); - lcdDrawNumber(lcdNextPos-1, y, telemetryItem.datetime.year, att|LEFT); + lcdDrawNumber(lcdNextPos-1, y, telemetryItem.datetime.year-2000, att|LEFT); y += FH; lcdDrawNumber(x, y, telemetryItem.datetime.hour, att|LEADING0|LEFT, 2); lcdDrawChar(lcdLastPos, y, ':', att); @@ -863,7 +863,7 @@ void drawDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags att) lcdDrawChar(lcdLastPos-1, y, '-', att); lcdDrawNumber(lcdNextPos, y, telemetryItem.datetime.month, att|LEFT, 2); lcdDrawChar(lcdLastPos-1, y, '-', att); - lcdDrawNumber(lcdNextPos, y, telemetryItem.datetime.year, att|LEFT); + lcdDrawNumber(lcdNextPos, y, telemetryItem.datetime.year-2000, att|LEFT); lcdDrawNumber(lcdNextPos+FW+1, y, telemetryItem.datetime.hour, att|LEADING0|LEFT, 2); lcdDrawChar(lcdLastPos, y, ':', att); lcdDrawNumber(lcdNextPos, y, telemetryItem.datetime.min, att|LEADING0|LEFT, 2); diff --git a/radio/src/gui/480x272/lcd.cpp b/radio/src/gui/480x272/lcd.cpp index c48186576..bf630a5b4 100644 --- a/radio/src/gui/480x272/lcd.cpp +++ b/radio/src/gui/480x272/lcd.cpp @@ -314,7 +314,7 @@ void drawDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags att) lcdDrawChar(lcdNextPos-1, y, '-', att); lcdDrawNumber(lcdNextPos-1, y, telemetryItem.datetime.month, att|LEFT, 2); lcdDrawChar(lcdNextPos-1, y, '-', att); - lcdDrawNumber(lcdNextPos-1, y, telemetryItem.datetime.year, att|LEFT); + lcdDrawNumber(lcdNextPos-1, y, telemetryItem.datetime.year-2000, att|LEFT); y += FH; lcdDrawNumber(x, y, telemetryItem.datetime.hour, att|LEADING0|LEFT, 2); lcdDrawChar(lcdNextPos, y, ':', att); @@ -327,7 +327,7 @@ void drawDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags att) lcdDrawChar(lcdNextPos-1, y, '-', att); lcdDrawNumber(lcdNextPos, y, telemetryItem.datetime.month, att|LEFT, 2); lcdDrawChar(lcdNextPos-1, y, '-', att); - lcdDrawNumber(lcdNextPos, y, telemetryItem.datetime.year, att|LEFT); + lcdDrawNumber(lcdNextPos, y, telemetryItem.datetime.year-2000, att|LEFT); lcdDrawNumber(lcdNextPos+11, y, telemetryItem.datetime.hour, att|LEADING0|LEFT, 2); lcdDrawChar(lcdNextPos, y, ':', att); lcdDrawNumber(lcdNextPos, y, telemetryItem.datetime.min, att|LEADING0|LEFT, 2); diff --git a/radio/src/logs.cpp b/radio/src/logs.cpp index 53fc1d192..1382ed810 100644 --- a/radio/src/logs.cpp +++ b/radio/src/logs.cpp @@ -312,10 +312,7 @@ void logsWrite() } } else if (sensor.unit == UNIT_DATETIME) { - if (telemetryItem.datetime.datestate) - f_printf(&g_oLogFile, "%4d-%02d-%02d %02d:%02d:%02d,", telemetryItem.datetime.year, telemetryItem.datetime.month, telemetryItem.datetime.day, telemetryItem.datetime.hour, telemetryItem.datetime.min, telemetryItem.datetime.sec); - else - f_printf(&g_oLogFile, ","); + f_printf(&g_oLogFile, "%4d-%02d-%02d %02d:%02d:%02d,", telemetryItem.datetime.year, telemetryItem.datetime.month, telemetryItem.datetime.day, telemetryItem.datetime.hour, telemetryItem.datetime.min, telemetryItem.datetime.sec); } else if (sensor.prec == 2) { div_t qr = div(telemetryItem.value, 100); diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index fad1fc78b..ef20a650b 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -157,7 +157,7 @@ static void luaPushLatLon(TelemetrySensor & telemetrySensor, TelemetryItem & tel static void luaPushTelemetryDateTime(TelemetrySensor & telemetrySensor, TelemetryItem & telemetryItem) { - luaPushDateTime(L, telemetryItem.datetime.year + 2000, telemetryItem.datetime.month, telemetryItem.datetime.day, + luaPushDateTime(L, telemetryItem.datetime.year, telemetryItem.datetime.month, telemetryItem.datetime.day, telemetryItem.datetime.hour, telemetryItem.datetime.min, telemetryItem.datetime.sec); } diff --git a/radio/src/rtc.cpp b/radio/src/rtc.cpp index baa5fadce..2b8fdddac 100644 --- a/radio/src/rtc.cpp +++ b/radio/src/rtc.cpp @@ -460,7 +460,7 @@ uint8_t rtcAdjust(uint16_t year, uint8_t mon, uint8_t day, uint8_t hour, uint8_t if ((get_tmr10ms() - lastRtcAdjust) > (RTC_ADJUST_PERIOD * 100)) { lastRtcAdjust = get_tmr10ms(); - if ((hour == 0 && min == 0) || (hour == 23 && min == 59)) return 0; + if (year == 0 || (hour == 0 && min == 0) || (hour == 23 && min == 59)) return 0; // convert given UTC time to local time (to seconds) and compare it with RTC struct gtm t; diff --git a/radio/src/telemetry/telemetry_sensors.cpp b/radio/src/telemetry/telemetry_sensors.cpp index 8f5ed97fa..f7b987551 100644 --- a/radio/src/telemetry/telemetry_sensors.cpp +++ b/radio/src/telemetry/telemetry_sensors.cpp @@ -76,29 +76,20 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t val, uint32 else if (unit == UNIT_DATETIME) { uint32_t data = uint32_t(newVal); if (data & 0x000000ff) { - datetime.year = (uint16_t) ((data & 0xff000000) >> 24) + 2000; + datetime.year = (uint16_t) ((data & 0xff000000) >> 24) + 2000; // SPORT GPS year is only two digits datetime.month = (uint8_t) ((data & 0x00ff0000) >> 16); datetime.day = (uint8_t) ((data & 0x0000ff00) >> 8); - if (datetime.year != 0) { - datetime.datestate = 1; - } } else { datetime.hour = (uint8_t) ((data & 0xff000000) >> 24); datetime.min = (uint8_t) ((data & 0x00ff0000) >> 16); - datetime.sec = (uint16_t) ((data & 0x0000ff00) >> 8); - if (datetime.datestate == 1) { - datetime.timestate = 1; - } + datetime.sec = (uint8_t) ((data & 0x0000ff00) >> 8); #if defined(RTCLOCK) - if (g_eeGeneral.adjustRTC && datetime.datestate == 1) { + if (g_eeGeneral.adjustRTC) { rtcAdjust(datetime.year, datetime.month, datetime.day, datetime.hour, datetime.min, datetime.sec); } #endif } - if (datetime.year == 0) { - return; - } newVal = 0; } else if (unit == UNIT_GPS_LATITUDE) { @@ -126,17 +117,16 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t val, uint32 uint32_t data = uint32_t(newVal); datetime.month = data >> 8; datetime.day = data & 0xFF; - datetime.datestate = 1; return; } else if (unit == UNIT_DATETIME_HOUR_MIN) { uint32_t data = uint32_t(newVal); datetime.hour = (data & 0xFF); datetime.min = data >> 8; + return; } else if (unit == UNIT_DATETIME_SEC) { datetime.sec = newVal & 0xFF; - datetime.timestate = 1; newVal = 0; } else if (unit == UNIT_RPMS) { diff --git a/radio/src/telemetry/telemetry_sensors.h b/radio/src/telemetry/telemetry_sensors.h index 2cfceb214..91ae90468 100644 --- a/radio/src/telemetry/telemetry_sensors.h +++ b/radio/src/telemetry/telemetry_sensors.h @@ -61,11 +61,9 @@ class TelemetryItem CellValue values[6]; } cells; struct { - uint8_t datestate; - uint16_t year; + uint16_t year; // full year (4 digits) uint8_t month; uint8_t day; - uint8_t timestate; uint8_t hour; uint8_t min; uint8_t sec;