diff --git a/companion/src/eeprominterface.cpp b/companion/src/eeprominterface.cpp index d2b2358eb..33f2651d8 100644 --- a/companion/src/eeprominterface.cpp +++ b/companion/src/eeprominterface.cpp @@ -791,115 +791,122 @@ QString FuncSwData::repeatToString() GeneralSettings::GeneralSettings() { memset(this, 0, sizeof(GeneralSettings)); + contrast = 25; vBatWarn = 90; - for (int i=0; i<(NUM_STICKS+C9X_NUM_POTS ); ++i) { + + for (int i=0; igetBoard())) { + potsType[0] = 1; + potsType[1] = 1; + } + templateSetup = g.profile[g.id()].channelOrder(); stickMode = g.profile[g.id()].defaultMode(); - QString t_calib=g.profile[g.id()].stickPotCalib(); - int potsnum=GetEepromInterface()->getCapability(Pots); - if (t_calib.isEmpty()) { - return; - } - else { - QString t_trainercalib=g.profile[g.id()].trainerCalib(); - int8_t t_vBatCalib=(int8_t)g.profile[g.id()].vBatCalib(); - int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib(); - int8_t t_PPM_Multiplier=(int8_t)g.profile[g.id()].ppmMultiplier(); - uint8_t t_stickMode=(uint8_t)g.profile[g.id()].gsStickMode(); - uint8_t t_vBatWarn=(uint8_t)g.profile[g.id()].vBatWarn(); - QString t_DisplaySet=g.profile[g.id()].display(); - QString t_BeeperSet=g.profile[g.id()].beeper(); - QString t_HapticSet=g.profile[g.id()].haptic(); - QString t_SpeakerSet=g.profile[g.id()].speaker(); - QString t_CountrySet=g.profile[g.id()].countryCode(); + QString t_calib=g.profile[g.id()].stickPotCalib(); + int potsnum=GetEepromInterface()->getCapability(Pots); + if (t_calib.isEmpty()) { + return; + } + else { + QString t_trainercalib=g.profile[g.id()].trainerCalib(); + int8_t t_vBatCalib=(int8_t)g.profile[g.id()].vBatCalib(); + int8_t t_currentCalib=(int8_t)g.profile[g.id()].currentCalib(); + int8_t t_PPM_Multiplier=(int8_t)g.profile[g.id()].ppmMultiplier(); + uint8_t t_stickMode=(uint8_t)g.profile[g.id()].gsStickMode(); + uint8_t t_vBatWarn=(uint8_t)g.profile[g.id()].vBatWarn(); + QString t_DisplaySet=g.profile[g.id()].display(); + QString t_BeeperSet=g.profile[g.id()].beeper(); + QString t_HapticSet=g.profile[g.id()].haptic(); + QString t_SpeakerSet=g.profile[g.id()].speaker(); + QString t_CountrySet=g.profile[g.id()].countryCode(); - if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) { - QString Byte; - int16_t byte16; - bool ok; - for (int i=0; i<(NUM_STICKS+potsnum); i++) { - Byte=t_calib.mid(i*12,4); - byte16=(int16_t)Byte.toInt(&ok,16); - if (ok) - calibMid[i]=byte16; - Byte=t_calib.mid(4+i*12,4); - byte16=(int16_t)Byte.toInt(&ok,16); - if (ok) - calibSpanNeg[i]=byte16; - Byte=t_calib.mid(8+i*12,4); - byte16=(int16_t)Byte.toInt(&ok,16); - if (ok) - calibSpanPos[i]=byte16; - } - for (int i=0; i<4; i++) { - Byte=t_trainercalib.mid(i*4,4); - byte16=(int16_t)Byte.toInt(&ok,16); - if (ok) - trainer.calib[i]=byte16; - } - currentCalib=t_currentCalib; - vBatCalib=t_vBatCalib; - vBatWarn=t_vBatWarn; - PPM_Multiplier=t_PPM_Multiplier; - stickMode = t_stickMode; + if ((t_calib.length()==(NUM_STICKS+potsnum)*12) && (t_trainercalib.length()==16)) { + QString Byte; + int16_t byte16; + bool ok; + for (int i=0; i<(NUM_STICKS+potsnum); i++) { + Byte=t_calib.mid(i*12,4); + byte16=(int16_t)Byte.toInt(&ok,16); + if (ok) + calibMid[i]=byte16; + Byte=t_calib.mid(4+i*12,4); + byte16=(int16_t)Byte.toInt(&ok,16); + if (ok) + calibSpanNeg[i]=byte16; + Byte=t_calib.mid(8+i*12,4); + byte16=(int16_t)Byte.toInt(&ok,16); + if (ok) + calibSpanPos[i]=byte16; } - if ((t_DisplaySet.length()==6) && (t_BeeperSet.length()==4) && (t_HapticSet.length()==6) && (t_SpeakerSet.length()==6)) { - uint8_t byte8u; - int8_t byte8; - bool ok; - byte8=(int8_t)t_DisplaySet.mid(0,2).toInt(&ok,16); + for (int i=0; i<4; i++) { + Byte=t_trainercalib.mid(i*4,4); + byte16=(int16_t)Byte.toInt(&ok,16); if (ok) - optrexDisplay=(byte8==1 ? true : false); - byte8u=(uint8_t)t_DisplaySet.mid(2,2).toUInt(&ok,16); + trainer.calib[i]=byte16; + } + currentCalib=t_currentCalib; + vBatCalib=t_vBatCalib; + vBatWarn=t_vBatWarn; + PPM_Multiplier=t_PPM_Multiplier; + stickMode = t_stickMode; + } + if ((t_DisplaySet.length()==6) && (t_BeeperSet.length()==4) && (t_HapticSet.length()==6) && (t_SpeakerSet.length()==6)) { + uint8_t byte8u; + int8_t byte8; + bool ok; + byte8=(int8_t)t_DisplaySet.mid(0,2).toInt(&ok,16); + if (ok) + optrexDisplay=(byte8==1 ? true : false); + byte8u=(uint8_t)t_DisplaySet.mid(2,2).toUInt(&ok,16); + if (ok) + contrast=byte8u; + byte8u=(uint8_t)t_DisplaySet.mid(4,2).toUInt(&ok,16); + if (ok) + backlightBright=byte8u; + byte8=(int8_t)t_BeeperSet.mid(0,2).toUInt(&ok,16); + if (ok) + beeperMode=(BeeperMode)byte8; + byte8=(int8_t)t_BeeperSet.mid(2,2).toInt(&ok,16); + if (ok) + beeperLength=byte8; + byte8=(int8_t)t_HapticSet.mid(0,2).toUInt(&ok,16); + if (ok) + hapticMode=(BeeperMode)byte8; + byte8u=(uint8_t)t_HapticSet.mid(2,2).toUInt(&ok,16); + if (ok) + hapticStrength=byte8u; + byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16); + if (ok) + hapticLength=byte8; + byte8u=(uint8_t)t_SpeakerSet.mid(0,2).toUInt(&ok,16); + if (ok) + speakerMode=byte8u; + byte8u=(uint8_t)t_SpeakerSet.mid(2,2).toUInt(&ok,16); + if (ok) + speakerPitch=byte8u; + byte8u=(uint8_t)t_SpeakerSet.mid(4,2).toUInt(&ok,16); + if (ok) + speakerVolume=byte8u; + if (t_CountrySet.length()==6) { + byte8u=(uint8_t)t_CountrySet.mid(0,2).toUInt(&ok,16); if (ok) - contrast=byte8u; - byte8u=(uint8_t)t_DisplaySet.mid(4,2).toUInt(&ok,16); + countryCode=byte8u; + byte8u=(uint8_t)t_CountrySet.mid(2,2).toUInt(&ok,16); if (ok) - backlightBright=byte8u; - byte8=(int8_t)t_BeeperSet.mid(0,2).toUInt(&ok,16); - if (ok) - beeperMode=(BeeperMode)byte8; - byte8=(int8_t)t_BeeperSet.mid(2,2).toInt(&ok,16); - if (ok) - beeperLength=byte8; - byte8=(int8_t)t_HapticSet.mid(0,2).toUInt(&ok,16); - if (ok) - hapticMode=(BeeperMode)byte8; - byte8u=(uint8_t)t_HapticSet.mid(2,2).toUInt(&ok,16); - if (ok) - hapticStrength=byte8u; - byte8=(int8_t)t_HapticSet.mid(4,2).toInt(&ok,16); - if (ok) - hapticLength=byte8; - byte8u=(uint8_t)t_SpeakerSet.mid(0,2).toUInt(&ok,16); - if (ok) - speakerMode=byte8u; - byte8u=(uint8_t)t_SpeakerSet.mid(2,2).toUInt(&ok,16); - if (ok) - speakerPitch=byte8u; - byte8u=(uint8_t)t_SpeakerSet.mid(4,2).toUInt(&ok,16); - if (ok) - speakerVolume=byte8u; - if (t_CountrySet.length()==6) { - byte8u=(uint8_t)t_CountrySet.mid(0,2).toUInt(&ok,16); - if (ok) - countryCode=byte8u; - byte8u=(uint8_t)t_CountrySet.mid(2,2).toUInt(&ok,16); - if (ok) - imperial=byte8u; - QString chars=t_CountrySet.mid(4,2); - ttsLanguage[0]=chars[0].toAscii(); - ttsLanguage[1]=chars[1].toAscii(); - } + imperial=byte8u; + QString chars=t_CountrySet.mid(4,2); + ttsLanguage[0]=chars[0].toAscii(); + ttsLanguage[1]=chars[1].toAscii(); } } - + } } RawSource GeneralSettings::getDefaultSource(unsigned int channel) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 36663659d..1b117f56d 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2595,8 +2595,8 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo } if (IS_TARANIS(board) && version >= 216) { internalField.Append(new UnsignedField<8>(generalData.hw_uartMode)); - for (int i=0; i<8; i++) { - internalField.Append(new UnsignedField<1>(generalData.potsType[i])); + for (int i=0; i<4; i++) { + internalField.Append(new UnsignedField<2>(potsType[i])); } } } @@ -2615,6 +2615,11 @@ void OpenTxGeneralData::beforeExport() sum += generalData.calibSpanPos[i]; if (++count == 12) break; } + for (int i=0; i<4; i++) { + potsType[i] = generalData.potsType[i]; + if (i<2 && potsType[i] == 1) + potsType[i] = 0; + } } else { for (int i=0; igetCapability(MultiposPots)) { ui->pot1Type->setCurrentIndex(g_eeGeneral.potsType[0]); ui->pot2Type->setCurrentIndex(g_eeGeneral.potsType[1]); + ui->pot3Type->setCurrentIndex(g_eeGeneral.potsType[2]); } else { ui->potsTypeSeparator->hide(); @@ -376,6 +377,8 @@ GeneralEdit::GeneralEdit(RadioData &radioData, QWidget *parent) : ui->pot1TypeLabel->hide(); ui->pot2Type->hide(); ui->pot2TypeLabel->hide(); + ui->pot3Type->hide(); + ui->pot3TypeLabel->hide(); } } @@ -396,6 +399,12 @@ void GeneralEdit::on_pot2Type_currentIndexChanged(int index) updateSettings(); } +void GeneralEdit::on_pot3Type_currentIndexChanged(int index) +{ + g_eeGeneral.potsType[2] = index; + updateSettings(); +} + void GeneralEdit::unlockSwitchEdited() { int i=0; diff --git a/companion/src/generaledit.h b/companion/src/generaledit.h index ce160dc0b..ca9911b74 100644 --- a/companion/src/generaledit.h +++ b/companion/src/generaledit.h @@ -121,6 +121,7 @@ private slots: void on_pot1Type_currentIndexChanged(int index); void on_pot2Type_currentIndexChanged(int index); + void on_pot3Type_currentIndexChanged(int index); void on_stickmodeCB_currentIndexChanged(int index); void on_channelorderCB_currentIndexChanged(int index); diff --git a/companion/src/generaledit.ui b/companion/src/generaledit.ui index 8f66dcab1..3eb53be8b 100644 --- a/companion/src/generaledit.ui +++ b/companion/src/generaledit.ui @@ -6,7 +6,7 @@ 0 0 - 795 + 804 912 @@ -1555,10 +1555,10 @@ Acceptable values are 5v..10v QLayout::SetMinimumSize - + 0 - + 0 @@ -3520,6 +3520,11 @@ p, li { white-space: pre-wrap; } 3 - Loud. 4 - Extra loud. + + + None + + Pot (normal) @@ -3556,6 +3561,11 @@ p, li { white-space: pre-wrap; } 3 - Loud. 4 - Extra loud. + + + None + + Pot (normal) @@ -3575,6 +3585,47 @@ p, li { white-space: pre-wrap; } + + + + S3 Type + + + + + + + + + + + + + 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 (normal) + + + + + Multipos Switch + + + + diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index 3af585369..e6174a1c2 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -68,6 +68,7 @@ MdiChild::MdiChild(): fileChanged(false) { ui->setupUi(this); + this->setWindowIcon(CompanionIcon("open.png")); ui->SimulateTxButton->setIcon(CompanionIcon("simulate.png")); setAttribute(Qt::WA_DeleteOnClose); @@ -166,7 +167,8 @@ void MdiChild::OpenEditWindow(bool wizard=false) ret = QMessageBox::question(this, tr("Companion"), tr("Do you want to use model wizard? "), QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::Yes) { wizard=true; - } else { + } + else { qSleep(500); ret = QMessageBox::question(this, tr("Companion"), tr("Ask this question again ? "), QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::No) { @@ -496,7 +498,8 @@ void MdiChild::writeEeprom() // write to Tx } backupEnable=false; } - } else { + } + else { backupEnable=false; } QString stickCal=g.profile[g.id()].stickPotCalib(); @@ -632,7 +635,8 @@ void MdiChild::print(int model, QString filename) printDialog *pd = new printDialog(this, &radioData.generalSettings, &radioData.models[model], filename); pd->show(); - } else { + } + else { if(ui->modelsList->currentRow()<1) return; printDialog *pd = new printDialog(this, &radioData.generalSettings, &radioData.models[ui->modelsList->currentRow()-1]); pd->show(); @@ -671,9 +675,8 @@ bool MdiChild::loadBackup() .arg(file.errorString())); return false; } - uint8_t *eeprom = (uint8_t *)malloc(eeprom_size); - memset(eeprom, 0, eeprom_size); - long result = file.read((char*)eeprom, eeprom_size); + QByteArray eeprom(eeprom_size, 0); + long result = file.read((char*)eeprom.data(), eeprom_size); file.close(); if (result != eeprom_size) { @@ -685,7 +688,7 @@ bool MdiChild::loadBackup() return false; } - if (!LoadBackup(radioData, eeprom, eeprom_size, index)) { + if (!LoadBackup(radioData, (uint8_t *)eeprom.data(), eeprom_size, index)) { QMessageBox::critical(this, tr("Error"), tr("Invalid binary backup File %1") .arg(fileName)); @@ -693,6 +696,6 @@ bool MdiChild::loadBackup() } ui->modelsList->refreshList(); - free(eeprom); + return true; } diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp index 04544f606..eb81faad4 100644 --- a/radio/src/gui/menu_general.cpp +++ b/radio/src/gui/menu_general.cpp @@ -1213,10 +1213,10 @@ void menuGeneralHardware(uint8_t event) putsMixerSource(sizeof(TR_TYPE)*FW, y, MIXSRC_FIRST_POT+idx); uint8_t potType = (g_eeGeneral.potsType & mask) >> shift; if (potType == POT_TYPE_NONE && i < 2) - potType = 1; + potType = POT_TYPE_POT; potType = selectMenuItem(HW_SETTINGS_COLUMN, y, STR_TYPE, STR_POTTYPES, potType, 0, POT_TYPE_MAX, attr, event); if (potType == POT_TYPE_POT && i < 2) - potType = 0; + potType = POT_TYPE_NONE; g_eeGeneral.potsType &= ~mask; g_eeGeneral.potsType |= (potType << shift); break;