bool writeEeprom(const QString &filename, ProgressWidget *progress) { if (IS_ARM(GetCurrentFirmware()->getBoard())) { QString path = findMassstoragePath("EEPROM.BIN"); if (path.isEmpty()) { // On previous OpenTX we called the EEPROM file "TARANIS.BIN" :( path = findMassstoragePath("TARANIS.BIN"); } if (path.isEmpty()) { // Mike's bootloader calls the EEPROM file "ERSKY9X.BIN" :( path = findMassstoragePath("ERSKY9X.BIN"); } if (!path.isEmpty()) { CopyProcess copyProcess(filename, path, progress); return copyProcess.run(); } } if (!IS_TARANIS(GetCurrentFirmware()->getBoard())) { FlashProcess flashProcess(getRadioInterfaceCmd(), getWriteEEpromCmd(filename), progress); return flashProcess.run(); } if (IS_ARM(GetCurrentFirmware()->getBoard())) { RadioNotFoundDialog dialog; dialog.exec(); } return false; }
void MdiChild::updateTitle() { QString title = userFriendlyCurrentFile() + "[*]" + " (" + GetCurrentFirmware()->getName() + QString(")"); if (!IS_SKY9X(GetCurrentFirmware()->getBoard())) title += QString(" - %1 ").arg(EEPromAvail) + tr("free bytes"); setWindowTitle(title); }
void populatePhasesCB(QComboBox *b, int value) { for (int i=-GetCurrentFirmware()->getCapability(FlightModes); i<=GetCurrentFirmware()->getCapability(FlightModes); i++) { if (i < 0) b->addItem(QObject::tr("!Flight mode %1").arg(-i-1), i); else if (i > 0) b->addItem(QObject::tr("Flight mode %1").arg(i-1), i); else b->addItem(QObject::tr("----"), 0); } b->setCurrentIndex(value + GetCurrentFirmware()->getCapability(FlightModes)); }
void GeneralEdit::on_calstore_PB_clicked() { int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); QString name=g.profile[profile_id].name(); int potsnum=GetCurrentFirmware()->getCapability(Pots); if (name.isEmpty()) { ui->calstore_PB->setDisabled(true); return; } else { QString calib=g.profile[profile_id].stickPotCalib(); if (!(calib.isEmpty())) { int ret = QMessageBox::question(this, "Companion", tr("Do you want to store calibration in %1 profile<br>overwriting existing calibration?").arg(name) , QMessageBox::Yes | QMessageBox::No); if (ret == QMessageBox::No) { return; } } calib.clear(); for (int i=0; i< (NUM_STICKS+potsnum); i++) { calib.append(QString("%1").arg((uint16_t)generalSettings.calibMid[i], 4, 16, QChar('0'))); calib.append(QString("%1").arg((uint16_t)generalSettings.calibSpanNeg[i], 4, 16, QChar('0'))); calib.append(QString("%1").arg((uint16_t)generalSettings.calibSpanPos[i], 4, 16, QChar('0'))); } g.profile[profile_id].stickPotCalib( calib ); calib.clear(); for (int i=0; i< 4; i++) { calib.append(QString("%1").arg((uint16_t)generalSettings.trainer.calib[i], 4, 16, QChar('0'))); } g.profile[profile_id].trainerCalib( calib ); g.profile[profile_id].vBatCalib( generalSettings.vBatCalib ); g.profile[profile_id].currentCalib( generalSettings.currentCalib ); g.profile[profile_id].vBatWarn( generalSettings.vBatWarn ); if (GetCurrentFirmware()->getCapability(HasBatMeterRange)) { g.profile[profile_id].vBatMin( generalSettings.vBatMin ); g.profile[profile_id].vBatMax( generalSettings.vBatMax ); } g.profile[profile_id].ppmMultiplier( generalSettings.PPM_Multiplier ); g.profile[profile_id].gsStickMode( generalSettings.stickMode ); g.profile[profile_id].display( QString("%1%2%3").arg((generalSettings.optrexDisplay ? 1:0), 2, 16, QChar('0')).arg((uint8_t)generalSettings.contrast, 2, 16, QChar('0')).arg((uint8_t)generalSettings.backlightBright, 2, 16, QChar('0')) ); g.profile[profile_id].beeper( QString("%1%2").arg(((uint8_t)generalSettings.beeperMode), 2, 16, QChar('0')).arg((uint8_t)generalSettings.beeperLength, 2, 16, QChar('0'))); g.profile[profile_id].haptic( QString("%1%2%3").arg(((uint8_t)generalSettings.hapticMode), 2, 16, QChar('0')).arg((int8_t)generalSettings.hapticStrength, 2, 16, QChar('0')).arg((uint8_t)generalSettings.hapticLength, 2, 16, QChar('0'))); g.profile[profile_id].speaker( QString("%1%2%3").arg((uint8_t)generalSettings.speakerMode, 2, 16, QChar('0')).arg((uint8_t)generalSettings.speakerPitch, 2, 16, QChar('0')).arg((uint8_t)generalSettings.speakerVolume, 2, 16, QChar('0'))); g.profile[profile_id].countryCode( QString("%1%2%3").arg((uint8_t)generalSettings.countryCode, 2, 16, QChar('0')).arg((uint8_t)generalSettings.imperial, 2, 16, QChar('0')).arg(generalSettings.ttsLanguage)); QDateTime dateTime = QDateTime::currentDateTime(); g.profile[profile_id].timeStamp(dateTime.toString("yyyy-MM-dd hh:mm")); QMessageBox::information(this, "Companion", tr("Calibration and HW parameters saved.")); } }
void MdiChild::print(int model, QString filename) { PrintDialog * pd = NULL; if (model>=0 && !filename.isEmpty()) { pd = new PrintDialog(this, GetCurrentFirmware()/*firmware*/, &radioData.generalSettings, &radioData.models[model], filename); } else if (ui->modelsList->currentRow() > 0) { pd = new PrintDialog(this, GetCurrentFirmware()/*firmware*/, &radioData.generalSettings, &radioData.models[ui->modelsList->currentRow()-1]); } if (pd) { pd->setAttribute(Qt::WA_DeleteOnClose, true); pd->show(); } }
void FuncSwData::clear() { memset(this, 0, sizeof(FuncSwData)); if (!GetCurrentFirmware()->getCapability(SafetyChannelCustomFunction)) { func = FuncTrainer; } }
int ModelData::getChannelsMax() { if (extendedLimits) return IS_TARANIS(GetCurrentFirmware()->getBoard()) ? 150 : 125; else return 100; }
bool readFirmware(const QString &filename, ProgressWidget *progress) { bool result = false; QFile file(filename); if (file.exists() && !file.remove()) { QMessageBox::warning(NULL, QObject::tr("Error"), QObject::tr("Could not delete temporary file: %1").arg(filename)); return false; } if (IS_ARM(GetCurrentFirmware()->getBoard())) { QString path = findMassstoragePath("FIRMWARE.BIN"); if (!path.isEmpty()) { qDebug() << "readFirmware: reading" << path << "into" << filename; CopyProcess copyProcess(path, filename, progress); result = copyProcess.run(); } } if (result == false) { qDebug() << "readFirmware: reading" << filename << "with" << getRadioInterfaceCmd() << getReadFirmwareArgs(filename); FlashProcess flashProcess(getRadioInterfaceCmd(), getReadFirmwareArgs(filename), progress); result = flashProcess.run(); } if (!QFileInfo(filename).exists()) { result = false; } return result; }
CalibrationPanel::CalibrationPanel(QWidget * parent, GeneralSettings & generalSettings, Firmware * firmware): GeneralPanel(parent, generalSettings, firmware) { tableWidget = new QTableWidget(); QVBoxLayout * layout = new QVBoxLayout(); layout->addWidget(tableWidget); layout->setContentsMargins(0, 0, 0, 0); this->setLayout(layout); tableWidget->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); tableWidget->setColumnCount(3); tableWidget->setShowGrid(false); tableWidget->setSelectionMode(QAbstractItemView::NoSelection); tableWidget->setFrameStyle(QFrame::NoFrame | QFrame::Plain); tableWidget->setStyleSheet("QTableWidget {background-color: transparent;}"); QStringList headerLabels; headerLabels << QObject::tr("Negative span") << QObject::tr("Mid value") << QObject::tr("Positive span"); tableWidget->setHorizontalHeaderLabels(headerLabels); int rows = NUM_STICKS + GetCurrentFirmware()->getCapability(Pots) + GetCurrentFirmware()->getCapability(Sliders); tableWidget->setRowCount(rows); for(int i = 0; i < rows; ++i) { QTableWidgetItem *newItem = new QTableWidgetItem(AnalogString(i)); newItem->setTextAlignment(Qt::AlignLeft); tableWidget->setVerticalHeaderItem(i, newItem); for(int j = 0; j < 3; ++j) { QSpinBox * newItem = new QSpinBox(); newItem->setMinimum(-9999); newItem->setMaximum(9999); newItem->setSingleStep(1); newItem->setValue(getCalibrationValue(i, j)); newItem->setProperty("row", i); newItem->setProperty("column", j); tableWidget->setCellWidget(i, j, newItem); connect(newItem, SIGNAL(valueChanged(int)), this, SLOT(onCellChanged(int))); } } disableMouseScrolling(); }
bool readEeprom(const QString &filename, ProgressWidget *progress) { bool result = false; QFile file(filename); if (file.exists() && !file.remove()) { QMessageBox::warning(NULL, QObject::tr("Error"), QObject::tr("Could not delete temporary file: %1").arg(filename)); return false; } if (IS_ARM(GetCurrentFirmware()->getBoard())) { QString path = findMassstoragePath("EEPROM.BIN"); if (path.isEmpty()) { // On previous OpenTX we called the EEPROM file "TARANIS.BIN" :( path = findMassstoragePath("TARANIS.BIN"); } if (path.isEmpty()) { // Mike's bootloader calls the EEPROM file "ERSKY9X.BIN" :( path = findMassstoragePath("ERSKY9X.BIN"); } if (!path.isEmpty()) { CopyProcess copyProcess(path, filename, progress); result = copyProcess.run(); } } if (result == false && !IS_TARANIS(GetCurrentFirmware()->getBoard())) { FlashProcess flashProcess(getRadioInterfaceCmd(), getReadEEpromCmd(filename), progress); result = flashProcess.run(); } if (result == false && IS_ARM(GetCurrentFirmware()->getBoard())) { RadioNotFoundDialog dialog; dialog.exec(); } if (!QFileInfo(filename).exists()) { result = false; } return result; }
void ModelData::clearInputs() { for (int i=0; i<C9X_MAX_EXPOS; i++) expoData[i].clear(); //clear all input names if (GetCurrentFirmware()->getCapability(VirtualInputs)) { for (int i=0; i<C9X_MAX_INPUTS; i++) { inputNames[i][0] = 0; } } }
bool writeFirmware(const QString &filename, ProgressWidget *progress) { if (IS_ARM(GetCurrentFirmware()->getBoard())) { QString path = findMassstoragePath("FIRMWARE.BIN"); if (!path.isEmpty()) { qDebug() << "writeFirmware: writing" << path << "from" << filename; CopyProcess copyProcess(filename, path, progress); return copyProcess.run(); } } qDebug() << "writeFirmware: writing" << filename << "with" << getRadioInterfaceCmd() << getWriteFirmwareArgs(filename); FlashProcess flashProcess(getRadioInterfaceCmd(), getWriteFirmwareArgs(filename), progress); return flashProcess.run(); }
GVarGroup::GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const unsigned int flags): QObject(), weightGV(weightGV), weightSB(weightSB), weightCB(weightCB), weight(weight), flags(flags), lock(false) { lock = true; if (GetCurrentFirmware()->getCapability(Gvars)) { populateGVCB(weightCB, weight); connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int))); connect(weightCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged())); }
GVarGroup::GVarGroup(QCheckBox *weightGV, QAbstractSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const double step, bool allowGvars): QObject(), weightGV(weightGV), weightSB(weightSB), sb(dynamic_cast<QSpinBox *>(weightSB)), dsb(dynamic_cast<QDoubleSpinBox *>(weightSB)), weightCB(weightCB), weight(weight), step(step), lock(true) { if (allowGvars && GetCurrentFirmware()->getCapability(Gvars)) { populateGVCB(weightCB, weight); connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int))); connect(weightCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged())); }
void MdiChild::modelEdit() { int row = ui->modelsList->currentRow(); if (row == 0){ generalEdit(); } else { QApplication::setOverrideCursor(Qt::WaitCursor); checkAndInitModel( row ); ModelData &model = radioData.models[row - 1]; ModelEdit *t = new ModelEdit(this, radioData, (row - 1), GetCurrentFirmware()/*firmware*/); t->setWindowTitle(tr("Editing model %1: ").arg(row) + model.name); connect(t, SIGNAL(modified()), this, SLOT(setModified())); t->show(); QApplication::restoreOverrideCursor(); } }
MdiChild::MdiChild(): QWidget(), ui(new Ui::mdiChild), firmware(GetCurrentFirmware()), isUntitled(true), fileChanged(false) { ui->setupUi(this); setWindowIcon(CompanionIcon("open.png")); ui->SimulateTxButton->setIcon(CompanionIcon("simulate.png")); setAttribute(Qt::WA_DeleteOnClose); eepromInterfaceChanged(); if (!(this->isMaximized() || this->isMinimized())) { adjustSize(); } }
int OpenTxEepromInterface::getSize(GeneralSettings &settings) { if (IS_SKY9X(board)) return 0; uint8_t tmp[EESIZE_RLC_MAX]; efile->EeFsCreate(tmp, EESIZE_RLC_MAX, board); OpenTxGeneralData open9xGeneral(settings, board, 255, GetCurrentFirmware()->getVariantNumber()); // open9xGeneral.Dump(); QByteArray eeprom; open9xGeneral.Export(eeprom); int sz = efile->writeRlc2(0, FILE_TYP_GENERAL, (const uint8_t*)eeprom.constData(), eeprom.size()); if (sz != eeprom.size()) { return -1; } return efile->size(0); }
QString getInputStr(ModelData & model, int index) { QString result; if (GetCurrentFirmware()->getCapability(VirtualInputs)) { if (strlen(model.inputNames[index]) > 0) { result = QObject::tr("[I%1]").arg(index+1); result += QString(model.inputNames[index]); } else { result = QObject::tr("Input%1").arg(index+1, 2, 10, QChar('0')); } } else { result = RawSource(SOURCE_TYPE_STICK, index).toString(model); } return result; }
int OpenTxEepromInterface::getSize(ModelData &model) { if (IS_SKY9X(board)) return 0; if (model.isempty()) return 0; // TODO something better uint8_t tmp[EESIZE_RLC_MAX]; efile->EeFsCreate(tmp, EESIZE_RLC_MAX, board); OpenTxModelData open9xModel(model, board, 255, GetCurrentFirmware()->getVariantNumber()); QByteArray eeprom; open9xModel.Export(eeprom); int sz = efile->writeRlc2(0, FILE_TYP_MODEL, (const uint8_t*)eeprom.constData(), eeprom.size()); if (sz != eeprom.size()) { return -1; } return efile->size(0); }
void MdiChild::modelEdit() { int row = getCurrentRow(); if (row == 0){ generalEdit(); } else { QApplication::setOverrideCursor(Qt::WaitCursor); checkAndInitModel( row ); ModelData &model = radioData.models[row - 1]; gStopwatch.restart(); gStopwatch.report("ModelEdit creation"); ModelEdit *t = new ModelEdit(this, radioData, (row - 1), GetCurrentFirmware()/*firmware*/); gStopwatch.report("ModelEdit created"); t->setWindowTitle(tr("Editing model %1: ").arg(row) + model.name); connect(t, SIGNAL(modified()), this, SLOT(setModified())); gStopwatch.report("STARTING MODEL EDIT"); t->show(); QApplication::restoreOverrideCursor(); gStopwatch.report("ModelEdit shown"); } }
bool convertEEprom(const QString &sourceEEprom, const QString &destinationEEprom, const QString &firmwareFilename) { Firmware *currentFirmware = GetCurrentFirmware(); FirmwareInterface firmware(firmwareFilename); if (!firmware.isValid()) return false; unsigned int version = firmware.getEEpromVersion(); unsigned int variant = firmware.getEEpromVariant(); QFile sourceFile(sourceEEprom); int eeprom_size = sourceFile.size(); if (!eeprom_size) return false; if (!sourceFile.open(QIODevice::ReadOnly)) return false; QByteArray eeprom(eeprom_size, 0); long result = sourceFile.read(eeprom.data(), eeprom_size); sourceFile.close(); QSharedPointer<RadioData> radioData = QSharedPointer<RadioData>(new RadioData()); if (!loadEEprom(*radioData, (uint8_t *)eeprom.data(), eeprom_size) || !currentFirmware->saveEEPROM((uint8_t *)eeprom.data(), *radioData, variant, version)) return false; QFile destinationFile(destinationEEprom); if (!destinationFile.open(QIODevice::WriteOnly)) return false; result = destinationFile.write(eeprom.constData(), eeprom_size); destinationFile.close(); if (result != eeprom_size) return false; return true; }
QString FuncSwData::paramToString() { QStringList qs; if (func <= FuncInstantTrim) { return QString("%1").arg(param); } else if (func==FuncPlaySound) { qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ; qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ; if (param>=0 && param<(int)qs.count()) return qs.at(param); else return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>"); } else if (func==FuncPlayHaptic) { qs << "0" << "1" << "2" << "3"; if (param>=0 && param<(int)qs.count()) return qs.at(param); else return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>"); } else if (func==FuncReset) { qs.append( QObject::tr("Timer1")); qs.append( QObject::tr("Timer2")); qs.append( QObject::tr("All")); qs.append( QObject::tr("Telemetry")); if (param>=0 && param<(int)qs.count()) return qs.at(param); else return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>"); } else if ((func==FuncVolume)|| (func==FuncPlayValue)) { RawSource item(param); ModelData model; return item.toString(model); } else if ((func==FuncPlayPrompt) || (func==FuncPlayBoth)) { if ( GetCurrentFirmware()->getCapability(VoicesAsNumbers)) { return QString("%1").arg(param); } else { return paramarm; } } else if ((func>FuncBackgroundMusicPause) && (func<FuncCount)) { ModelData model; switch (adjustMode) { case 0: return QObject::tr("Value ")+QString("%1").arg(param); break; case 1: return RawSource(param).toString(model); break; case 2: return RawSource(param).toString(model); break; case 3: if (param==0) { return QObject::tr("Decr:")+QString(" -1"); } else { return QObject::tr("Incr:")+QString(" +1"); } break; default: return ""; } } return ""; }
GeneralSettings::GeneralSettings() { memset(this, 0, sizeof(GeneralSettings)); contrast = 25; vBatWarn = 90; for (int i=0; i<NUM_STICKS+C9X_NUM_POTS; ++i) { calibMid[i] = 0x200; calibSpanNeg[i] = 0x180; calibSpanPos[i] = 0x180; } BoardEnum board = GetEepromInterface()->getBoard(); if (IS_TARANIS(board)) { potsType[0] = 1; potsType[1] = 1; } if (IS_ARM(board)) { speakerVolume = 12; } templateSetup = g.profile[g.id()].channelOrder(); stickMode = g.profile[g.id()].defaultMode(); QString t_calib=g.profile[g.id()].stickPotCalib(); int potsnum=GetCurrentFirmware()->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_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; byte8=(int8_t)t_HapticSet.mid(2,2).toInt(&ok,16); if (ok) hapticStrength=byte8; 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(); } } } }
bool MdiChild::saveFile(const QString &fileName, bool setCurrent) { QString myFile; myFile = fileName; if (IS_SKY9X(GetEepromInterface()->getBoard())) { myFile.replace(".eepe", ".bin"); } QFile file(myFile); int fileType = getFileType(myFile); uint8_t *eeprom = (uint8_t*)malloc(GetEepromInterface()->getEEpromSize()); int eeprom_size = 0; if (fileType != FILE_TYPE_XML) { eeprom_size = GetEepromInterface()->save(eeprom, radioData, GetCurrentFirmware()->getVariantNumber(), 0/*last version*/); if (!eeprom_size) { QMessageBox::warning(this, tr("Error"),tr("Cannot write file %1:\n%2.").arg(myFile).arg(file.errorString())); return false; } } if (!file.open(fileType == FILE_TYPE_BIN ? QIODevice::WriteOnly : (QIODevice::WriteOnly | QIODevice::Text))) { QMessageBox::warning(this, tr("Error"),tr("Cannot write file %1:\n%2.").arg(myFile).arg(file.errorString())); return false; } QTextStream outputStream(&file); #if 0 if (fileType==FILE_TYPE_XML) { if (!XmlInterface(outputStream).save(radioData)) { QMessageBox::warning(this, tr("Error"),tr("Cannot write file %1:\n%2.").arg(myFile).arg(file.errorString())); file.close(); return false; } } else #endif if (fileType==FILE_TYPE_HEX || fileType==FILE_TYPE_EEPE) { // write hex if (fileType==FILE_TYPE_EEPE) outputStream << EEPE_EEPROM_FILE_HEADER << "\n"; if (!HexInterface(outputStream).save(eeprom, eeprom_size)) { QMessageBox::warning(this, tr("Error"),tr("Cannot write file %1:\n%2.").arg(myFile).arg(file.errorString())); file.close(); return false; } } else if (fileType==FILE_TYPE_BIN) // write binary { long result = file.write((char*)eeprom, eeprom_size); if(result!=eeprom_size) { QMessageBox::warning(this, tr("Error"),tr("Error writing file %1:\n%2.").arg(myFile).arg(file.errorString())); return false; } } else { QMessageBox::warning(this, tr("Error"),tr("Error writing file %1:\n%2.").arg(myFile).arg("Unknown format")); return false; } free(eeprom); // TODO free in all cases ... file.close(); if(setCurrent) setCurrentFile(myFile); return true; }
RawSourceRange RawSource::getRange(const ModelData & model, const GeneralSettings & settings, unsigned int flags) const { RawSourceRange result; FirmwareInterface * firmware = GetCurrentFirmware(); int board = firmware->getBoard(); bool singleprec = (flags & RANGE_SINGLE_PRECISION); if (!singleprec && !IS_ARM(board)) { singleprec = true; } switch (type) { case SOURCE_TYPE_TELEMETRY: if (singleprec) { result.offset = -DBL_MAX; } switch (index) { case TELEMETRY_SOURCE_TX_BATT: result.step = 0.1; result.decimals = 1; result.max = 25.5; result.unit = QObject::tr("V"); break; case TELEMETRY_SOURCE_TX_TIME: result.step = 1; result.max = 24*60 - 1; break; case TELEMETRY_SOURCE_TIMER1: case TELEMETRY_SOURCE_TIMER2: result.step = singleprec ? 5 : 1; result.max = singleprec ? 255*5 : 60*60; result.unit = QObject::tr("s"); break; case TELEMETRY_SOURCE_RSSI_TX: case TELEMETRY_SOURCE_RSSI_RX: result.max = 100; if (singleprec) result.offset = 128; break; case TELEMETRY_SOURCE_A1_MIN: case TELEMETRY_SOURCE_A2_MIN: case TELEMETRY_SOURCE_A3_MIN: case TELEMETRY_SOURCE_A4_MIN: result = model.frsky.channels[index-TELEMETRY_SOURCE_A1_MIN].getRange(); break; case TELEMETRY_SOURCE_A1: case TELEMETRY_SOURCE_A2: case TELEMETRY_SOURCE_A3: case TELEMETRY_SOURCE_A4: result = model.frsky.channels[index-TELEMETRY_SOURCE_A1].getRange(); break; case TELEMETRY_SOURCE_ALT: case TELEMETRY_SOURCE_ALT_MIN: case TELEMETRY_SOURCE_ALT_MAX: case TELEMETRY_SOURCE_GPS_ALT: result.step = singleprec ? 8 : 1; result.min = -500; result.max = singleprec ? 1540 : 3000; if (firmware->getCapability(Imperial) || settings.imperial) { result.step = (result.step * 105) / 32; result.min = (result.min * 105) / 32; result.max = (result.max * 105) / 32; result.unit = QObject::tr("ft"); } else { result.unit = QObject::tr("m"); } break; case TELEMETRY_SOURCE_T1: case TELEMETRY_SOURCE_T1_MAX: case TELEMETRY_SOURCE_T2: case TELEMETRY_SOURCE_T2_MAX: result.min = -30; result.max = 225; result.unit = QObject::trUtf8("°C"); break; case TELEMETRY_SOURCE_HDG: result.step = singleprec ? 2 : 1; result.max = 360; if (singleprec) result.offset = 256; result.unit = QObject::trUtf8("°"); break; case TELEMETRY_SOURCE_RPM: case TELEMETRY_SOURCE_RPM_MAX: result.step = singleprec ? 50 : 1; result.max = singleprec ? 12750 : 30000; break; case TELEMETRY_SOURCE_FUEL: result.max = 100; result.unit = QObject::tr("%"); break; case TELEMETRY_SOURCE_ASPEED: case TELEMETRY_SOURCE_ASPEED_MAX: result.decimals = 1; result.step = singleprec ? 2.0 : 0.1; result.max = singleprec ? (2*255) : 2000; if (firmware->getCapability(Imperial) || settings.imperial) { result.step *= 1.150779; result.max *= 1.150779; result.unit = QObject::tr("mph"); } else { result.step *= 1.852; result.max *= 1.852; result.unit = QObject::tr("km/h"); } break; case TELEMETRY_SOURCE_SPEED: case TELEMETRY_SOURCE_SPEED_MAX: result.step = singleprec ? 2 : 1; result.max = singleprec ? (2*255) : 2000; if (firmware->getCapability(Imperial) || settings.imperial) { result.step *= 1.150779; result.max *= 1.150779; result.unit = QObject::tr("mph"); } else { result.step *= 1.852; result.max *= 1.852; result.unit = QObject::tr("km/h"); } break; case TELEMETRY_SOURCE_VERTICAL_SPEED: result.step = 0.1; result.min = singleprec ? -12.5 : -300.0; result.max = singleprec ? 13.0 : 300.0; result.decimals = 1; result.unit = QObject::tr("m/s"); break; case TELEMETRY_SOURCE_DTE: result.max = 30000; break; case TELEMETRY_SOURCE_DIST: case TELEMETRY_SOURCE_DIST_MAX: result.step = singleprec ? 8 : 1; result.max = singleprec ? 2040 : 10000; result.unit = QObject::tr("m"); break; case TELEMETRY_SOURCE_CELL: case TELEMETRY_SOURCE_CELL_MIN: result.step = singleprec ? 0.02 : 0.01; result.max = 5.1; result.decimals = 2; result.unit = QObject::tr("V"); break; case TELEMETRY_SOURCE_CELLS_SUM: case TELEMETRY_SOURCE_CELLS_MIN: case TELEMETRY_SOURCE_VFAS: case TELEMETRY_SOURCE_VFAS_MIN: result.step = 0.1; result.max = singleprec ? 25.5 : 100.0; result.decimals = 1; result.unit = QObject::tr("V"); break; case TELEMETRY_SOURCE_CURRENT: case TELEMETRY_SOURCE_CURRENT_MAX: result.step = singleprec ? 0.5 : 0.1; result.max = singleprec ? 127.5 : 200.0; result.decimals = 1; result.unit = QObject::tr("A"); break; case TELEMETRY_SOURCE_CONSUMPTION: result.step = singleprec ? 100 : 1; result.max = singleprec ? 25500 : 30000; result.unit = QObject::tr("mAh"); break; case TELEMETRY_SOURCE_POWER: case TELEMETRY_SOURCE_POWER_MAX: result.step = singleprec ? 5 : 1; result.max = singleprec ? 1275 : 2000; result.unit = QObject::tr("W"); break; case TELEMETRY_SOURCE_ACCX: case TELEMETRY_SOURCE_ACCY: case TELEMETRY_SOURCE_ACCZ: result.step = 0.01; result.decimals = 2; result.max = singleprec ? 2.55 : 10.00; result.min = singleprec ? 0 : -10.00; result.unit = QObject::tr("g"); break; default: result.max = 125; break; } if (singleprec && result.offset==-DBL_MAX) { result.offset = result.max - (127*result.step); } if (flags & (RANGE_DELTA_FUNCTION|RANGE_DELTA_ABS_FUNCTION)) { if (singleprec) { result.offset = 0; result.min = result.step * -127; result.max = result.step * 127; } else { result.min = -result.max; } } break; case SOURCE_TYPE_GVAR: result.max = 1024; result.min = -result.max; break; default: result.max = (model.extendedLimits ? 125 : 100); result.min = -result.max; break; } if (flags & RANGE_DELTA_ABS_FUNCTION) { result.min = 0; } return result; }
void MdiChild::eepromInterfaceChanged() { ui->modelsList->refreshList(); ui->SimulateTxButton->setEnabled(GetCurrentFirmware()/*firmware*/->getCapability(Simulation)); updateTitle(); }
void MdiChild::generalEdit() { GeneralEdit *t = new GeneralEdit(this, radioData, GetCurrentFirmware()/*firmware*/); connect(t, SIGNAL(modified()), this, SLOT(setModified())); t->show(); }
void burnDialog::on_BurnFlashButton_clicked() { if (hexType==FLASH_FILE_TYPE) { QString fileName=ui->FWFileName->text(); if (!fileName.isEmpty()) { g.flashDir( QFileInfo(fileName).dir().absolutePath() ); if (!ui->useFwImageCB->isChecked()) { QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width(), ui->imageLabel->height()); if (!image.isNull()) { QString tempDir = QDir::tempPath(); QString tempFile; if (getFileType(fileName) == FILE_TYPE_HEX) tempFile = tempDir + "/flash.hex"; else tempFile = tempDir + "/flash.bin"; FlashInterface flash(fileName); flash.setSplash(image); if (flash.saveFlash(tempFile) > 0) { hexfileName->clear(); hexfileName->append(tempFile); } else { hexfileName->clear(); QMessageBox::critical(this, tr("Warning"), tr("Cannot save customized firmware")); } } else { hexfileName->clear(); QMessageBox::critical(this, tr("Warning"), tr("Custom image not found")); } } else { hexfileName->clear(); hexfileName->append(fileName); } } else { QMessageBox::critical(this, tr("Warning"), tr("No firmware selected")); hexfileName->clear(); } } if (hexType==EEPROM_FILE_TYPE) { QString calib = g.profile[g.id()].stickPotCalib(); QString trainercalib = g.profile[g.id()].trainerCalib(); int potsnum=GetCurrentFirmware()->getCapability(Pots); int8_t vBatCalib=(int8_t) g.profile[g.id()].vBatCalib(); int8_t currentCalib=(int8_t) g.profile[g.id()].currentCalib(); int8_t PPM_Multiplier=(int8_t) g.profile[g.id()].ppmMultiplier(); uint8_t GSStickMode=(uint8_t) g.profile[g.id()].gsStickMode(); uint8_t vBatWarn=(uint8_t) g.profile[g.id()].vBatWarn(); QString DisplaySet= g.profile[g.id()].display(); QString BeeperSet= g.profile[g.id()].beeper(); QString HapticSet= g.profile[g.id()].haptic(); QString SpeakerSet= g.profile[g.id()].speaker(); bool patch=false; if (ui->patchcalib_CB->isChecked()) { if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) { QString Byte; int16_t byte16; bool ok; for (int i=0; i<(NUM_STICKS+potsnum); i++) { Byte=calib.mid(i*12,4); byte16=(int16_t)Byte.toInt(&ok,16); if (ok) radioData.generalSettings.calibMid[i]=byte16; Byte=calib.mid(4+i*12,4); byte16=(int16_t)Byte.toInt(&ok,16); if (ok) radioData.generalSettings.calibSpanNeg[i]=byte16; Byte=calib.mid(8+i*12,4); byte16=(int16_t)Byte.toInt(&ok,16); if (ok) radioData.generalSettings.calibSpanPos[i]=byte16; } for (int i=0; i<4; i++) { Byte=trainercalib.mid(i*4,4); byte16=(int16_t)Byte.toInt(&ok,16); if (ok) radioData.generalSettings.trainer.calib[i]=byte16; } radioData.generalSettings.currentCalib=currentCalib; radioData.generalSettings.vBatCalib=vBatCalib; radioData.generalSettings.PPM_Multiplier=PPM_Multiplier; patch=true; } else { QMessageBox::critical(this, tr("Warning"), tr("Wrong radio calibration data in profile, Settings not patched")); } } if (ui->patchhw_CB->isChecked()) { if ((DisplaySet.length()==6) && (BeeperSet.length()==4) && (HapticSet.length()==6) && (SpeakerSet.length()==6)) { radioData.generalSettings.vBatWarn=vBatWarn; radioData.generalSettings.stickMode=GSStickMode; uint8_t byte8u; int8_t byte8; bool ok; byte8=(int8_t)DisplaySet.mid(0,2).toInt(&ok,16); if (ok) radioData.generalSettings.optrexDisplay=(byte8==1 ? true : false); byte8u=(uint8_t)DisplaySet.mid(2,2).toUInt(&ok,16); if (ok) radioData.generalSettings.contrast=byte8u; byte8u=(uint8_t)DisplaySet.mid(4,2).toUInt(&ok,16); if (ok) radioData.generalSettings.backlightBright=byte8u; byte8u=(uint8_t)BeeperSet.mid(0,2).toUInt(&ok,16); if (ok) radioData.generalSettings.beeperMode=(BeeperMode)byte8u; byte8=(int8_t)BeeperSet.mid(2,2).toInt(&ok,16); if (ok) radioData.generalSettings.beeperLength=byte8; byte8u=(uint8_t)HapticSet.mid(0,2).toUInt(&ok,16); if (ok) radioData.generalSettings.hapticMode=(BeeperMode)byte8u; byte8u=(uint8_t)HapticSet.mid(2,2).toUInt(&ok,16); if (ok) radioData.generalSettings.hapticStrength=byte8u; byte8=(int8_t)HapticSet.mid(4,2).toInt(&ok,16); if (ok) radioData.generalSettings.hapticLength=byte8; byte8u=(uint8_t)SpeakerSet.mid(0,2).toUInt(&ok,16); if (ok) radioData.generalSettings.speakerMode=byte8u; byte8u=(uint8_t)SpeakerSet.mid(2,2).toUInt(&ok,16); if (ok) radioData.generalSettings.speakerPitch=byte8u; byte8u=(uint8_t)SpeakerSet.mid(4,2).toUInt(&ok,16); if (ok) radioData.generalSettings.speakerVolume=byte8u; patch=true; } else { QMessageBox::critical(this, tr("Warning"), tr("Wrong radio setting data in profile, Settings not patched")); } QString fileName; if (patch) { QString tempDir = QDir::tempPath(); fileName = tempDir + "/temp.bin"; QFile file(fileName); uint8_t *eeprom = (uint8_t*)malloc(GetEepromInterface()->getEEpromSize()); int eeprom_size = 0; eeprom_size = GetEepromInterface()->save(eeprom, radioData, GetCurrentFirmwareVariant()); if (!eeprom_size) { QMessageBox::warning(this, tr("Error"),tr("Cannot write file %1:\n%2.").arg(fileName).arg(file.errorString())); hexfileName->clear(); } if (!file.open(QIODevice::WriteOnly)) { QMessageBox::warning(this, tr("Error"),tr("Cannot write file %1:\n%2.").arg(fileName).arg(file.errorString())); hexfileName->clear(); } QTextStream outputStream(&file); long result = file.write((char*)eeprom, eeprom_size); if(result!=eeprom_size) { QMessageBox::warning(this, tr("Error"),tr("Error writing file %1:\n%2.").arg(fileName).arg(file.errorString())); hexfileName->clear(); } hexfileName->clear(); hexfileName->append(fileName); } else { hexfileName->clear(); hexfileName->append(ui->FWFileName->text()); } } else { hexfileName->clear(); hexfileName->append(ui->FWFileName->text()); } } this->close(); }
void GeneralEdit::on_calretrieve_PB_clicked() { int profile_id=ui->profile_CB->itemData(ui->profile_CB->currentIndex()).toInt(); QString calib=g.profile[profile_id].stickPotCalib(); int potsnum=GetCurrentFirmware()->getCapability(Pots)+GetCurrentFirmware()->getCapability(Sliders); int numSwPots=GetCurrentFirmware()->getCapability(Switches)+GetCurrentFirmware()->getCapability(Pots)+GetCurrentFirmware()->getCapability(Sliders); if (calib.isEmpty()) { return; } else { QString trainercalib = g.profile[profile_id].trainerCalib(); QString hwtypes = g.profile[profile_id].controlTypes(); QString controlNames=g.profile[profile_id].controlNames(); int8_t txVoltageCalibration = (int8_t)g.profile[profile_id].txVoltageCalibration(); int8_t txCurrentCalibration = (int8_t)g.profile[profile_id].txCurrentCalibration(); int8_t PPM_Multiplier = (int8_t)g.profile[profile_id].ppmMultiplier(); uint8_t GSStickMode = (uint8_t)g.profile[profile_id].gsStickMode(); uint8_t vBatWarn = (uint8_t)g.profile[profile_id].vBatWarn(); QString DisplaySet = g.profile[profile_id].display(); QString BeeperSet = g.profile[profile_id].beeper(); QString HapticSet = g.profile[profile_id].haptic(); QString SpeakerSet = g.profile[profile_id].speaker(); QString CountrySet = g.profile[profile_id].countryCode(); if ((calib.length()==(NUM_STICKS+potsnum)*12) && (trainercalib.length()==16)) { QString Byte; int16_t byte16; bool ok; for (int i=0; i<(NUM_STICKS+potsnum); i++) { Byte=calib.mid(i*12,4); byte16=(int16_t)Byte.toInt(&ok,16); if (ok) generalSettings.calibMid[i]=byte16; Byte=calib.mid(4+i*12,4); byte16=(int16_t)Byte.toInt(&ok,16); if (ok) generalSettings.calibSpanNeg[i]=byte16; Byte=calib.mid(8+i*12,4); byte16=(int16_t)Byte.toInt(&ok,16); if (ok) generalSettings.calibSpanPos[i]=byte16; } for (int i=0; i<4; i++) { Byte=trainercalib.mid(i*4,4); byte16=(int16_t)Byte.toInt(&ok,16); if (ok) generalSettings.trainer.calib[i]=byte16; } generalSettings.txCurrentCalibration=txCurrentCalibration; generalSettings.txVoltageCalibration=txVoltageCalibration; generalSettings.vBatWarn=vBatWarn; if (GetCurrentFirmware()->getCapability(HasBatMeterRange)) { generalSettings.vBatMin = (int8_t) g.profile[profile_id].vBatMin(); generalSettings.vBatMax = (int8_t) g.profile[profile_id].vBatMax(); } generalSettings.PPM_Multiplier=PPM_Multiplier; } else { QMessageBox::critical(this, tr("Warning"), tr("Wrong data in profile, radio calibration was not retrieved")); } if (hwtypes.length()==numSwPots) { QString Byte; int16_t byte16; QByteArray qba; int16_t offset; bool ok; for (int i=0; i<NUM_STICKS; i++) { qba = controlNames.mid(3*i,3).toAscii(); strcpy(generalSettings.stickName[i], qba.data()); } for (int i=0; i<(GetCurrentFirmware()->getCapability(Switches)); i++) { Byte=hwtypes.mid(i,1); byte16=(int16_t)Byte.toInt(&ok,16); qba=controlNames.mid(3*(i+NUM_STICKS),3).toAscii(); if (ok) generalSettings.switchConfig[i]=byte16; strcpy(generalSettings.switchName[i], qba.data()); } offset = GetCurrentFirmware()->getCapability(Switches); for (int i=0; i<(GetCurrentFirmware()->getCapability(Pots)); i++) { Byte=hwtypes.mid(i+offset,1); byte16=(int16_t)Byte.toInt(&ok,16); qba=controlNames.mid(3*(i+NUM_STICKS+offset),3).toAscii(); if (ok) generalSettings.potConfig[i]=byte16; strcpy(generalSettings.potName[i], qba.data()); } offset += GetCurrentFirmware()->getCapability(Pots); for (int i=0; i<(GetCurrentFirmware()->getCapability(Sliders)); i++) { Byte=hwtypes.mid(i+offset,1); byte16=(int16_t)Byte.toInt(&ok,16); qba=controlNames.mid(3*(i+NUM_STICKS+offset),3).toAscii(); if (ok) generalSettings.sliderConfig[i]=byte16; strcpy(generalSettings.sliderName[i], qba.data()); } } else { QMessageBox::critical(this, tr("Warning"), tr("Wrong data in profile, Switch/pot config not retrieved")); } if ((DisplaySet.length()==6) && (BeeperSet.length()==4) && (HapticSet.length()==6) && (SpeakerSet.length()==6)) { generalSettings.stickMode=GSStickMode; uint8_t byte8u; int8_t byte8; QString chars; bool ok; byte8=(int8_t)DisplaySet.mid(0,2).toInt(&ok,16); if (ok) generalSettings.optrexDisplay=(byte8==1 ? true : false); byte8u=(uint8_t)DisplaySet.mid(2,2).toUInt(&ok,16); if (ok) generalSettings.contrast=byte8u; byte8u=(uint8_t)DisplaySet.mid(4,2).toUInt(&ok,16); if (ok) generalSettings.backlightBright=byte8u; byte8=(int8_t)BeeperSet.mid(0,2).toUInt(&ok,16); if (ok) 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=(GeneralSettings::BeeperMode)byte8; byte8=(int8_t)HapticSet.mid(2,2).toInt(&ok,16); if (ok) generalSettings.hapticStrength=byte8; byte8=(int8_t)HapticSet.mid(4,2).toInt(&ok,16); if (ok) generalSettings.hapticLength=byte8; byte8u=(uint8_t)SpeakerSet.mid(0,2).toUInt(&ok,16); if (ok) generalSettings.speakerMode=byte8u; byte8u=(uint8_t)SpeakerSet.mid(2,2).toUInt(&ok,16); if (ok) generalSettings.speakerPitch=byte8u; byte8u=(uint8_t)SpeakerSet.mid(4,2).toUInt(&ok,16); if (ok) generalSettings.speakerVolume=byte8u; if (CountrySet.length()==6) { byte8u=(uint8_t)CountrySet.mid(0,2).toUInt(&ok,16); if (ok) generalSettings.countryCode=byte8u; byte8u=(uint8_t)CountrySet.mid(2,2).toUInt(&ok,16); if (ok) generalSettings.imperial=byte8u; chars=CountrySet.mid(4,2); generalSettings.ttsLanguage[0]=chars[0].toAscii(); generalSettings.ttsLanguage[1]=chars[1].toAscii(); } } else { QMessageBox::critical(this, tr("Warning"), tr("Wrong data in profile, hw related parameters were not retrieved")); } } emit modified(); }
void AppPreferencesDialog::initSettings() { ui->snapshotClipboardCKB->setChecked(g.snapToClpbrd()); ui->burnFirmware->setChecked(g.profile[g.id()].burnFirmware()); ui->snapshotPath->setText(g.snapshotDir()); ui->snapshotPath->setReadOnly(true); if (ui->snapshotClipboardCKB->isChecked()) { ui->snapshotPath->setDisabled(true); ui->snapshotPathButton->setDisabled(true); } ui->startupCheck_companion9x->setChecked(g.autoCheckApp()); ui->startupCheck_fw->setChecked(g.autoCheckFw()); ui->showSplash->setChecked(g.showSplash()); ui->historySize->setValue(g.historySize()); ui->backLightColor->setCurrentIndex(g.backLight()); if (IS_TARANIS(GetCurrentFirmware()->getBoard())) { ui->backLightColor->setEnabled(false); } ui->simuSW->setChecked(g.simuSW()); ui->modelWizard_CB->setChecked(g.useWizard()); ui->libraryPath->setText(g.libDir()); ui->ge_lineedit->setText(g.gePath()); if (!g.backupDir().isEmpty()) { if (QDir(g.backupDir()).exists()) { ui->backupPath->setText(g.backupDir()); ui->backupEnable->setEnabled(true); ui->backupEnable->setChecked(g.enableBackup()); } else { ui->backupEnable->setDisabled(true); } } else { ui->backupEnable->setDisabled(true); } ui->splashincludeCB->setCurrentIndex(g.embedSplashes()); #ifdef JOYSTICKS ui->joystickChkB->setChecked(g.jsSupport()); if (ui->joystickChkB->isChecked()) { QStringList joystickNames; joystickNames << tr("No joysticks found"); joystick = new Joystick(0,false,0,0); ui->joystickcalButton->setDisabled(true); ui->joystickCB->setDisabled(true); if ( joystick ) { if ( joystick->joystickNames.count() > 0 ) { joystickNames = joystick->joystickNames; ui->joystickCB->setEnabled(true); ui->joystickcalButton->setEnabled(true); } joystick->close(); } ui->joystickCB->clear(); ui->joystickCB->insertItems(0, joystickNames); ui->joystickCB->setCurrentIndex(g.jsCtrl()); } else { ui->joystickCB->clear(); ui->joystickCB->setDisabled(true); ui->joystickcalButton->setDisabled(true); } #endif // Profile Tab Inits ui->channelorderCB->setCurrentIndex(g.profile[g.id()].channelOrder()); ui->stickmodeCB->setCurrentIndex(g.profile[g.id()].defaultMode()); ui->renameFirmware->setChecked(g.profile[g.id()].renameFwFiles()); ui->sdPath->setText(g.profile[g.id()].sdPath()); if (!g.profile[g.id()].pBackupDir().isEmpty()) { if (QDir(g.profile[g.id()].pBackupDir()).exists()) { ui->profilebackupPath->setText(g.profile[g.id()].pBackupDir()); ui->pbackupEnable->setEnabled(true); ui->pbackupEnable->setChecked(g.profile[g.id()].penableBackup()); } else { ui->pbackupEnable->setDisabled(true); } } else { ui->pbackupEnable->setDisabled(true); } ui->profileNameLE->setText(g.profile[g.id()].name()); ui->SplashFileName->setText(g.profile[g.id()].splashFile()); displayImage( g.profile[g.id()].splashFile() ); QString hwSettings; if (g.profile[g.id()].stickPotCalib() == "" ) { hwSettings = tr("EMPTY: No radio settings stored in profile"); } else { QString str = g.profile[g.id()].timeStamp(); if (str.isEmpty()) hwSettings = tr("AVAILABLE: Radio settings of unknown age"); else hwSettings = tr("AVAILABLE: Radio settings stored %1").arg(str); } ui->lblGeneralSettings->setText(hwSettings); FirmwareInterface * current_firmware = GetCurrentFirmware(); foreach(FirmwareInterface * firmware, firmwares) { ui->downloadVerCB->addItem(firmware->getName(), firmware->getId()); if (current_firmware->getFirmwareBase() == firmware) { ui->downloadVerCB->setCurrentIndex(ui->downloadVerCB->count() - 1); } }