Another fix for #4224

This commit is contained in:
Bertrand Songis
2017-01-18 10:11:47 +01:00
parent 9535e80745
commit 125c301c56
6 changed files with 44 additions and 19 deletions
@@ -138,7 +138,6 @@ Er9xGeneral::operator GeneralSettings ()
result.speakerPitch = speakerPitch;
result.hapticStrength = hapticStrength - 3;
result.speakerMode = speakerMode;
result.switchWarningStates =switchWarningStates;
return result;
}
@@ -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;
+35 -10
View File
@@ -18,12 +18,11 @@
* GNU General Public License for more details.
*/
#include <stdlib.h>
#include <algorithm>
#include "helpers.h"
#include "opentxeeprom.h"
#include <QObject>
#include "customdebug.h"
#include <stdlib.h>
#include <algorithm>
#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):
+3
View File
@@ -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;
}
+6 -6
View File
@@ -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; i<firmware->getCapability(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;
}
-1
View File
@@ -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;