diff --git a/companion/src/burndialog.cpp b/companion/src/burndialog.cpp index d0c166cfc..b868c2bbe 100644 --- a/companion/src/burndialog.cpp +++ b/companion/src/burndialog.cpp @@ -519,7 +519,7 @@ void burnDialog::on_BurnFlashButton_clicked() byte8u=(uint8_t)BeeperSet.mid(0,2).toUInt(&ok,16); if (ok) - radioData.generalSettings.beeperMode=(BeeperMode)byte8u; + radioData.generalSettings.beeperMode=(GeneralSettings::BeeperMode)byte8u; byte8=(int8_t)BeeperSet.mid(2,2).toInt(&ok,16); if (ok) @@ -527,7 +527,7 @@ void burnDialog::on_BurnFlashButton_clicked() byte8u=(uint8_t)HapticSet.mid(0,2).toUInt(&ok,16); if (ok) - radioData.generalSettings.hapticMode=(BeeperMode)byte8u; + radioData.generalSettings.hapticMode=(GeneralSettings::BeeperMode)byte8u; byte8u=(uint8_t)HapticSet.mid(2,2).toUInt(&ok,16); if (ok) diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index 3d88ba9ee..fd0cf0d1f 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -15,7 +15,7 @@ std::list EEPROMWarnings; const char * switches9X[] = { "3POS", "THR", "RUD", "ELE", "AIL", "GEA", "TRN" }; -const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH" }; +const char * switchesX9D[] = { "SA", "SB", "SC", "SD", "SE", "SF", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN" }; const char leftArrow[] = {(char)0xE2, (char)0x86, (char)0x90, 0}; const char rightArrow[] = {(char)0xE2, (char)0x86, (char)0x92, 0}; const char upArrow[] = {(char)0xE2, (char)0x86, (char)0x91, 0}; @@ -531,6 +531,12 @@ QString RawSwitch::toString() SwitchUp('F'), SwitchDn('F'), SwitchUp('G'), QString::fromUtf8("SG-"), SwitchDn('G'), SwitchUp('H'), SwitchDn('H'), + SwitchUp('I'), SwitchDn('I'), + SwitchUp('J'), SwitchDn('J'), + SwitchUp('K'), SwitchDn('K'), + SwitchUp('L'), SwitchDn('L'), + SwitchUp('M'), SwitchDn('M'), + SwitchUp('N'), SwitchDn('N'), }; static const QString logicalSwitches[] = { @@ -976,6 +982,33 @@ void LimitData::clear() max = +1000; } +GeneralSettings::SwitchInfo GeneralSettings::switchInfoFromSwitchPositionTaranis(unsigned int index) +{ + if (index <= 3*5) + return SwitchInfo((index-1)/3, (index-1)%3); + else if (index <= 17) + return SwitchInfo(5, index==17 ? 2 : 0); + else if (index <= 20) + return SwitchInfo(6, index-18); + else + return SwitchInfo(7+(index-21)/2, 2*((index-21)%2)); +} + +bool GeneralSettings::switchPositionAllowedTaranis(int index) const +{ + if (index == 0) + return true; + SwitchInfo info = switchInfoFromSwitchPositionTaranis(abs(index)); + if (index < 0 && switchConfigTaranis(info.index) != SWITCH_3POS) + return false; + else if (info.index >= 8) + return switchConfigTaranis(info.index-8) == SWITCH_2x2POS; + else if (info.position == 1) + return switchConfigTaranis(info.index) == SWITCH_3POS; + else + return true; +} + GeneralSettings::GeneralSettings() { memset(this, 0, sizeof(GeneralSettings)); diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index ac3981217..766b51738 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -126,7 +126,14 @@ enum Switches { SWITCH_SG1, SWITCH_SG2, SWITCH_SH0, - SWITCH_SH1 + SWITCH_SH2, + SWITCH_SI0, + SWITCH_SI2, + SWITCH_SJ0, + SWITCH_SJ2, + SWITCH_SK0, + SWITCH_SK2, + }; enum TimerModes { @@ -1007,7 +1014,7 @@ class ModelData { unsigned int thrTraceSrc; unsigned int modelId; unsigned int switchWarningStates; - unsigned int nSwToWarn; + unsigned int switchWarningEnable; unsigned int nPotsToWarn; int potPosition[C9X_NUM_POTS]; bool displayChecklist; @@ -1070,15 +1077,24 @@ class TrainerData { void clear() { memset(this, 0, sizeof(TrainerData)); } }; -enum BeeperMode { - e_quiet = -2, - e_alarms_only = -1, - e_no_keys = 0, - e_all = 1 -}; - class GeneralSettings { public: + + enum BeeperMode { + BEEPER_QUIET = -2, + BEEPER_ALARMS_ONLY = -1, + BEEPER_NOKEYS = 0, + BEEPER_ALL = 1 + }; + + enum SwitchConfig { + SWITCH_DEFAULT, + SWITCH_TOGGLE, + SWITCH_2POS, + SWITCH_3POS, + SWITCH_2x2POS + }; + GeneralSettings(); int getDefaultStick(unsigned int channel) const; @@ -1166,6 +1182,49 @@ class GeneralSettings { unsigned int potsType[8]; unsigned int backlightColor; CustomFunctionData customFn[C9X_MAX_CUSTOM_FUNCTIONS]; + unsigned int switchConfig[8]; + char switchNames[32][3+1]; + char anaNames[32][3+1]; + + struct SwitchInfo { + SwitchInfo(unsigned int index, unsigned int position): + index(index), + position(position) + { + } + unsigned int index; + unsigned int position; + }; + + static SwitchInfo switchInfoFromSwitchPositionTaranis(unsigned int index); + bool switchPositionAllowedTaranis(int index) const; + + static unsigned int switchDefaultConfigTaranis(unsigned int index) + { + if (index == 5) + return SWITCH_2POS; + else if (index == 7) + return SWITCH_TOGGLE; + else + return SWITCH_3POS; + } + + unsigned int switchConfigTaranis(unsigned int index) const + { + unsigned int result = switchConfig[index]; + if (result == SWITCH_DEFAULT) + result = switchDefaultConfigTaranis(index); + return result; + } + + bool isSwitchWarningAllowedTaranis(unsigned int index) const + { + if (index < 8) + return switchConfigTaranis(index) != SWITCH_TOGGLE; + else + return switchConfig[index-8] == SWITCH_2x2POS; + } + }; class RadioData { diff --git a/companion/src/firmwares/er9x/er9xeeprom.cpp b/companion/src/firmwares/er9x/er9xeeprom.cpp index 1cb7d160b..18eadd7f5 100644 --- a/companion/src/firmwares/er9x/er9xeeprom.cpp +++ b/companion/src/firmwares/er9x/er9xeeprom.cpp @@ -85,13 +85,13 @@ Er9xGeneral::operator GeneralSettings () switch (beeperVal) { case 0: - result.beeperMode = e_quiet; + result.beeperMode = GeneralSettings::BEEPER_QUIET; break; case 1: - result.beeperMode = e_no_keys; + result.beeperMode = GeneralSettings::BEEPER_NOKEYS; break; default: - result.beeperMode = e_all; + result.beeperMode = GeneralSettings::BEEPER_ALL; result.beeperLength = beeperVal - 4; break; } diff --git a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp index 7598e1fe4..7096a1ded 100644 --- a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp @@ -105,13 +105,13 @@ Ersky9xGeneral::operator GeneralSettings () switch (beeperVal) { case 0: - result.beeperMode = e_quiet; + result.beeperMode = GeneralSettings::BEEPER_QUIET; break; case 1: - result.beeperMode = e_no_keys; + result.beeperMode = GeneralSettings::BEEPER_NOKEYS; break; default: - result.beeperMode = e_all; + result.beeperMode = GeneralSettings::BEEPER_ALL; result.beeperLength = beeperVal - 4; break; } diff --git a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp index 222b6237c..7beb76611 100644 --- a/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp +++ b/companion/src/firmwares/gruvin9x/gruvin9xeeprom.cpp @@ -88,13 +88,13 @@ Gruvin9xGeneral_v103::operator GeneralSettings () switch (beeperVal) { case 0: - result.beeperMode = e_quiet; + result.beeperMode = GeneralSettings::BEEPER_QUIET; break; case 1: - result.beeperMode = e_no_keys; + result.beeperMode = GeneralSettings::BEEPER_NOKEYS; break; default: - result.beeperMode = e_all; + result.beeperMode = GeneralSettings::BEEPER_ALL; result.beeperLength = beeperVal - 4; break; } @@ -142,7 +142,7 @@ Gruvin9xGeneral_v104::operator GeneralSettings () result.view = view; result.disableThrottleWarning = disableThrottleWarning; result.switchWarning = switchWarning; - result.beeperMode = (BeeperMode)beeperVal; + result.beeperMode = (GeneralSettings::BeeperMode)beeperVal; result.disableMemoryWarning = disableMemoryWarning; result.disableAlarmWarning = disableAlarmWarning; result.stickMode = stickMode; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index d839b2dc6..aa046575f 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -12,8 +12,8 @@ #define HAS_LARGE_LCD(board) IS_TARANIS(board) #define MAX_VIEWS(board) (HAS_LARGE_LCD(board) ? 2 : 256) #define MAX_POTS(board) (IS_TARANIS(board) ? 5 : 3) -#define MAX_SWITCHES(board) (IS_TARANIS(board) ? 8 : 7) -#define MAX_SWITCHES_POSITION(board) (IS_TARANIS(board) ? 22 : 9) +#define MAX_SWITCHES(board, version) (version >= 217 ? (IS_TARANIS(board) ? 8+6 : 7) : (IS_TARANIS(board) ? 8 : 7)) +#define MAX_SWITCHES_POSITION(board, version) (IS_TARANIS(board) ? (version >= 217 ? 22+12 : 22) : 9) #define MAX_ROTARY_ENCODERS(board) (board==BOARD_GRUVIN9X ? 2 : (IS_SKY9X(board) ? 1 : 0)) #define MAX_FLIGHT_MODES(board, version) (IS_ARM(board) ? 9 : (IS_DBLRAM(board, version) ? 6 : 5)) #define MAX_TIMERS(board, version) ((IS_ARM(board) && version >= 217) ? 3 : 2) @@ -56,7 +56,7 @@ class SwitchesConversionTable: public ConversionTable { addConversion(RawSwitch(SWITCH_TYPE_NONE), val++); } - for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) { + for (int i=1; i<=MAX_SWITCHES_POSITION(board, version); i++) { int s = switchIndex(i, board, version); addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val); if (IS_TARANIS(board) && s>=21/*SHup/SHdown*/) { @@ -110,7 +110,7 @@ class SwitchesConversionTable: public ConversionTable { if (version < 216) { // previous "moment" switches - for (int i=1; i<=MAX_SWITCHES_POSITION(board); i++) { + for (int i=1; i<=MAX_SWITCHES_POSITION(board, version); i++) { int s = switchIndex(i, board, version); addConversion(RawSwitch(SWITCH_TYPE_SWITCH, s), val++); } @@ -241,7 +241,7 @@ class SourcesConversionTable: public ConversionTable { if (!(flags & FLAG_NOSWITCHES)) { if (afterrelease21March2013) { - for (int i=1; i(modelData.modelId)); } - if (IS_TARANIS(board)) + if (IS_TARANIS(board) && version >= 217) + internalField.Append(new SwitchesWarningField<32>(modelData.switchWarningStates, board, version)); + else if (IS_TARANIS(board)) internalField.Append(new SwitchesWarningField<16>(modelData.switchWarningStates, board, version)); else internalField.Append(new SwitchesWarningField<8>(modelData.switchWarningStates, board, version)); - if (version >= 216) { - internalField.Append(new UnsignedField<8>(modelData.nSwToWarn)); - } + + if (IS_TARANIS(board) && version >= 217) + internalField.Append(new UnsignedField<16>(modelData.switchWarningEnable)); + else if (version >= 216) + internalField.Append(new UnsignedField<8>(modelData.switchWarningEnable)); if ((board == BOARD_STOCK || (board == BOARD_M128 && version >= 215)) && (variant & GVARS_VARIANT)) { for (int i=0; i(generalData.backlightColor)); } - if (version >= 216) { - internalField.Append(new SpareBitsField<16>()); + + if (IS_TARANIS(board)) { + if (version >= 217) + internalField.Append(new SpareBitsField<32>()); + else + internalField.Append(new SpareBitsField<16>()); } + if (version >= 217) { for (int i=0; i= 217) { + for (int i=0; i<8; i++) { + internalField.Append(new UnsignedField<4>(generalData.switchConfig[i])); + } + for (int i=0; i(generalData.switchNames[i])); + } + for (int i=0; i(generalData.anaNames[i])); + } + } } } diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index bfca15a82..f0bc7d557 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -571,9 +571,9 @@ int OpenTxFirmware::getCapability(const Capability capability) case Pots: return (IS_TARANIS(board) ? 5 : 3); case Switches: - return (IS_TARANIS(board) ? 8 : 7); + return (IS_TARANIS(board) ? 8+6 : 7); case SwitchesPositions: - return (IS_TARANIS(board) ? 22 : 9); + return (IS_TARANIS(board) ? 22+12 : 9); case CustomFunctions: if (IS_TARANIS(board)) return 64; diff --git a/companion/src/firmwares/th9x/th9xeeprom.cpp b/companion/src/firmwares/th9x/th9xeeprom.cpp index 76bc9851a..2a5e2d09e 100644 --- a/companion/src/firmwares/th9x/th9xeeprom.cpp +++ b/companion/src/firmwares/th9x/th9xeeprom.cpp @@ -71,16 +71,16 @@ Th9xGeneral::operator GeneralSettings () result.disableMemoryWarning = disableMemoryWarning; switch (beeperVal) { case 0: - result.beeperMode = e_quiet; + result.beeperMode = GeneralSettings::BEEPER_QUIET; break; case 1: - result.beeperMode = e_no_keys; + result.beeperMode = GeneralSettings::BEEPER_NOKEYS; break; case 2: - result.beeperMode = e_all; + result.beeperMode = GeneralSettings::BEEPER_ALL; break; case 3: - result.beeperMode = e_all; + result.beeperMode = GeneralSettings::BEEPER_ALL; result.beeperLength = 2; } result.stickMode = stickMode; diff --git a/companion/src/generaledit/calibration.cpp b/companion/src/generaledit/calibration.cpp index 1c8120cc7..ccbdf60ef 100644 --- a/companion/src/generaledit/calibration.cpp +++ b/companion/src/generaledit/calibration.cpp @@ -20,6 +20,93 @@ CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSe ui->pot2TypeLabel->hide(); ui->pot3Type->hide(); ui->pot3TypeLabel->hide(); + ui->pot4Label->hide(); + ui->pot5Label->hide(); + } + + if (IS_TARANIS(firmware->getBoard())) { + ui->rudName->setField(generalSettings.anaNames[0], 3, this); + ui->eleName->setField(generalSettings.anaNames[1], 3, this); + ui->thrName->setField(generalSettings.anaNames[2], 3, this); + ui->ailName->setField(generalSettings.anaNames[3], 3, this); + ui->pot1Name->setField(generalSettings.anaNames[4], 3, this); + ui->pot2Name->setField(generalSettings.anaNames[5], 3, this); + ui->pot3Name->setField(generalSettings.anaNames[6], 3, this); + ui->pot4Name->setField(generalSettings.anaNames[7], 3, this); + ui->pot5Name->setField(generalSettings.anaNames[8], 3, this); + ui->saName->setField(generalSettings.switchNames[0], 3, this); + ui->saType->setField(generalSettings.switchConfig[0], this); + ui->sbName->setField(generalSettings.switchNames[1], 3, this); + ui->sbType->setField(generalSettings.switchConfig[1], this); + ui->scName->setField(generalSettings.switchNames[2], 3, this); + ui->scType->setField(generalSettings.switchConfig[2], this); + ui->sdName->setField(generalSettings.switchNames[3], 3, this); + ui->sdType->setField(generalSettings.switchConfig[3], this); + ui->seName->setField(generalSettings.switchNames[4], 3, this); + ui->seType->setField(generalSettings.switchConfig[4], this); + ui->sfName->setField(generalSettings.switchNames[5], 3, this); + ui->sfType->setField(generalSettings.switchConfig[5], this); + ui->sgName->setField(generalSettings.switchNames[6], 3, this); + ui->sgType->setField(generalSettings.switchConfig[6], this); + ui->shName->setField(generalSettings.switchNames[7], 3, this); + ui->shType->setField(generalSettings.switchConfig[7], this); + ui->siName->setField(generalSettings.switchNames[8], 3, this); + ui->sjName->setField(generalSettings.switchNames[9], 3, this); + ui->skName->setField(generalSettings.switchNames[10], 3, this); + ui->slName->setField(generalSettings.switchNames[11], 3, this); + ui->smName->setField(generalSettings.switchNames[12], 3, this); + ui->snName->setField(generalSettings.switchNames[13], 3, this); + connect(ui->saType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); + connect(ui->sbType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); + connect(ui->scType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); + connect(ui->sdType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); + connect(ui->seType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); + connect(ui->sgType, SIGNAL(currentIndexChanged(int)), this, SLOT(update())); + } + else { + ui->rudLabel->hide(); + ui->rudName->hide(); + ui->eleLabel->hide(); + ui->eleName->hide(); + ui->thrLabel->hide(); + ui->thrName->hide(); + ui->ailLabel->hide(); + ui->ailName->hide(); + ui->pot1Name->hide(); + ui->pot2Name->hide(); + ui->pot3Name->hide(); + ui->pot4Name->hide(); + ui->pot5Name->hide(); + ui->saLabel->hide(); + ui->saName->hide(); + ui->saType->hide(); + ui->sbLabel->hide(); + ui->sbName->hide(); + ui->sbType->hide(); + ui->scLabel->hide(); + ui->scName->hide(); + ui->scType->hide(); + ui->sdLabel->hide(); + ui->sdName->hide(); + ui->sdType->hide(); + ui->seLabel->hide(); + ui->seName->hide(); + ui->seType->hide(); + ui->sfLabel->hide(); + ui->sfName->hide(); + ui->sfType->hide(); + ui->sgLabel->hide(); + ui->sgName->hide(); + ui->sgType->hide(); + ui->shLabel->hide(); + ui->shName->hide(); + ui->shType->hide(); + ui->siName->hide(); + ui->sjName->hide(); + ui->skName->hide(); + ui->slName->hide(); + ui->smName->hide(); + ui->snName->hide(); } int potsCount = GetCurrentFirmware()->getCapability(Pots); @@ -46,6 +133,22 @@ CalibrationPanel::~CalibrationPanel() delete ui; } +void CalibrationPanel::update() +{ + ui->siLabel->setVisible(generalSettings.switchConfig[0] == GeneralSettings::SWITCH_2x2POS); + ui->siName->setVisible(generalSettings.switchConfig[0] == GeneralSettings::SWITCH_2x2POS); + ui->sjLabel->setVisible(generalSettings.switchConfig[1] == GeneralSettings::SWITCH_2x2POS); + ui->sjName->setVisible(generalSettings.switchConfig[1] == GeneralSettings::SWITCH_2x2POS); + ui->skLabel->setVisible(generalSettings.switchConfig[2] == GeneralSettings::SWITCH_2x2POS); + ui->skName->setVisible(generalSettings.switchConfig[2] == GeneralSettings::SWITCH_2x2POS); + ui->slLabel->setVisible(generalSettings.switchConfig[3] == GeneralSettings::SWITCH_2x2POS); + ui->slName->setVisible(generalSettings.switchConfig[3] == GeneralSettings::SWITCH_2x2POS); + ui->smLabel->setVisible(generalSettings.switchConfig[4] == GeneralSettings::SWITCH_2x2POS); + ui->smName->setVisible(generalSettings.switchConfig[4] == GeneralSettings::SWITCH_2x2POS); + ui->snLabel->setVisible(generalSettings.switchConfig[6] == GeneralSettings::SWITCH_2x2POS); + ui->snName->setVisible(generalSettings.switchConfig[6] == GeneralSettings::SWITCH_2x2POS); +} + void CalibrationPanel::on_PPM_MultiplierDSB_editingFinished() { generalSettings.PPM_Multiplier = (int)(ui->PPM_MultiplierDSB->value()*10)-10; diff --git a/companion/src/generaledit/calibration.h b/companion/src/generaledit/calibration.h index 0135ce121..e89a058b9 100644 --- a/companion/src/generaledit/calibration.h +++ b/companion/src/generaledit/calibration.h @@ -14,6 +14,7 @@ class CalibrationPanel : public GeneralPanel public: CalibrationPanel(QWidget *parent, GeneralSettings & generalSettings, FirmwareInterface * firmware); virtual ~CalibrationPanel(); + virtual void update(); private slots: void on_battCalibDSB_editingFinished(); @@ -52,10 +53,10 @@ class CalibrationPanel : public GeneralPanel void on_ana7Pos_editingFinished(); void on_ana8Pos_editingFinished(); - void on_pot1Type_currentIndexChanged(int index); void on_pot2Type_currentIndexChanged(int index); void on_pot3Type_currentIndexChanged(int index); + void on_serialPortMode_currentIndexChanged(int index); private: diff --git a/companion/src/generaledit/calibration.ui b/companion/src/generaledit/calibration.ui index a5b0cdece..1de906f85 100644 --- a/companion/src/generaledit/calibration.ui +++ b/companion/src/generaledit/calibration.ui @@ -6,14 +6,340 @@ 0 0 - 780 - 450 + 802 + 1036 Form - + + + + + + + + + + + Beeper volume + +0 - Quiet. No beeps at all. +1 - No Keys. Normal beeps but menu keys do not beep. +2 - Normal. +3 - Loud. +4 - Extra loud. + + + + None + + + + + Pot with detent (normal) + + + + + Multipos Switch + + + + + Pot without detent + + + + + + + + 3 + + + + + + + RS + + + + + + + SB + + + + + + + Serial Port + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 3 + + + + + + + + + + + + + Beeper volume + +0 - Quiet. No beeps at all. +1 - No Keys. Normal beeps but menu keys do not beep. +2 - Normal. +3 - Loud. +4 - Extra loud. + + + + Default + + + + + 2POS Toggle + + + + + 2POS + + + + + 3POS + + + + + 2x2POS + + + + + + + + + 0 + 10 + + + + Qt::Horizontal + + + + + + + + + + + + + Beeper volume + +0 - Quiet. No beeps at all. +1 - No Keys. Normal beeps but menu keys do not beep. +2 - Normal. +3 - Loud. +4 - Extra loud. + + + + None + + + + + Pot with detent (normal) + + + + + Multipos Switch + + + + + Pot without detent + + + + + + + + + + + + + + Beeper volume + +0 - Quiet. No beeps at all. +1 - No Keys. Normal beeps but menu keys do not beep. +2 - Normal. +3 - Loud. +4 - Extra loud. + + + + Default + + + + + 2POS Toggle + + + + + 2POS + + + + + 3POS + + + + + 2x2POS + + + + + + + + + OFF + + + + + S-Port Mirror + + + + + Telemetry + + + + + SBUS Trainer + + + + + Debug + + + + + + + + + + + + + + Beeper volume + +0 - Quiet. No beeps at all. +1 - No Keys. Normal beeps but menu keys do not beep. +2 - Normal. +3 - Loud. +4 - Extra loud. + + + + None + + + + + Pot with detent (normal) + + + + + Multipos Switch + + + + + Pot without detent + + + + + + + + 3 + + + + + + + 3 + + + + + + + 3 + + + + + + + Rud + + + + + + + + + + -9999 + + + 9999 + + + @@ -75,20 +401,7 @@ - - - - 1 - - - 5.000000000000000 - - - 1.000000000000000 - - - - + PPM 1 @@ -168,16 +481,10 @@ - - - - - - - -9999 - - - 9999 + + + + PPM 2 @@ -315,27 +622,14 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - - + Battery - + @@ -357,39 +651,14 @@ - + PPM Multiplier - - - - - 0 - 0 - - - - - 0 - 10 - - - - QFrame::Sunken - - - 1 - - - Qt::Horizontal - - - - + @@ -408,7 +677,7 @@ - + @@ -427,7 +696,7 @@ - + @@ -446,7 +715,7 @@ - + @@ -465,41 +734,21 @@ - - - - PPM 2 - - - - + PPM 3 - + PPM 4 - - - - - 0 - 10 - - - - Qt::Horizontal - - - - + -49 @@ -509,7 +758,7 @@ - + Current @@ -689,107 +938,113 @@ - - - - - - - - - - Beeper volume - -0 - Quiet. No beeps at all. -1 - No Keys. Normal beeps but menu keys do not beep. -2 - Normal. -3 - Loud. -4 - Extra loud. - - - - None - - - - - Pot with detent (normal) - - - - - Multipos Switch - - - - - Pot without detent - - - - - + - S1 Type + S1 - - - - + + + + S2 - - + + + + + + S3 - - Beeper volume - -0 - Quiet. No beeps at all. -1 - No Keys. Normal beeps but menu keys do not beep. -2 - Normal. -3 - Loud. -4 - Extra loud. + + + + + + 3 + + + + + + + SA - - - None - - - - - Pot with detent (normal) - - - - - Multipos Switch - - - - - Pot without detent - - - + - S2 Type + Ele + + + + + + + Ail - + - S3 Type + Thr + + + + + + + 3 + + + + + + + 3 - + + + 3 + + + + + + + SC + + + + + + + LS + + + + + + + 3 + + + + + + + 3 + + + + + @@ -797,77 +1052,439 @@ - Beeper volume - -0 - Quiet. No beeps at all. -1 - No Keys. Normal beeps but menu keys do not beep. -2 - Normal. -3 - Loud. -4 - Extra loud. + - None + Default - Pot with detent (normal) + 2POS Toggle - Multipos Switch + 2POS - Pot without detent + 3POS + + + + + 2x2POS - - - - - OFF - - - - - S-Port Mirror - - - - - Telemetry - - - - - SBUS Trainer - - - - - Debug - - + + + + 3 + - - + + - Serial Port + SD - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + Default + + + + + 2POS Toggle + + + + + 2POS + + + + + 3POS + + + + + 2x2POS + + + + + + + + 3 + + + + + + + SE + + + + + + + + + + + + + + + + + Default + + + + + 2POS Toggle + + + + + 2POS + + + + + 3POS + + + + + 2x2POS + + + + + + + + 3 + + + + + + + SF + + + + + + + + + + + + + + + + + Default + + + + + 2POS Toggle + + + + + 2POS + + + + + 3POS + + + + + 2x2POS + + + + + + + + 3 + + + + + + + SG + + + + + + + + + + + + + + + + + Default + + + + + 2POS Toggle + + + + + 2POS + + + + + 3POS + + + + + 2x2POS + + + + + + + + 3 + + + + + + + SH + + + + + + + + + + + + + + + + + Default + + + + + 2POS Toggle + + + + + 2POS + + + + + 3POS + + + + + 2x2POS + + + + + + + + 3 + + + + + + + SI + + + + + + + 3 + + + + + + + SJ + + + + + + + 3 + + + + + + + SK + + + + + + + 3 + + + + + + + SL + + + + + + + 3 + + + + + + + SM + + + + + + + 3 + + + + + + + SN + + + + + + + 3 + + + + + + + 1 + + + 5.000000000000000 + + + 1.000000000000000 + + + + + + + + 0 + 10 + + + + Qt::Horizontal + + + + + + + + 0 + 10 + + + + Qt::Horizontal + + + AutoLineEdit + QLineEdit +
autolineedit.h
+
+ + AutoComboBox + QComboBox +
autocombobox.h
+
+
diff --git a/companion/src/generaledit/generaledit.cpp b/companion/src/generaledit/generaledit.cpp index 9d4fb77d7..4c3ab0a87 100644 --- a/companion/src/generaledit/generaledit.cpp +++ b/companion/src/generaledit/generaledit.cpp @@ -142,13 +142,13 @@ void GeneralEdit::on_calretrieve_PB_clicked() generalSettings.backlightBright=byte8u; byte8=(int8_t)BeeperSet.mid(0,2).toUInt(&ok,16); if (ok) - generalSettings.beeperMode=(BeeperMode)byte8; + generalSettings.beeperMode = (GeneralSettings::BeeperMode)byte8; byte8=(int8_t)BeeperSet.mid(2,2).toInt(&ok,16); if (ok) generalSettings.beeperLength=byte8; byte8=(int8_t)HapticSet.mid(0,2).toUInt(&ok,16); if (ok) - generalSettings.hapticMode=(BeeperMode)byte8; + generalSettings.hapticMode=(GeneralSettings::BeeperMode)byte8; byte8=(int8_t)HapticSet.mid(2,2).toInt(&ok,16); if (ok) generalSettings.hapticStrength=byte8; diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index 9a839615e..d1f2fd370 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -553,7 +553,7 @@ void GeneralSetupPanel::on_alarmwarnChkB_stateChanged(int ) void GeneralSetupPanel::on_beeperCB_currentIndexChanged(int index) { - generalSettings.beeperMode = (BeeperMode)(index-2); + generalSettings.beeperMode = (GeneralSettings::BeeperMode)(index-2); emit modified(); } @@ -565,7 +565,7 @@ void GeneralSetupPanel::on_displayTypeCB_currentIndexChanged(int index) void GeneralSetupPanel::on_hapticmodeCB_currentIndexChanged(int index) { - generalSettings.hapticMode = (BeeperMode)(index-2); + generalSettings.hapticMode = (GeneralSettings::BeeperMode)(index-2); emit modified(); } diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index f04d8eb3c..896ff2e98 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -412,11 +412,9 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin } for (int i=-GetCurrentFirmware()->getCapability(SwitchesPositions); i<0; i++) { + if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i)) + continue; item = RawSwitch(SWITCH_TYPE_SWITCH, i); - if (IS_TARANIS(GetCurrentFirmware()->getBoard())) { - //hide up and down for !SH and !SF, because they are redundant (!SFup == SFdown) - if (item.toString().contains("H") || item.toString().contains("F")) continue; - } b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); } @@ -435,6 +433,8 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin } for (int i=1; i<=GetCurrentFirmware()->getCapability(SwitchesPositions); i++) { + if (IS_TARANIS(GetCurrentFirmware()->getBoard()) && !generalSettings.switchPositionAllowedTaranis(i)) + continue; item = RawSwitch(SWITCH_TYPE_SWITCH, i); b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1); diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index 920041c31..4dbfe3fcb 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -453,15 +453,22 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool))); centerBeepCheckboxes << checkbox; if (!IS_TARANIS_PLUS(board) && i==6) { - checkbox->hide(); + checkbox->hide(); } } // Startup switches warnings - for (int i=0; igetCapability(Switches)-1; i++) { + for (int i=0; igetCapability(Switches); i++) { + if (!IS_TARANIS(firmware->getBoard()) && i==firmware->getCapability(Switches)-1) + continue; QLabel * label = new QLabel(this); QSlider * slider = new QSlider(this); QCheckBox * cb = new QCheckBox(this); + if (IS_TARANIS(firmware->getBoard()) && !generalSettings.isSwitchWarningAllowedTaranis(i)) { + label->hide(); + slider->hide(); + cb->hide(); + } slider->setProperty("index", i+1); slider->setOrientation(Qt::Vertical); slider->setMinimum(0); @@ -474,7 +481,7 @@ SetupPanel::SetupPanel(QWidget *parent, ModelData & model, GeneralSettings & gen slider->setMaximumSize(QSize(50, 50)); if (IS_TARANIS(board)) { label->setText(switchesX9D[i]); - slider->setMaximum(i==5 ? 1 : 2); + slider->setMaximum((i==5 || i>=7) ? 1 : 2); } else { label->setText(switches9X[i]); @@ -677,17 +684,21 @@ void SetupPanel::updateStartupSwitches() unsigned int switchStates = model->switchWarningStates; - for (int i=0; igetCapability(Switches)-1; i++) { + for (int i=0; igetCapability(Switches); i++) { QSlider * slider = startupSwitchesSliders[i]; QCheckBox * cb = startupSwitchesCheckboxes[i]; - bool enabled = !(model->nSwToWarn & (1 << i)); + bool enabled = !(model->switchWarningEnable & (1 << i)); slider->setEnabled(enabled); cb->setChecked(enabled); if (IS_TARANIS(GetEepromInterface()->getBoard())) { - slider->setValue(i==5 ? (switchStates & 0x3)/2 : switchStates & 0x3); + slider->setValue((i==5 || i>=7) ? (switchStates & 0x3)/2 : switchStates & 0x3); switchStates >>= 2; } else { + if (i == firmware->getCapability(Switches)-1) { + // Trainer switch, no switch warning + continue; + } slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1); switchStates >>= (i==0 ? 2 : 1); } @@ -704,7 +715,7 @@ void SetupPanel::startupSwitchEdited(int value) int index = sender()->property("index").toInt(); if (IS_TARANIS(GetEepromInterface()->getBoard())) { - if (index == 6) { + if (index == 6 || index >= 8) { shift = (index - 1) * 2; mask = 0x02 << shift; shift++; @@ -741,9 +752,9 @@ void SetupPanel::startupSwitchToggled(bool checked) int index = sender()->property("index").toInt()-1; if (checked) - model->nSwToWarn &= ~(1 << index); + model->switchWarningEnable &= ~(1 << index); else - model->nSwToWarn |= (1 << index); + model->switchWarningEnable |= (1 << index); updateStartupSwitches(); emit modified(); diff --git a/companion/src/shared/CMakeLists.txt b/companion/src/shared/CMakeLists.txt index 4fc2266f7..b5582ad6d 100644 --- a/companion/src/shared/CMakeLists.txt +++ b/companion/src/shared/CMakeLists.txt @@ -12,6 +12,7 @@ set(shared_HDRS autocombobox.h autodoublespinbox.h autohexspinbox.h + autolineedit.h genericpanel.h hexspinbox.h verticalscrollarea.h diff --git a/companion/src/shared/autocombobox.h b/companion/src/shared/autocombobox.h index ad370d83b..d106359af 100644 --- a/companion/src/shared/autocombobox.h +++ b/companion/src/shared/autocombobox.h @@ -2,7 +2,7 @@ #define AUTOCOMBOBOX_H_ #include -#include "modeledit/modeledit.h" +#include "genericpanel.h" class AutoComboBox: public QComboBox { @@ -35,7 +35,7 @@ class AutoComboBox: public QComboBox lock = false; } - void setField(unsigned int & field, ModelPanel * panel=NULL) + void setField(unsigned int & field, GenericPanel * panel=NULL) { this->field = (int *)&field; this->panel = panel; @@ -46,7 +46,7 @@ class AutoComboBox: public QComboBox } } - void setField(int & field, ModelPanel * panel=NULL) + void setField(int & field, GenericPanel * panel=NULL) { this->field = &field; this->panel = panel; @@ -70,7 +70,7 @@ class AutoComboBox: public QComboBox protected: int * field; - ModelPanel * panel; + GenericPanel * panel; bool lock; }; diff --git a/companion/src/shared/autolineedit.h b/companion/src/shared/autolineedit.h new file mode 100755 index 000000000..154dd55e6 --- /dev/null +++ b/companion/src/shared/autolineedit.h @@ -0,0 +1,60 @@ +#ifndef AUTOLINEEDIT_H_ +#define AUTOLINEEDIT_H_ + +#include +#include +#include "genericpanel.h" + +#define CHAR_FOR_NAMES_REGEX "[ A-Za-z0-9_.-,]*" + +class AutoLineEdit: public QLineEdit +{ + Q_OBJECT + + public: + explicit AutoLineEdit(QWidget *parent = 0): + QLineEdit(parent), + field(NULL), + panel(NULL), + lock(false) + { + QRegExp rx(CHAR_FOR_NAMES_REGEX); + setValidator(new QRegExpValidator(rx, this)); + connect(this, SIGNAL(editingFinished()), this, SLOT(onEdited())); + } + + void setField(char * field, int len, GenericPanel * panel=NULL) + { + this->field = field; + this->panel = panel; + setMaxLength(len); + updateValue(); + } + + void updateValue() + { + lock = true; + if (field) { + setText(field); + } + lock = false; + } + + protected slots: + void onEdited() + { + if (field && !lock) { + strcpy(field, text().toAscii()); + if (panel) { + emit panel->modified(); + } + } + } + + protected: + char * field; + GenericPanel * panel; + bool lock; +}; + +#endif /* AUTOLINEEDIT_H_ */ diff --git a/companion/src/shared/genericpanel.h b/companion/src/shared/genericpanel.h index eafb27c34..26983e634 100644 --- a/companion/src/shared/genericpanel.h +++ b/companion/src/shared/genericpanel.h @@ -17,6 +17,7 @@ class GenericPanel : public QWidget friend class AutoDoubleSpinBox; friend class AutoCheckBox; friend class AutoHexSpinBox; + friend class AutoLineEdit; public: GenericPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, FirmwareInterface * firmware); diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 2ed72a5b8..ab929420a 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -90,6 +90,20 @@ #define AVR_FIELD(x) x; #endif +#if defined(PCBSTD) + #define N_PCBSTD_FIELD(x) +#else + #define N_PCBSTD_FIELD(x) x; +#endif + +#if defined(PCBTARANIS) + #define N_TARANIS_FIELD(x) + #define TARANIS_FIELD(x) x; +#else + #define N_TARANIS_FIELD(x) x; + #define TARANIS_FIELD(x) +#endif + #define NUM_STICKS 4 #if defined(PCBTARANIS) @@ -623,18 +637,6 @@ enum SwitchConfig { #define LEN_SWITCH_NAME 3 #define LEN_ANA_NAME 3 -#if defined(PCBSTD) - #define N_PCBSTD_FIELD(x) -#else - #define N_PCBSTD_FIELD(x) x; -#endif - -#if defined(PCBTARANIS) - #define N_TARANIS_FIELD(x) -#else - #define N_TARANIS_FIELD(x) x; -#endif - #define ALTERNATE_VIEW 0x10 PACK(typedef struct t_EEGeneral { uint8_t version; @@ -681,15 +683,15 @@ PACK(typedef struct t_EEGeneral { EXTRA_GENERAL_FIELDS - ARM_FIELD(swarnstate_t switchUnlockStates) + TARANIS_FIELD(swarnstate_t switchUnlockStates) ARM_FIELD(CustomFunctionData customFn[NUM_CFN]) - ARM_FIELD(uint32_t switchConfig) + TARANIS_FIELD(uint32_t switchConfig) - ARM_FIELD(char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]) + TARANIS_FIELD(char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]) - ARM_FIELD(char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]) + TARANIS_FIELD(char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]) }) EEGeneral;