mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 12:25:12 +03:00
Projectkk2glider/gps misc fixes (#3970)
* Fixed Lua GPS date (year is now kept with four digits) * * GPS year displayed with two digits * GPS date/time handling fixes
This commit is contained in:
parent
a332f7a872
commit
5ba14734cb
8 changed files with 13 additions and 28 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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, ",");
|
||||
}
|
||||
else if (sensor.prec == 2) {
|
||||
div_t qr = div(telemetryItem.value, 100);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue