diff --git a/companion/src/firmwares/er9x/er9xeeprom.cpp b/companion/src/firmwares/er9x/er9xeeprom.cpp index 3e75cb501..d889b2fa5 100644 --- a/companion/src/firmwares/er9x/er9xeeprom.cpp +++ b/companion/src/firmwares/er9x/er9xeeprom.cpp @@ -138,7 +138,6 @@ Er9xGeneral::operator GeneralSettings () result.speakerPitch = speakerPitch; result.hapticStrength = hapticStrength - 3; result.speakerMode = speakerMode; - result.switchWarningStates =switchWarningStates; return result; } diff --git a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp index 48d24cba6..6c57766de 100644 --- a/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp +++ b/companion/src/firmwares/ersky9x/ersky9xeeprom.cpp @@ -150,7 +150,6 @@ Ersky9xGeneral::operator GeneralSettings () result.speakerPitch = speakerPitch; result.hapticStrength = hapticStrength - 3; result.speakerMode = speakerMode; - result.switchWarningStates = switchWarningStates; result.speakerVolume = volume; result.backlightBright = bright ; result.txCurrentCalibration = current_calib; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 74fb888ef..b46da6c53 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -18,12 +18,11 @@ * GNU General Public License for more details. */ -#include -#include #include "helpers.h" #include "opentxeeprom.h" -#include #include "customdebug.h" +#include +#include #define IS_DBLEEPROM(board, version) ((IS_2560(board) || board==BOARD_M128) && version >= 213) // Macro used for Gruvin9x board and M128 board between versions 213 and 214 (when there were stack overflows!) @@ -3417,22 +3416,36 @@ void OpenTxModelData::beforeExport() // qDebug() << QString("before export model") << modelData.name; for (int module=0; module<3; module++) { - if (modelData.moduleData[module].protocol >= PULSES_PXX_XJT_X16 && modelData.moduleData[module].protocol <= PULSES_PXX_XJT_LR12) + if (modelData.moduleData[module].protocol >= PULSES_PXX_XJT_X16 && modelData.moduleData[module].protocol <= PULSES_PXX_XJT_LR12) { subprotocols[module] = modelData.moduleData[module].protocol - PULSES_PXX_XJT_X16; - else if (modelData.moduleData[module].protocol >= PULSES_LP45 && modelData.moduleData[module].protocol <= PULSES_DSMX) + } + else if (modelData.moduleData[module].protocol >= PULSES_LP45 && modelData.moduleData[module].protocol <= PULSES_DSMX) { subprotocols[module] = modelData.moduleData[module].protocol - PULSES_LP45; + } else if (modelData.moduleData[module].protocol == PULSES_MULTIMODULE) { // copy multi settings to ppm settings to get them written to the eeprom // (reverse the int => ms logic of the ppm delay) since only ppm is written - subprotocols[module] = modelData.moduleData[module].multi.rfProtocol & (0x1f); int multiByte = ((modelData.moduleData[module].multi.rfProtocol >> 4) & 0x03) | (modelData.moduleData[module].multi.customProto << 7); modelData.moduleData[module].ppm.delay = 300 + 50 * multiByte; modelData.moduleData[module].ppm.frameLength = modelData.moduleData[module].multi.optionValue; modelData.moduleData[module].ppm.outputType = modelData.moduleData[module].multi.lowPowerMode; modelData.moduleData[module].ppm.pulsePol = modelData.moduleData[module].multi.autoBindMode; - } else - subprotocols[module] = (module==0 ? -1 : 0); + } + else { + subprotocols[module] = (module == 0 ? -1 : 0); + } + } + + if (IS_HORUS(board)) { + uint32_t newSwitchWarningStates = 0; + for (int i = 0; i < MAX_SWITCHES(board, version); i++) { + uint8_t value = (modelData.switchWarningStates >> (2*i)) & 0x03; + if (!(modelData.switchWarningEnable & (1 << i))) { + newSwitchWarningStates |= (value + 1) << (3*i); + } + } + modelData.switchWarningStates = newSwitchWarningStates; } } @@ -3465,11 +3478,11 @@ void OpenTxModelData::afterImport() modelData.moduleData[module].protocol += subprotocols[module]; else modelData.moduleData[module].protocol = PULSES_OFF; - } else if (modelData.moduleData[module].protocol == PULSES_MULTIMODULE) { + } + else if (modelData.moduleData[module].protocol == PULSES_MULTIMODULE) { // Copy data from ppm struct to multi struct unsigned int multiByte = (unsigned int)((modelData.moduleData[module].ppm.delay - 300) / 50); modelData.moduleData[module].multi.rfProtocol = subprotocols[module] | ((multiByte & 0x3) << 4); - modelData.moduleData[module].multi.customProto = (multiByte & 0x80) == 0x80; modelData.moduleData[module].multi.optionValue = modelData.moduleData[module].ppm.frameLength; modelData.moduleData[module].multi.lowPowerMode = modelData.moduleData[module].ppm.outputType; @@ -3480,6 +3493,18 @@ void OpenTxModelData::afterImport() if (IS_TARANIS(board) && version < 217 && modelData.moduleData[1].protocol != PULSES_OFF) { modelData.moduleData[1].modelId = modelData.moduleData[0].modelId; } + + if (IS_HORUS(board)) { + uint32_t newSwitchWarningStates = 0; + for (int i = 0; i < MAX_SWITCHES(board, version); i++) { + uint8_t value = (modelData.switchWarningStates >> (3*i)) & 0x07; + if (value == 0) + modelData.switchWarningEnable |= (1 << i); + else + newSwitchWarningStates |= ((value & 0x03) - 1) << (2*i); + } + modelData.switchWarningStates = newSwitchWarningStates; + } } OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum board, unsigned int version, unsigned int variant): diff --git a/companion/src/modeledit/modeledit.cpp b/companion/src/modeledit/modeledit.cpp index 429ab3c48..4a32c560d 100644 --- a/companion/src/modeledit/modeledit.cpp +++ b/companion/src/modeledit/modeledit.cpp @@ -122,12 +122,15 @@ void ModelEdit::launchSimulation() { RadioData * simuData = new RadioData(); simuData->generalSettings = generalSettings; + CategoryData category("Models"); + simuData->categories.push_back(category); if (simuData->models.size() == 0) { simuData->models.push_back(model); } else { simuData->models[0] = model; } + simuData->models[0].category = 0; startSimulation(this, *simuData, 0); delete simuData; } diff --git a/companion/src/modeledit/setup.cpp b/companion/src/modeledit/setup.cpp index caec275f2..ce77aa0d6 100644 --- a/companion/src/modeledit/setup.cpp +++ b/companion/src/modeledit/setup.cpp @@ -659,7 +659,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge ui->centerBeepLayout->addWidget(checkbox, 0, i+1); connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool))); centerBeepCheckboxes << checkbox; - if (IS_TARANIS(board)) { + if (IS_HORUS_OR_TARANIS(board)) { RawSource src(SOURCE_TYPE_STICK, i); if (src.isPot() && !generalSettings.isPotAvailable(i-CPN_MAX_STICKS)) { checkbox->hide(); @@ -714,7 +714,7 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge // Pot warnings prevFocus = ui->potWarningMode; - if (IS_TARANIS(board)) { + if (IS_HORUS_OR_TARANIS(board)) { for (int i=0; igetCapability(Pots)+firmware->getCapability(Sliders); i++) { QCheckBox * cb = new QCheckBox(this); cb->setProperty("index", i); @@ -881,7 +881,7 @@ void SetupPanel::update() updateBeepCenter(); updateStartupSwitches(); - if(IS_TARANIS(GetEepromInterface()->getBoard())) { + if(IS_HORUS_OR_TARANIS(GetEepromInterface()->getBoard())) { updatePotWarnings(); } @@ -915,7 +915,7 @@ void SetupPanel::updateStartupSwitches() QCheckBox * cb = startupSwitchesCheckboxes[i]; int index = slider->property("index").toInt(); bool enabled = !(model->switchWarningEnable & (1 << index)); - if (IS_TARANIS(GetEepromInterface()->getBoard())) { + if (IS_HORUS_OR_TARANIS(GetEepromInterface()->getBoard())) { value = (switchStates >> 2*index) & 0x03; if (generalSettings.switchConfig[index] != GeneralSettings::SWITCH_3POS && value == 2) { value = 1; @@ -940,7 +940,7 @@ void SetupPanel::startupSwitchEdited(int value) uint64_t mask; int index = sender()->property("index").toInt(); - if (IS_TARANIS(GetEepromInterface()->getBoard())) { + if (IS_HORUS_OR_TARANIS(GetEepromInterface()->getBoard())) { shift = index * 2; mask = 0x03ul << shift; } @@ -956,7 +956,7 @@ void SetupPanel::startupSwitchEdited(int value) model->switchWarningStates &= ~mask; - if (IS_TARANIS(GetEepromInterface()->getBoard()) && generalSettings.switchConfig[index] != GeneralSettings::SWITCH_3POS) { + if (IS_HORUS_OR_TARANIS(GetEepromInterface()->getBoard()) && generalSettings.switchConfig[index] != GeneralSettings::SWITCH_3POS) { if (value == 1) { value = 2; } diff --git a/companion/src/radiodata.h b/companion/src/radiodata.h index ba2259f01..2de2738f8 100644 --- a/companion/src/radiodata.h +++ b/companion/src/radiodata.h @@ -1193,7 +1193,6 @@ class GeneralSettings { int hapticStrength; unsigned int speakerMode; char ownerName[10+1]; - unsigned int switchWarningStates; int beeperLength; unsigned int gpsFormat; int speakerVolume;