feat: Support all current timezones for GPS (#3406)
* Support all current timezones. * Fix function name and calculation for timezone offset. * Allow setting any time offset value from -12 to +14 in 15 minutes increments. * Alternate timezone editor in Companion (from elecpower). * Fix compiler warning. * chore: Add the T20
This commit is contained in:
@@ -599,9 +599,18 @@ void menuRadioSetup(event_t event)
|
||||
|
||||
#if defined(GPS)
|
||||
case ITEM_RADIO_SETUP_TIMEZONE:
|
||||
lcdDrawTextAlignedLeft(y, STR_TIMEZONE);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.timezone, attr|LEFT);
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.timezone, -12, 12);
|
||||
{
|
||||
lcdDrawTextAlignedLeft(y, STR_TIMEZONE);
|
||||
int tzIndex = timezoneIndex(g_eeGeneral.timezone, g_eeGeneral.timezoneMinutes);
|
||||
lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, timezoneDisplay(tzIndex).c_str(), attr);
|
||||
if (attr) {
|
||||
tzIndex = checkIncDec(event, tzIndex, minTimezone(), maxTimezone(), EE_GENERAL);
|
||||
if (checkIncDec_Ret) {
|
||||
g_eeGeneral.timezone = timezoneHour(tzIndex);
|
||||
g_eeGeneral.timezoneMinutes = timezoneMinute(tzIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_RADIO_SETUP_ADJUST_RTC:
|
||||
|
||||
@@ -547,9 +547,18 @@ void menuRadioSetup(event_t event)
|
||||
break;
|
||||
|
||||
case ITEM_RADIO_SETUP_TIMEZONE:
|
||||
lcdDrawText(INDENT_WIDTH, y, STR_TIMEZONE);
|
||||
lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.timezone, attr|LEFT);
|
||||
if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.timezone, -12, 12);
|
||||
{
|
||||
lcdDrawText(INDENT_WIDTH, y, STR_TIMEZONE);
|
||||
int tzIndex = timezoneIndex(g_eeGeneral.timezone, g_eeGeneral.timezoneMinutes);
|
||||
lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, timezoneDisplay(tzIndex).c_str(), attr);
|
||||
if (attr) {
|
||||
tzIndex = checkIncDec(event, tzIndex, minTimezone(), maxTimezone(), EE_GENERAL);
|
||||
if (checkIncDec_Ret) {
|
||||
g_eeGeneral.timezone = timezoneHour(tzIndex);
|
||||
g_eeGeneral.timezoneMinutes = timezoneMinute(tzIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ITEM_RADIO_SETUP_ADJUST_RTC:
|
||||
|
||||
@@ -556,10 +556,22 @@ class GpsPage : public SubPage {
|
||||
{
|
||||
FlexGridLayout grid(col_two_dsc, row_dsc, 4);
|
||||
|
||||
tzIndex = timezoneIndex(g_eeGeneral.timezone, g_eeGeneral.timezoneMinutes);
|
||||
|
||||
auto line = body.newLine(&grid);
|
||||
// Timezone
|
||||
new StaticText(line, rect_t{}, STR_TIMEZONE, 0, COLOR_THEME_PRIMARY1);
|
||||
new NumberEdit(line, rect_t{}, -12, 12, GET_SET_DEFAULT(g_eeGeneral.timezone));
|
||||
auto tz = new NumberEdit(line, rect_t{}, minTimezone(), maxTimezone(),
|
||||
GET_DEFAULT(tzIndex),
|
||||
[=](int newTz) {
|
||||
tzIndex = newTz;
|
||||
g_eeGeneral.timezone = timezoneHour(newTz);
|
||||
g_eeGeneral.timezoneMinutes = timezoneMinute(newTz);
|
||||
SET_DIRTY();
|
||||
});
|
||||
tz->setDisplayHandler([](int32_t tz) {
|
||||
return timezoneDisplay(tz);
|
||||
});
|
||||
line = body.newLine(&grid);
|
||||
|
||||
// Adjust RTC (from telemetry)
|
||||
@@ -572,6 +584,9 @@ class GpsPage : public SubPage {
|
||||
new Choice(line, rect_t{}, STR_GPSFORMAT, 0, 1, GET_SET_DEFAULT(g_eeGeneral.gpsFormat));
|
||||
line = body.newLine(&grid);
|
||||
}
|
||||
|
||||
protected:
|
||||
int tzIndex;
|
||||
};
|
||||
|
||||
class ViewOptionsPage : public Page
|
||||
|
||||
Reference in New Issue
Block a user