From 2a3c5958ad83b073c91672b8a4e25ee1f65f2b06 Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 17 Feb 2015 19:35:52 +0100 Subject: [PATCH 1/8] Fixes #2056 - Needs tests! --- radio/src/gui/Taranis/menu_general_setup.cpp | 12 +++++++++++- radio/src/myeeprom.h | 2 +- radio/src/telemetry/telemetry.cpp | 16 ++++++++++++++++ radio/src/translations.cpp | 2 ++ radio/src/translations.h | 2 ++ radio/src/translations/cz.h.txt | 2 ++ radio/src/translations/de.h.txt | 2 ++ radio/src/translations/en.h.txt | 6 ++++-- radio/src/translations/es.h.txt | 2 ++ radio/src/translations/fi.h.txt | 2 ++ radio/src/translations/fr.h.txt | 2 ++ radio/src/translations/it.h.txt | 2 ++ radio/src/translations/pl.h.txt | 2 ++ radio/src/translations/pt.h.txt | 2 ++ radio/src/translations/se.h.txt | 2 ++ 15 files changed, 54 insertions(+), 4 deletions(-) diff --git a/radio/src/gui/Taranis/menu_general_setup.cpp b/radio/src/gui/Taranis/menu_general_setup.cpp index 791ce551e..e94242c29 100755 --- a/radio/src/gui/Taranis/menu_general_setup.cpp +++ b/radio/src/gui/Taranis/menu_general_setup.cpp @@ -90,7 +90,9 @@ enum menuGeneralSetupItems { CASE_REVPLUS(ITEM_SETUP_BACKLIGHT_COLOR) ITEM_SETUP_FLASH_BEEP, CASE_SPLASH_PARAM(ITEM_SETUP_DISABLE_SPLASH) + CASE_GPS(ITEM_SETUP_LABEL_GPS) CASE_GPS(ITEM_SETUP_TIMEZONE) + CASE_GPS(ITEM_SETUP_ADJUST_RTC) CASE_GPS(ITEM_SETUP_GPSFORMAT) CASE_PXX(ITEM_SETUP_COUNTRYCODE) ITEM_SETUP_LANGUAGE, @@ -126,7 +128,7 @@ void menuGeneralSetup(uint8_t event) } #endif - MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, { 2, 2, 1, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO_CPUARM(LABEL(VARIO)) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, 0, CASE_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, IF_FAI_CHOICE(0) CASE_MAVLINK(0) 0, 0, LABEL(TX_MODE), 0, 1/*to force edit mode*/ }); + MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, { 2, 2, 1, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO_CPUARM(LABEL(VARIO)) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, 0, CASE_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, IF_FAI_CHOICE(0) CASE_MAVLINK(0) 0, 0, LABEL(TX_MODE), 0, 1/*to force edit mode*/ }); int sub = m_posVert; @@ -412,12 +414,20 @@ void menuGeneralSetup(uint8_t event) #endif #if defined(FRSKY) && defined(FRSKY_HUB) && defined(GPS) + case ITEM_SETUP_LABEL_GPS: + lcd_putsLeft(y, STR_GPS); + break; + case ITEM_SETUP_TIMEZONE: lcd_putsLeft(y, STR_TIMEZONE); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.timezone, attr|LEFT); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.timezone, -12, 12); break; + case ITEM_SETUP_ADJUST_RTC: + g_eeGeneral.adjustRTC = onoffMenuItem(g_eeGeneral.adjustRTC, RADIO_SETUP_2ND_COLUMN, y, STR_ADJUST_RTC, attr, event); + break; + case ITEM_SETUP_GPSFORMAT: g_eeGeneral.gpsFormat = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_GPSCOORD, STR_GPSFORMAT, g_eeGeneral.gpsFormat, 0, 1, attr, event); break; diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 93e079c50..c02fcc6a5 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -742,7 +742,7 @@ PACK(typedef struct { uint8_t disableAlarmWarning:1; uint8_t stickMode:2; int8_t timezone:5; - uint8_t spare1:1; + uint8_t adjustRTC:1; uint8_t inactivityTimer; uint8_t mavbaud:3; SPLASH_MODE; /* 3bits */ diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index 1a3101b3f..2239661f7 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -53,12 +53,28 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uin datetime.month = (uint8_t) ((data & 0x00ff0000) >> 16); datetime.day = (uint8_t) ((data & 0x0000ff00) >> 8); datetime.datestate = 1; + if (g_eeGeneral.adjustRTC) { + struct gtm t; + gettime(&t); + t.tm_year = datetime.year-1900; + t.tm_mon = datetime.month; + t.tm_mday = datetime.day; + rtcSetTime(&t); + } } else { datetime.hour = ((uint8_t) ((data & 0xff000000) >> 24) + g_eeGeneral.timezone + 24) % 24; datetime.min = (uint8_t) ((data & 0x00ff0000) >> 16); datetime.sec = (uint16_t) ((data & 0x0000ff00) >> 8); datetime.timestate = 1; + if (g_eeGeneral.adjustRTC) { + struct gtm t; + gettime(&t); + t.tm_hour = datetime.hour; + t.tm_min = datetime.min; + t.tm_sec = datetime.sec; + rtcSetTime(&t); + } } if (datetime.year == 0) { return; diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 48ce9ee21..738db4af3 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -248,6 +248,8 @@ const pm_char STR_THROTTLEWARNING[] PROGMEM = TR_THROTTLEWARNING; const pm_char STR_SWITCHWARNING[] PROGMEM = TR_SWITCHWARNING; #ifdef FRSKY const pm_char STR_TIMEZONE[] PROGMEM = TR_TIMEZONE; +const pm_char STR_ADJUST_RTC[] PROGMEM = TR_ADJUST_RTC; +const pm_char STR_GPS[] PROGMEM = TR_GPS; const pm_char STR_GPSCOORD[] PROGMEM = TR_GPSCOORD; const pm_char STR_VARIO[] PROGMEM = TR_VARIO; const pm_char STR_PITCH_AT_ZERO[] PROGMEM = TR_PITCH_AT_ZERO; diff --git a/radio/src/translations.h b/radio/src/translations.h index 8f9cdbcda..b297af880 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -427,6 +427,8 @@ extern const pm_char STR_SPLASHSCREEN[]; extern const pm_char STR_THROTTLEWARNING[]; extern const pm_char STR_SWITCHWARNING[]; extern const pm_char STR_TIMEZONE[]; +extern const pm_char STR_ADJUST_RTC[]; +extern const pm_char STR_GPS[]; extern const pm_char STR_GPSCOORD[]; extern const pm_char STR_VARIO[]; extern const pm_char STR_PITCH_AT_ZERO[]; diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 76eef770b..18c5fc535 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -621,6 +621,8 @@ #define TR_SWITCHWARNING TR("* Spínače", INDENT "Polohy Spínačů") #define TR_POTWARNING TR("* Potenc.", INDENT "Nastavení Pot.") #define TR_TIMEZONE "časové pásmo" +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD TR("Pořadí kanálů", "Výchozí pořadí kanálů") #define TR_STICKS "Sticks" #define TR_POTS "Pots" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index b47d7ab97..8241fd4dc 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -669,6 +669,8 @@ #define TR_SWITCHWARNING TR("Sch. Alarm", INDENT "Schalter-Alarm") #define TR_POTWARNING TR("Pot Warn.", INDENT "Poti-Warnung") #define TR_TIMEZONE TR("Zeitzone", "GPS-Zeitzone +/-Std") +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD TR("Kanalanordnung", "Kanalvoreinstellung") #define TR_STICKS "Knüppel" #define TR_POTS "Potis" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 4d403c78d..09490e257 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -668,7 +668,9 @@ #define TR_THROTTLEWARNING TR(IF_CPUARM(INDENT) "T-Warning", INDENT "Throttle State") #define TR_SWITCHWARNING TR(IF_CPUARM(INDENT) "S-Warning", INDENT "Switch Positions") #define TR_POTWARNING TR(IF_CPUARM(INDENT) "Pot Warn.", INDENT "Pot Positions") -#define TR_TIMEZONE TR("Time Zone", "GPS Time zone") +#define TR_TIMEZONE TR("Time Zone", INDENT "Time zone") +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD TR("Rx Channel Ord", "Default channel order") #define TR_STICKS "Sticks" #define TR_POTS "Pots" @@ -771,7 +773,7 @@ #define TR_MINRSSI "Min Rssi" #define TR_LATITUDE "Latitude" #define TR_LONGITUDE "Longitude" -#define TR_GPSCOORD TR("GPS Coords", "GPS coordinate format") +#define TR_GPSCOORD TR("GPS Coords", INDENT "Coordinate format") #define TR_VARIO TR("Vario", "Variometer") #define TR_PITCH_AT_ZERO INDENT "Pitch at Zero" #define TR_PITCH_AT_MAX INDENT "Pitch at Max" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index de3d0fb45..098519165 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -618,6 +618,8 @@ #define TR_SWITCHWARNING TR("Aviso-I", INDENT "Aviso Intrptor") #define TR_POTWARNING TR("Pot Warn.", INDENT "Pot Warning") #define TR_TIMEZONE TR("Zona Hora", "GPS Zona Hora") +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD TR("Rx Orden canal", "Orden habitual canales") #define TR_STICKS "Sticks" #define TR_POTS "Pots" diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index 3cc4f2746..2eabacb29 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -618,6 +618,8 @@ #define TR_SWITCHWARNING TR("S-Warning", INDENT "Switch Warning") #define TR_POTWARNING TR("Pot Warn.", INDENT "Pot Warning") #define TR_TIMEZONE TR("Time Zone","GPS Time zone") +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD TR("Rx Channel Ord","Default channel order") #define TR_STICKS "Sticks" #define TR_POTS "Pots" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 4ad9984f3..ce283f777 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -673,6 +673,8 @@ #define TR_SWITCHWARNING TR(IF_CPUARM(INDENT) "Alerte int", INDENT "Pos. interrupteurs") #define TR_POTWARNING TR(IF_CPUARM(INDENT) "Alerte pot", INDENT "Pos. potentios") #define TR_TIMEZONE "Fuseau horaire" +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD TR("Ordre voies RX","Ordre des voies préféré") #define TR_STICKS "Manches" #define TR_POTS "Potentios" diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index f310e17ee..698d139b5 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -618,6 +618,8 @@ #define TR_SWITCHWARNING TR("Avv. Int.", INDENT "Avviso Interr.") #define TR_POTWARNING TR("Avv. Pot.", INDENT "Avviso Pot.") #define TR_TIMEZONE "Ora locale" +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD "Ordine ch RX" #define TR_STICKS "Sticks" #define TR_POTS "Pots" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index a45e0c107..0332a0eae 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -616,6 +616,8 @@ #define TR_SWITCHWARNING TR(IF_CPUARM(INDENT) "OstrzPrzeł", INDENT "PozycjaPrzeł") #define TR_POTWARNING TR(IF_CPUARM(INDENT) "Ostrz.Poten.", INDENT "PozycjaPotencj.") #define TR_TIMEZONE TR("Strefa czasowa" ,"Strefa czasowa GPS") +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD TR("KolejnKan.RX", "Bazowa kolejność kanałów") #define TR_STICKS "Sticks" #define TR_POTS "Pots" diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 0e10202e9..cf65ee016 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -618,6 +618,8 @@ #define TR_SWITCHWARNING TR("Avisa Chav", INDENT "Avisa Chav") #define TR_POTWARNING TR("Pot Warn.", INDENT "Pot Warning") #define TR_TIMEZONE "Time Zone" +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD "Ordem Canal RX" #define TR_STICKS "Sticks" #define TR_POTS "Pots" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index c235ae993..cc7dbcc7e 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -618,6 +618,8 @@ #define TR_SWITCHWARNING TR("Bryt.varn.", INDENT "Brytarvarning") #define TR_POTWARNING TR("Rattvarn.", INDENT "Rattvarning") #define TR_TIMEZONE TR("Tidszon", "GPS Tidszon") +#define TR_ADJUST_RTC INDENT "Adjust RTC" +#define TR_GPS "GPS" #define TR_RXCHANNELORD "Kanaler i RX" #define TR_STICKS "Sticks" #define TR_POTS "Pots" From 01e6c60cf5f470a3f862ae6d8cc34dc36b1adce4 Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 17 Feb 2015 21:34:54 +0100 Subject: [PATCH 2/8] Companion compilation fix --- radio/src/targets/sky9x/rtc_driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/targets/sky9x/rtc_driver.cpp b/radio/src/targets/sky9x/rtc_driver.cpp index e39e6e0fa..ddd0ea50d 100644 --- a/radio/src/targets/sky9x/rtc_driver.cpp +++ b/radio/src/targets/sky9x/rtc_driver.cpp @@ -34,7 +34,7 @@ * */ -#include "../opentx.h" +#include "../../opentx.h" #if defined(REVX) // TODO change this, not the right place From 0886873f54b89ab1ea02b60cdab724b2feb8103c Mon Sep 17 00:00:00 2001 From: bsongis Date: Fri, 20 Feb 2015 23:03:26 +0100 Subject: [PATCH 3/8] Fix for the bug projectkk2glider noticed, thanks! --- radio/src/telemetry/telemetry.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index 2239661f7..27b85dde7 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -70,10 +70,14 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uin if (g_eeGeneral.adjustRTC) { struct gtm t; gettime(&t); - t.tm_hour = datetime.hour; - t.tm_min = datetime.min; - t.tm_sec = datetime.sec; - rtcSetTime(&t); + if (abs((t.tm_hour-datetime.hour)*3600 + (t.tm_min-datetime.min)*60 + (t.tm_sec-datetime.sec)) > 20) { + // we adjust RTC only if difference is > 20 seconds + t.tm_hour = datetime.hour; + t.tm_min = datetime.min; + t.tm_sec = datetime.sec; + g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated + rtcSetTime(&t); + } } } if (datetime.year == 0) { From c44a355573eb37943797fd7449a492605815c6ce Mon Sep 17 00:00:00 2001 From: bsongis Date: Fri, 20 Feb 2015 23:51:12 +0100 Subject: [PATCH 4/8] Fixes #2056 - Companion part --- companion/src/eeprominterface.h | 4 +- .../src/firmwares/opentx/opentxeeprom.cpp | 7 +- .../src/firmwares/opentx/opentxinterface.cpp | 2 - companion/src/generaledit/generalsetup.cpp | 22 +- companion/src/generaledit/generalsetup.h | 3 +- companion/src/generaledit/generalsetup.ui | 527 +++++++++--------- 6 files changed, 296 insertions(+), 269 deletions(-) diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 0684fafd4..1c65c9c5d 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -1095,7 +1095,8 @@ class GeneralSettings { bool enableTelemetryAlarm; BeeperMode hapticMode; unsigned int stickMode; // TODO enum - int timezone; + int timezone; + bool adjustRTC; bool optrexDisplay; unsigned int inactivityTimer; bool minuteBeep; @@ -1246,7 +1247,6 @@ enum Capability { NoTelemetryProtocol, TelemetryCustomScreens, TelemetryCustomScreensFieldsPerLine, - TelemetryTimeshift, TelemetryMaxMultiplier, HasVario, HasVarioSink, diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index e319a9730..a0531d166 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -3157,7 +3157,12 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo internalField.Append(new UnsignedField<2>(generalData.stickMode)); internalField.Append(new SignedField<5>(generalData.timezone)); - internalField.Append(new SpareBitsField<1>()); + if (version >= 217 && IS_TARANIS(board)) { + internalField.Append(new BoolField<1>(generalData.adjustRTC)); + } + else { + internalField.Append(new SpareBitsField<1>()); + } internalField.Append(new UnsignedField<8>(generalData.inactivityTimer)); if (IS_9X(board) && version >= 215) { diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 6d506ca1e..48ad71cb7 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -689,8 +689,6 @@ int OpenTxFirmware::getCapability(const Capability capability) return IS_TARANIS(board) ? 1 : 0; case TelemetryUnits: return 0; - case TelemetryTimeshift: - return 1; case TelemetryMaxMultiplier: return (IS_ARM(board) ? 32 : 8); case PPMCenter: diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index 9fcf2e1c0..ddd982e1a 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -123,17 +123,16 @@ GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & general ui->units_CB->setCurrentIndex(generalSettings.imperial); } - if (!firmware->getCapability(TelemetryTimeshift)) { - ui->label_timezone->hide(); - ui->timezoneSB->hide(); - ui->timezoneSB->setDisabled(true); - ui->gpsFormatCB->hide(); - ui->gpsFormatLabel->hide(); - } - ui->gpsFormatCB->setCurrentIndex(generalSettings.gpsFormat); ui->timezoneSB->setValue(generalSettings.timezone); + if (IS_TARANIS(firmware->getBoard())) { + ui->adjustRTC->setChecked(generalSettings.adjustRTC); + } + else { + ui->adjustRTC->hide(); + } + if (!firmware->getCapability(OptrexDisplay)) { ui->label_displayType->hide(); ui->displayTypeCB->setDisabled(true); @@ -533,6 +532,13 @@ void GeneralSetupPanel::on_timezoneSB_editingFinished() emit modified(); } +void GeneralSetupPanel::on_adjustRTC_stateChanged(int) +{ + generalSettings.adjustRTC = ui->adjustRTC->isChecked(); + emit modified(); +} + + void GeneralSetupPanel::on_inactimerSB_editingFinished() { generalSettings.inactivityTimer = ui->inactimerSB->value(); diff --git a/companion/src/generaledit/generalsetup.h b/companion/src/generaledit/generalsetup.h index 3b72b475d..f884d0062 100644 --- a/companion/src/generaledit/generalsetup.h +++ b/companion/src/generaledit/generalsetup.h @@ -19,7 +19,7 @@ class GeneralSetupPanel : public GeneralPanel private slots: void on_splashScreenChkB_stateChanged(int); void on_splashScreenDuration_currentIndexChanged(int index); - void on_alarmwarnChkB_stateChanged(int ); + void on_alarmwarnChkB_stateChanged(int); void on_gpsFormatCB_currentIndexChanged(int index); void on_displayTypeCB_currentIndexChanged(int index); void on_BLBright_SB_editingFinished(); @@ -29,6 +29,7 @@ class GeneralSetupPanel : public GeneralPanel void on_faimode_CB_stateChanged(int ); void on_speakerPitchSB_editingFinished(); void on_timezoneSB_editingFinished(); + void on_adjustRTC_stateChanged(int); void on_hapticStrength_valueChanged(); void on_soundModeCB_currentIndexChanged(int index); void on_beeperlenCB_currentIndexChanged(int index); diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index cd269787a..156464e5c 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -6,101 +6,29 @@ 0 0 - 689 - 606 + 758 + 635 Form - + GPS Coordinates - - - - Speaker Pitch (spkr only) - - - - - - - + Measurement Units - - - - - hh° (N/S) mm' ss''.dd - - - - - NMEA - - - - - - - -14 - - - 12 - - - 0 - - - - - - - Voice Language - - - - - - - Timeshift from UTC - - - - - - - - Metric - - - - - Imperial - - - - - - - - Country Code - - - - @@ -119,6 +47,144 @@ + + + + FAI Mode + + + + + + + Country Code + + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Show splash screen on startup + + + Show splash screen on startup + + + + + + + + + + + 0 + 0 + + + + + --- + + + + + 2s + + + + + 3s + + + + + 4s + + + + + 6s + + + + + 8s + + + + + 10s + + + + + 15s + + + + + + + + + + + hh° (N/S) mm' ss''.dd + + + + + NMEA + + + + + + + + + Metric + + + + + Imperial + + + + + + + + Speaker Pitch (spkr only) + + + + + + + + + + Voice Language + + + @@ -195,6 +261,41 @@ + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + + + + + + true + + + @@ -247,7 +348,7 @@ - + Qt::Vertical @@ -1278,41 +1379,6 @@ Acceptable values are 5v..10v - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - - - @@ -1404,85 +1470,6 @@ p, li { white-space: pre-wrap; } - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Show splash screen on startup - - - Show splash screen on startup - - - - - - - - - - - 0 - 0 - - - - - --- - - - - - 2s - - - - - 3s - - - - - 4s - - - - - 6s - - - - - 8s - - - - - 10s - - - - - 15s - - - - - - @@ -1607,19 +1594,6 @@ p, li { white-space: pre-wrap; } - - - - - 0 - 0 - - - - Stick reverse (order as above) - - - @@ -1633,13 +1607,6 @@ p, li { white-space: pre-wrap; } - - - - FAI Mode - - - @@ -1694,38 +1661,6 @@ Mode 4: - - - - - - 1 - - - - - - - 2 - - - - - - - 3 - - - - - - - 4 - - - - - @@ -1862,17 +1797,7 @@ Mode 4: - - - - If you enable FAI, you loose the vario, the play functions, the telemetry screen. This function cannot be disabled by the radio. - - - - - - - + @@ -1885,7 +1810,7 @@ Mode 4: - + @@ -1932,6 +1857,98 @@ p, li { white-space: pre-wrap; } + + + + Timeshift from UTC + + + + + + + + + 1 + + + + + + + 2 + + + + + + + 3 + + + + + + + 4 + + + + + + + + + + 0 + 0 + + + + Stick reverse + + + + + + + + + -14 + + + 12 + + + 0 + + + + + + + If you enable FAI, you loose the vario, the play functions, the telemetry screen. This function cannot be disabled by the radio. + + + Qt::RightToLeft + + + Adjust RTC + + + + + + + + + If you enable FAI, you loose the vario, the play functions, the telemetry screen. This function cannot be disabled by the radio. + + + + + + From 4318d047072ea49db842ffbaba699807479f2ead Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Sat, 21 Mar 2015 11:12:19 +0400 Subject: [PATCH 5/8] Fix date adjustment, avoid setting time/date before GPS reception is good (GPS sends 0:0:0 0-0-0). Doesn't handle disconnection/reconnection of GPS module while radio is on, datetime.datestate and datetime.timestate should be reset when sensor is considered old --- radio/src/telemetry/telemetry.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index 27b85dde7..3f1e5fced 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -52,12 +52,14 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uin datetime.year = (uint16_t) ((data & 0xff000000) >> 24); datetime.month = (uint8_t) ((data & 0x00ff0000) >> 16); datetime.day = (uint8_t) ((data & 0x0000ff00) >> 8); - datetime.datestate = 1; - if (g_eeGeneral.adjustRTC) { + if (datetime.year != 0) { + datetime.datestate = 1; + } + if (g_eeGeneral.adjustRTC && (datetime.datestate == 1)) { struct gtm t; gettime(&t); - t.tm_year = datetime.year-1900; - t.tm_mon = datetime.month; + t.tm_year = datetime.year+4; + t.tm_mon = datetime.month-1; t.tm_mday = datetime.day; rtcSetTime(&t); } @@ -66,8 +68,10 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uin datetime.hour = ((uint8_t) ((data & 0xff000000) >> 24) + g_eeGeneral.timezone + 24) % 24; datetime.min = (uint8_t) ((data & 0x00ff0000) >> 16); datetime.sec = (uint16_t) ((data & 0x0000ff00) >> 8); - datetime.timestate = 1; - if (g_eeGeneral.adjustRTC) { + if (datetime.datestate == 1) { + datetime.timestate = 1; + } + if (g_eeGeneral.adjustRTC && (datetime.datestate == 1)) { struct gtm t; gettime(&t); if (abs((t.tm_hour-datetime.hour)*3600 + (t.tm_min-datetime.min)*60 + (t.tm_sec-datetime.sec)) > 20) { From 609f701f90710fb9976512d507e5531519432ed6 Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Sat, 21 Mar 2015 12:30:12 +0400 Subject: [PATCH 6/8] Time/date marked as invalid when sensor is old --- radio/src/telemetry/frsky.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/radio/src/telemetry/frsky.cpp b/radio/src/telemetry/frsky.cpp index 046921ce0..16586f305 100644 --- a/radio/src/telemetry/frsky.cpp +++ b/radio/src/telemetry/frsky.cpp @@ -357,6 +357,11 @@ void telemetryWakeup() uint8_t lastReceived = telemetryItems[i].lastReceived; if (lastReceived < TELEMETRY_VALUE_TIMER_CYCLE && uint8_t(now - lastReceived) > TELEMETRY_VALUE_OLD_THRESHOLD) { telemetryItems[i].lastReceived = TELEMETRY_VALUE_OLD; + TelemetrySensor * sensor = & g_model.telemetrySensors[i]; + if (sensor->unit == UNIT_DATETIME) { + telemetryItems[i].datetime.datestate = 0; + telemetryItems[i].datetime.timestate = 0; + } } } } From 405567ac11daefe06bbdf459ab4eeac49ec95eae Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Sun, 22 Mar 2015 13:17:47 +0400 Subject: [PATCH 7/8] Compilation fix when RTCLOCK not defined --- radio/src/telemetry/telemetry.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index 3f1e5fced..bca364d52 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -55,6 +55,7 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uin if (datetime.year != 0) { datetime.datestate = 1; } +#if defined(RTCLOCK) if (g_eeGeneral.adjustRTC && (datetime.datestate == 1)) { struct gtm t; gettime(&t); @@ -63,6 +64,7 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uin t.tm_mday = datetime.day; rtcSetTime(&t); } +#endif } else { datetime.hour = ((uint8_t) ((data & 0xff000000) >> 24) + g_eeGeneral.timezone + 24) % 24; @@ -71,6 +73,7 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uin if (datetime.datestate == 1) { datetime.timestate = 1; } +#if defined(RTCLOCK) if (g_eeGeneral.adjustRTC && (datetime.datestate == 1)) { struct gtm t; gettime(&t); @@ -83,6 +86,7 @@ void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t newVal, uin rtcSetTime(&t); } } +#endif } if (datetime.year == 0) { return; From 763f9062444b08c06974cb4de2665303f09be2e9 Mon Sep 17 00:00:00 2001 From: bsongis Date: Sun, 22 Mar 2015 18:50:08 +0100 Subject: [PATCH 8/8] [Taranis X9E] Bluetooth driver --- radio/src/main_arm.cpp | 4 ++ .../src/targets/taranis/bluetooth_driver.cpp | 63 +++++++++++++++---- radio/src/targets/taranis/board_taranis.h | 1 + 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/radio/src/main_arm.cpp b/radio/src/main_arm.cpp index 09c7b209f..747160ab3 100644 --- a/radio/src/main_arm.cpp +++ b/radio/src/main_arm.cpp @@ -203,4 +203,8 @@ void perMain() topLcdRefreshEnd(); #endif +#if defined(REV9E) && !defined(SIMU) + bt_wakeup(); +#endif + } diff --git a/radio/src/targets/taranis/bluetooth_driver.cpp b/radio/src/targets/taranis/bluetooth_driver.cpp index 55f106fec..819c1c153 100755 --- a/radio/src/targets/taranis/bluetooth_driver.cpp +++ b/radio/src/targets/taranis/bluetooth_driver.cpp @@ -16,9 +16,16 @@ #define BT_UART_AF GPIO_AF_USART6 #define BT_UART_IRQn USART6_IRQn -#define BT_UART_GPIO_PORT GPIOG +#define BT_UART_GPIO_CLK_TXRX RCC_AHB1Periph_GPIOG +#define BT_UART_GPIO_PORT_TXRX GPIOG #define BT_UART_GPIO_PIN_TX GPIO_Pin_14 #define BT_UART_GPIO_PIN_RX GPIO_Pin_9 +#define BT_UART_GPIO_CLK_EN RCC_AHB1Periph_GPIOD +#define BT_UART_GPIO_PORT_EN GPIOD +#define BT_UART_GPIO_PIN_EN GPIO_Pin_11 +#define BT_UART_GPIO_CLK_BRTS RCC_AHB1Periph_GPIOB +#define BT_UART_GPIO_PORT_BRTS GPIOB +#define BT_UART_GPIO_PIN_BRTS GPIO_Pin_10 #define BT_UART_GPIO_TX_PinSource GPIO_PinSource14 #define BT_UART_GPIO_RX_PinSource GPIO_PinSource9 @@ -30,25 +37,34 @@ int bt_open() GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure; - RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE); + RCC_AHB1PeriphClockCmd(BT_UART_GPIO_CLK_TXRX, ENABLE); + RCC_AHB1PeriphClockCmd(BT_UART_GPIO_CLK_EN, ENABLE); + RCC_AHB1PeriphClockCmd(BT_UART_GPIO_CLK_BRTS, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE); - GPIO_PinAFConfig(BT_UART_GPIO_PORT, BT_UART_GPIO_TX_PinSource, BT_UART_AF); - GPIO_PinAFConfig(BT_UART_GPIO_PORT, BT_UART_GPIO_RX_PinSource, BT_UART_AF); - - GPIO_InitStructure.GPIO_Pin = BT_UART_GPIO_PIN_TX; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Pin = BT_UART_GPIO_PIN_EN; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(BT_UART_GPIO_PORT, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = BT_UART_GPIO_PIN_RX; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_Init(BT_UART_GPIO_PORT_EN, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = BT_UART_GPIO_PIN_BRTS; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(BT_UART_GPIO_PORT, &GPIO_InitStructure); + GPIO_Init(BT_UART_GPIO_PORT_BRTS, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = BT_UART_GPIO_PIN_TX|BT_UART_GPIO_PIN_RX; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; + GPIO_Init(BT_UART_GPIO_PORT_TXRX, &GPIO_InitStructure); + + GPIO_PinAFConfig(BT_UART_GPIO_PORT_TXRX, BT_UART_GPIO_TX_PinSource, BT_UART_AF); + GPIO_PinAFConfig(BT_UART_GPIO_PORT_TXRX, BT_UART_GPIO_RX_PinSource, BT_UART_AF); USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_Parity = USART_Parity_No; @@ -68,9 +84,14 @@ int bt_open() NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); + GPIO_SetBits(BT_UART_GPIO_PORT_BRTS, BT_UART_GPIO_PIN_BRTS); + GPIO_ResetBits(BT_UART_GPIO_PORT_EN, BT_UART_GPIO_PIN_EN); // open bluetooth + return 0; } +uint8_t bt_state = 0; + extern "C" void USART6_IRQHandler(void) { #if 1 @@ -90,6 +111,8 @@ extern "C" void USART6_IRQHandler(void) } else { USART_ITConfig(BT_UART, USART_IT_TXE, DISABLE); + GPIO_SetBits(BT_UART_GPIO_PORT_BRTS, BT_UART_GPIO_PIN_BRTS); + bt_state = 0; } } #endif @@ -101,10 +124,23 @@ int bt_write(const void *buffer, int len) for (int i=0; i