QStringList getAvrdudeArgs(const QString &cmd, const QString &filename) { QStringList args; burnConfigDialog bcd; QString programmer = bcd.getProgrammer(); QString mcu = bcd.getMCU(); args << "-c" << programmer << "-p"; if (IS_2560(GetEepromInterface()->getBoard())) args << "m2560"; else if (GetEepromInterface()->getBoard() == BOARD_M128) args << "m128"; else args << mcu; args << bcd.getAvrdudeArgs(); QString fullcmd = cmd + filename; if (QFileInfo(filename).suffix().toUpper() == "HEX") fullcmd += ":i"; else if (QFileInfo(filename).suffix().toUpper()=="BIN") fullcmd += ":r"; else fullcmd += ":a"; args << "-U" << fullcmd; return args; }
QString getRadioInterfaceCmd() { burnConfigDialog bcd; EEPROMInterface *eepromInterface = GetEepromInterface(); if (IS_TARANIS(eepromInterface->getBoard())) { return bcd.getDFU(); } else if (IS_SKY9X(GetEepromInterface()->getBoard())) { return bcd.getSAMBA(); } else { return bcd.getAVRDUDE(); } }
void burnDialog::checkFw(QString fileName) { if (fileName.isEmpty()) { return; } if (!IS_TARANIS(GetEepromInterface()->getBoard())) { ui->EEbackupCB->show(); } else { ui->EEbackupCB->setChecked(false); *backup=false; } ui->FWFileName->setText(fileName); FlashInterface flash(fileName); if (flash.isValid()) { ui->FramFWInfo->show(); ui->DateField->setText(flash.getDate() + " " + flash.getTime()); ui->versionField->setText(flash.getVersion()); ui->ModField->setText(flash.getEEprom()); ui->SplashFrame->hide(); if (flash.hasSplash()) { ui->SplashFrame->show(); ui->imageLabel->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight()); } } else { QMessageBox::warning(this, tr("Warning"), tr("%1 may not be a valid firmware file").arg(fileName)); } ui->BurnFlashButton->setEnabled(true); QTimer::singleShot(0, this, SLOT(shrink())); g.flashDir( QFileInfo(fileName).dir().absolutePath() ); }
bool MdiChild::saveAs(bool isNew) { QString fileName; if (IS_SKY9X(GetEepromInterface()->getBoard())) { curFile.replace(".eepe", ".bin"); QFileInfo fi(curFile); #ifdef __APPLE__ fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" +fi.fileName()); #else fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" +fi.fileName(), tr(BIN_FILES_FILTER)); #endif } else { QFileInfo fi(curFile); #ifdef __APPLE__ fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" +fi.fileName()); #else fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" +fi.fileName(), tr(EEPROM_FILES_FILTER)); #endif } if (fileName.isEmpty()) return false; g.eepromDir( QFileInfo(fileName).dir().absolutePath() ); if (isNew) return saveFile(fileName); else return saveFile(fileName,true); }
void WizMix::addMix(ModelData &model, Input input, int weight, int channel, int & mixIndex) { if (input != NO_INPUT) { bool isTaranis = IS_TARANIS(GetEepromInterface()->getBoard()); if (input >= RUDDER_INPUT && input <= AILERONS_INPUT) { MixData & mix = model.mixData[mixIndex++]; mix.destCh = channel+1; if (isTaranis) { int channel = settings.getDefaultChannel(input-1); mix.srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, channel); } else mix.srcRaw = RawSource(SOURCE_TYPE_STICK, input-1); mix.weight = weight; } else if (input==FLAPS_INPUT) { // There ought to be some kind of constants for switches somewhere... maxMixSwitch((char *)"Flaps Up", model.mixData[mixIndex++], channel+1, isTaranis ? SWITCH_SA0 :-SWITCH_ELE , weight); //Taranis SA-UP, 9X ELE-UP maxMixSwitch((char *)"Flaps Down", model.mixData[mixIndex++], channel+1, isTaranis ? SWITCH_SA2 : SWITCH_ELE , -weight); //Taranis SA-DOWN, 9X ELE-DOWN } else if (input==AIRBRAKES_INPUT) { maxMixSwitch((char *)"Airbrk Off", model.mixData[mixIndex++], channel+1, isTaranis ? SWITCH_SE0 :-SWITCH_RUD , -weight); //Taranis SE-UP, 9X RUD-UP maxMixSwitch((char *)"Airbrk On", model.mixData[mixIndex++], channel+1, isTaranis ? SWITCH_SE2 : SWITCH_RUD , weight); //Tatanis SE-DOWN, 9X RUD-DOWN } } }
void ModelData::setDefaultMixes(const GeneralSettings & settings) { if (IS_TARANIS(GetEepromInterface()->getBoard())) { setDefaultInputs(settings); } for (int i=0; i<NUM_STICKS; i++) { MixData * mix = &mixData[i]; mix->destCh = i+1; mix->weight = 100; if (IS_TARANIS(GetEepromInterface()->getBoard())) { mix->srcRaw = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i); } else { mix->srcRaw = RawSource(SOURCE_TYPE_STICK, i); } } }
void RepeatComboBox::update() { unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10; int value = repeatParam/step; if (step == 1) { value++; } setCurrentIndex(value); }
TelemetryPanel::TelemetryPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::Telemetry) { ui->setupUi(this); if (firmware->getCapability(NoTelemetryProtocol)) { model.frsky.usrProto = 1; } analogs[0] = new TelemetryAnalog(this, model.frsky.channels[0], model, generalSettings, firmware); ui->A1Layout->addWidget(analogs[0]); connect(analogs[0], SIGNAL(modified()), this, SLOT(onAnalogModified())); analogs[1] = new TelemetryAnalog(this, model.frsky.channels[1], model, generalSettings, firmware); ui->A2Layout->addWidget(analogs[1]); connect(analogs[1], SIGNAL(modified()), this, SLOT(onAnalogModified())); if (IS_ARM(GetEepromInterface()->getBoard())) { analogs[2] = new TelemetryAnalog(this, model.frsky.channels[2], model, generalSettings, firmware); ui->A3Layout->addWidget(analogs[2]); connect(analogs[2], SIGNAL(modified()), this, SLOT(onAnalogModified())); analogs[3] = new TelemetryAnalog(this, model.frsky.channels[3], model, generalSettings, firmware); ui->A4Layout->addWidget(analogs[3]); connect(analogs[3], SIGNAL(modified()), this, SLOT(onAnalogModified())); } else { ui->A3GB->hide(); ui->A4GB->hide(); } for (int i=0; i<firmware->getCapability(TelemetryCustomScreens); i++) { TelemetryCustomScreen * tab = new TelemetryCustomScreen(this, model, model.frsky.screens[i], generalSettings, firmware); ui->customScreens->addTab(tab, tr("Telemetry screen %1").arg(i+1)); } if (IS_ARM(GetEepromInterface()->getBoard())) { ui->bladesCount->setMinimum(1); ui->bladesCount->setMaximum(128); } setup(); }
QString FuncSwData::repeatToString() { if (repeatParam==0) { return QObject::tr("No repeat"); } else { unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10; return QObject::tr("%1 sec").arg(step*repeatParam); } }
QString AnalogString(int index) { static const QString sticks[] = { QObject::tr("Rud"), QObject::tr("Ele"), QObject::tr("Thr"), QObject::tr("Ail") }; static const QString pots9X[] = { QObject::tr("P1"), QObject::tr("P2"), QObject::tr("P3") }; static const QString potsTaranis[] = { QObject::tr("S1"), QObject::tr("S2"), QObject::tr("S3"), QObject::tr("LS"), QObject::tr("RS") }; if (index < 4) return CHECK_IN_ARRAY(sticks, index); else return (IS_TARANIS(GetEepromInterface()->getBoard()) ? CHECK_IN_ARRAY(potsTaranis, index-4) : CHECK_IN_ARRAY(pots9X, index-4)); }
WizMix::operator ModelData() { int throttleChannel = -1; bool isTaranis = IS_TARANIS(GetEepromInterface()->getBoard()); ModelData model; model.used = true; model.modelId = modelId; model.setDefaultInputs(settings); int mixIndex = 0; int switchIndex = 0; int timerIndex = 0; // Safe copy model name strncpy(model.name, name, WIZ_MODEL_NAME_LENGTH); model.name[WIZ_MODEL_NAME_LENGTH] = 0; // Add the channel mixes for (int i=0; i<WIZ_MAX_CHANNELS; i++ ) { Channel ch = channel[i]; if (ch.input1 == THROTTLE_INPUT || ch.input2 == THROTTLE_INPUT) throttleChannel = i; addMix(model, ch.input1, ch.weight1, i, mixIndex); addMix(model, ch.input2, ch.weight2, i, mixIndex); } // Add the Throttle Cut option if( options[THROTTLE_CUT_OPTION] && throttleChannel >=0 ) { model.funcSw[switchIndex].swtch.type = SWITCH_TYPE_SWITCH; model.funcSw[switchIndex].swtch.index = isTaranis ? SWITCH_SF0 : SWITCH_THR; model.funcSw[switchIndex].enabled = 1; model.funcSw[switchIndex].func = (AssignFunc)throttleChannel; model.funcSw[switchIndex].param = -100; } // Add the Flight Timer option if (options[FLIGHT_TIMER_OPTION] ) { model.timers[timerIndex].mode.type = SWITCH_TYPE_TIMER_MODE; model.timers[timerIndex].mode.index = TMRMODE_THR_TRG; timerIndex++; } // Add the Throttle Timer option if (options[THROTTLE_TIMER_OPTION] && throttleChannel >=0) { model.timers[timerIndex].mode.type = SWITCH_TYPE_TIMER_MODE; model.timers[timerIndex].mode.index = TMRMODE_THR; timerIndex++; } return model; }
void ExpoDialog::widgetChanged() { if (GetEepromInterface()->getCapability(GvarsAsWeight)) { int gvars=0; if (GetEepromInterface()->getCapability(HasVariants)) { if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) { gvars=1; } } else { gvars=1; } if (gvars==1) { if (!GetEepromInterface()->getCapability(ExpoIsCurve)) { if (ui->expoGV->isChecked()) { ui->expoCB->show(); ui->expoSB->hide(); } else { ui->expoCB->hide(); ui->expoSB->show(); } } else { if (ui->expoCurveGV->isChecked()) { ui->expoCurveCB->show(); ui->expoCurveSB->hide(); } else { ui->expoCurveCB->hide(); ui->expoCurveSB->show(); } } if (ui->weightGV->isChecked()) { ui->weightCB->show(); ui->weightSB->hide(); } else { ui->weightCB->hide(); ui->weightSB->show(); } } valuesChanged(); QTimer::singleShot(0, this, SLOT(shrink())); } }
void ModelData::setDefaultInputs(const GeneralSettings & settings) { if (IS_TARANIS(GetEepromInterface()->getBoard())) { for (int i=0; i<NUM_STICKS; i++) { ExpoData * expo = &expoData[i]; expo->chn = i; expo->mode = INPUT_MODE_BOTH; expo->srcRaw = settings.getDefaultSource(i); expo->weight = 100; strncpy(inputNames[i], expo->srcRaw.toString(*this).toLatin1().constData(), sizeof(inputNames[i])-1); } } }
QStringList getWriteEEpromCmd(const QString &filename) { EEPROMInterface *eepromInterface = GetEepromInterface(); if (IS_TARANIS(eepromInterface->getBoard())) { // impossible return QStringList(); } else if (IS_SKY9X(eepromInterface->getBoard())) { return getSambaArgs(QString("SERIALFLASH::Init 0\n") + "send_file {SerialFlash AT25} \"" + filename + "\" 0x0 0\n"); } else { return getAvrdudeArgs("eeprom:w:", filename); } }
QStringList getReadEEpromCmd(const QString &filename) { QStringList result; EEPROMInterface *eepromInterface = GetEepromInterface(); if (IS_TARANIS(eepromInterface->getBoard())) { // impossible } else if (IS_SKY9X(eepromInterface->getBoard())) { result = getSambaArgs(QString("SERIALFLASH::Init 0\n") + "receive_file {SerialFlash AT25} \"" + filename + "\" 0x0 0x80000 0\n"); } else { result = getAvrdudeArgs("eeprom:r:", filename); } return result; }
void burnDialog::on_FlashLoadButton_clicked() { QString fileName; ui->BurnFlashButton->setDisabled(true); ui->FWFileName->clear(); ui->DateField->clear(); ui->versionField->clear(); ui->ModField->clear(); ui->FramFWInfo->hide(); ui->SplashFrame->hide(); ui->BurnFlashButton->setDisabled(true); ui->EEbackupCB->hide(); QTimer::singleShot(0, this, SLOT(shrink())); if (hexType==FLASH_FILE_TYPE) { fileName = QFileDialog::getOpenFileName(this, tr("Open Firmware File"), g.flashDir(), FLASH_FILES_FILTER); if(fileName.isEmpty()) return; checkFw(fileName); } else { QString fileName = QFileDialog::getOpenFileName(this,tr("Choose Radio Backup file"), g.eepromDir(), tr(EXTERNAL_EEPROM_FILES_FILTER)); if (checkeEprom(fileName)) { if (burnraw==false) { ui->BurnFlashButton->setEnabled(true); ui->profile_label->show(); ui->patchcalib_CB->show(); ui->patchhw_CB->show(); if (!IS_TARANIS(GetEepromInterface()->getBoard())) { ui->EEpromCB->show(); } else { ui->EEpromCB->setChecked(false); } } else { ui->BurnFlashButton->setEnabled(true); ui->profile_label->hide(); ui->patchcalib_CB->setChecked(false); ui->patchhw_CB->setChecked(false); ui->patchhw_CB->hide(); ui->patchcalib_CB->hide(); } QTimer::singleShot(0, this, SLOT(shrink())); } } updateUI(); }
QStringList getReadFirmwareArgs(const QString &filename) { EEPROMInterface *eepromInterface = GetEepromInterface(); if (IS_TARANIS(eepromInterface->getBoard())) { return getDfuArgs("-U", filename); } else if (eepromInterface->getBoard() == BOARD_SKY9X) { return getSambaArgs(QString("receive_file {Flash} \"") + filename + "\" 0x400000 0x40000 0\n"); } else if (eepromInterface->getBoard() == BOARD_9XRPRO) { return getSambaArgs(QString("receive_file {Flash} \"") + filename + "\" 0x400000 0x80000 0\n"); } else { return getAvrdudeArgs("flash:r:", filename); } }
QStringList getWriteFirmwareArgs(const QString &filename) { EEPROMInterface *eepromInterface = GetEepromInterface(); if (IS_TARANIS(eepromInterface->getBoard())) { return getDfuArgs("-D", filename); } else if (eepromInterface->getBoard() == BOARD_SKY9X) { return getSambaArgs(QString("send_file {Flash} \"") + filename + "\" 0x400000 0\n" + "FLASH::ScriptGPNMV 2\n"); } else if (eepromInterface->getBoard() == BOARD_9XRPRO) { return getSambaArgs(QString("send_file {Flash} \"") + filename + "\" 0x400000 0\n" + "FLASH::ScriptGPNMV 2\n"); } else { return getAvrdudeArgs("flash:w:", filename); } }
TelemetryAnalog::TelemetryAnalog(QWidget *parent, FrSkyChannelData & analog, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware): ModelPanel(parent, model, generalSettings, firmware), ui(new Ui::TelemetryAnalog), analog(analog), lock(false) { ui->setupUi(this); float ratio = analog.getRatio(); if (analog.type==0 || analog.type==1 || analog.type==2) { ui->RatioSB->setDecimals(1); ui->RatioSB->setMaximum(25.5*firmware->getCapability(TelemetryMaxMultiplier)); } else { ui->RatioSB->setDecimals(0); ui->RatioSB->setMaximum(255*firmware->getCapability(TelemetryMaxMultiplier)); } ui->RatioSB->setValue(ratio); update(); ui->UnitCB->setCurrentIndex(analog.type); if (!IS_TARANIS(GetEepromInterface()->getBoard())) { ui->alarm1LevelCB->setCurrentIndex(analog.alarms[0].level); ui->alarm1GreaterCB->setCurrentIndex(analog.alarms[0].greater); ui->alarm2LevelCB->setCurrentIndex(analog.alarms[1].level); ui->alarm2GreaterCB->setCurrentIndex(analog.alarms[1].greater); } else { ui->alarm1LevelCB->hide(); ui->alarm2LevelCB->hide(); ui->alarm1GreaterCB->hide(); ui->alarm2GreaterCB->hide(); ui->alarm1Label->setText(tr("Low Alarm")); ui->alarm2Label->setText(tr("Critical Alarm")); } if (!(firmware->getCapability(Telemetry) & TM_HASOFFSET)) { ui->CalibSB->hide(); ui->CalibLabel->hide(); } else { ui->label_Max->setText(tr("Range")); } }
FlashFirmwareDialog::FlashFirmwareDialog(QWidget *parent): QDialog(parent), ui(new Ui::FlashFirmwareDialog), fwName(g.profile[g.id()].fwName()) { ui->setupUi(this); if (!g.profile[g.id()].splashFile().isEmpty()){ imageSource = PROFILE; imageFile = g.profile[g.id()].splashFile(); ui->useProfileSplash->setChecked(true); } else { imageSource = FIRMWARE; imageFile = ""; ui->useProfileSplash->setDisabled(true); } if (IS_TARANIS(GetEepromInterface()->getBoard())) { // No backup on Taranis ... could be done if in massstorage ui->backupEEprom->hide(); ui->backupEEprom->setCheckState(Qt::Unchecked); } else { ui->backupEEprom->setCheckState(g.backupOnFlash() ? Qt::Checked : Qt::Unchecked); } QString backupPath = g.profile[g.id()].pBackupDir(); if (backupPath.isEmpty()) { backupPath=g.backupDir(); } if (backupPath.isEmpty() || !QDir(backupPath).exists()) { ui->backupEEprom->setEnabled(false); } ui->checkHardwareCompatibility->setChecked(g.checkHardwareCompatibility()); updateUI(); resize(0, 0); // TODO needed? }
RepeatComboBox::RepeatComboBox(QWidget *parent, int & repeatParam): QComboBox(parent), repeatParam(repeatParam) { unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10; int value = repeatParam/step; if (step == 1) { addItem(QObject::tr("Played once, not during startup"), -1); value++; } addItem(QObject::tr("No repeat"), 0); for (unsigned int i=step; i<=60; i+=step) { addItem(QObject::tr("%1s").arg(i), i); } setCurrentIndex(value); connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int))); }
void ModelData::clear() { memset(this, 0, sizeof(ModelData)); moduleData[0].channelsCount = 8; moduleData[1].channelsStart = 0; moduleData[1].channelsCount = 8; moduleData[0].ppmDelay = 300; moduleData[1].ppmDelay = 300; moduleData[2].ppmDelay = 300; int board = GetEepromInterface()->getBoard(); if (IS_TARANIS(board)) { moduleData[0].protocol=PXX_XJT_X16; moduleData[1].protocol=OFF; } else { moduleData[0].protocol=PPM; moduleData[1].protocol=OFF; } for (int i=0; i<C9X_MAX_FLIGHT_MODES; i++) { flightModeData[i].clear(); } clearInputs(); clearMixes(); for (int i=0; i<C9X_NUM_CHNOUT; i++) limitData[i].clear(); for (int i=0; i<NUM_STICKS; i++) expoData[i].clear(); for (int i=0; i<C9X_NUM_CSW; i++) customSw[i].clear(); for (int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++) funcSw[i].clear(); for (int i=0; i<C9X_MAX_CURVES; i++) curves[i].clear(5); for (int i=0; i<2; i++) timers[i].clear(); swashRingData.clear(); frsky.clear(); }
void burnConfigDialog::on_advCtrChkB_toggled(bool checked) { EEPROMInterface *eepromInterface = GetEepromInterface(); if (checked) { if (IS_TARANIS(eepromInterface->getBoard())) { ui->label_dfu2->show(); ui->dfuArgs->show(); } else if (IS_SKY9X(eepromInterface->getBoard())) { ui->label_sb2->show(); ui->arm_mcu->show(); } else { ui->label_av3->show(); ui->avrdude_mcu->show(); QMessageBox::warning(this, tr("Companion"), tr("<b><u>WARNING!</u></b><br>Normally CPU type is automatically selected according to the chosen firmware.<br>If you change the CPU type the resulting eeprom could be inconsistent."), QMessageBox::Ok); } } else { if (IS_TARANIS(eepromInterface->getBoard())) { ui->label_dfu2->hide(); ui->dfuArgs->hide(); } else if (IS_SKY9X(eepromInterface->getBoard())) { ui->label_sb2->hide(); ui->arm_mcu->hide(); } else { ui->label_av3->hide(); ui->avrdude_mcu->hide(); } } QTimer::singleShot(0, this, SLOT(shrink())); }
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) { unsigned int widgetsMask = 0; if (modified) { model.funcSw[i].swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt()); model.funcSw[i].func = (AssignFunc)fswtchFunc[i]->currentIndex(); model.funcSw[i].enabled = fswtchEnable[i]->isChecked(); model.funcSw[i].adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex(); } int index = fswtchFunc[i]->currentIndex(); if (index>=FuncOverrideCH1 && index<=FuncOverrideCH32) { int channelsMax = model.getChannelsMax(true); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setMinimum(-channelsMax); fswtchParam[i]->setMaximum(channelsMax); if (modified) { model.funcSw[i].param = fswtchParam[i]->value(); } fswtchParam[i]->setValue(model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (index==FuncLogs) { fswtchParam[i]->setDecimals(1); fswtchParam[i]->setMinimum(0); fswtchParam[i]->setMaximum(25.5); fswtchParam[i]->setSingleStep(0.1); if (modified) model.funcSw[i].param = fswtchParam[i]->value()*10.0; fswtchParam[i]->setValue(model.funcSw[i].param/10.0); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } else if (index>=FuncAdjustGV1 && index<=FuncAdjustGVLast) { if (modified) model.funcSw[i].adjustMode = fswtchGVmode[i]->currentIndex(); widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE; if (model.funcSw[i].adjustMode==0) { if (modified) model.funcSw[i].param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); if (IS_ARM(GetEepromInterface()->getBoard())) { fswtchParam[i]->setMinimum(-500); fswtchParam[i]->setMaximum(500); } else { fswtchParam[i]->setMinimum(-125); fswtchParam[i]->setMaximum(125); } fswtchParam[i]->setValue(model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } else { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param, model.funcSw[i].adjustMode); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } else if (index==FuncReset) { if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; } else if (index>=FuncSetTimer1 && index<=FuncSetTimer2) { if (modified) model.funcSw[i].param = QTimeS(fswtchParamTime[i]->time()).seconds(); fswtchParamTime[i]->setMinimumTime(QTime(0, 0, 0)); fswtchParamTime[i]->setMaximumTime(QTime(0, 59, 59)); fswtchParamTime[i]->setTime(QTimeS(model.funcSw[i].param)); widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (index==FuncVolume) { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { if (index != FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_REPEAT; fswtchRepeat[i]->update(); } if (index==FuncPlayValue) { if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT; } else if (index==FuncPlayPrompt || index==FuncPlayBoth) { if (firmware->getCapability(VoicesAsNumbers)) { fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setMinimum(0); if (index==FuncPlayPrompt) { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT + CUSTOM_FUNCTION_GV_TOOGLE; } else { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT; fswtchParamGV[i]->setChecked(false); } fswtchParam[i]->setMaximum(index==FuncPlayBoth ? 254 : 255); if (modified) { if (fswtchParamGV[i]->isChecked()) { fswtchParam[i]->setMinimum(1); model.funcSw[i].param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0); } else { model.funcSw[i].param = fswtchParam[i]->value(); } } if (model.funcSw[i].param>250 && (index!=FuncPlayBoth)) { fswtchParamGV[i]->setChecked(true); fswtchParam[i]->setValue(model.funcSw[i].param-250); fswtchParam[i]->setMaximum(5); } else { fswtchParamGV[i]->setChecked(false); fswtchParam[i]->setValue(model.funcSw[i].param); } if (model.funcSw[i].param < 251) widgetsMask |= CUSTOM_FUNCTION_PLAY; } else { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); int vml = firmware->getCapability(VoicesMaxLength); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) { model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); } } } populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, tracksSet); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; } } } else if (index==FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); int vml=firmware->getCapability(VoicesMaxLength); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(),vml); j++) { model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); } } } populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, tracksSet); } else if (index==FuncPlaySound) { if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } else if (index==FuncPlayHaptic) { if (modified) model.funcSw[i].param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], model, index, model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } else if (index==FuncPlayScript) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); int vml = 8/*TODO*/; if (fswtchParamArmT[i]->currentText() != "----") { for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) { model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j); } } } populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, scriptsSet); } else if (index==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) { if (modified) model.funcSw[i].param = (uint8_t)fswtchBLcolor[i]->value(); fswtchBLcolor[i]->setValue(model.funcSw[i].param); widgetsMask |= CUSTOM_FUNCTION_BL_COLOR; } else { if (modified) model.funcSw[i].param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setValue(model.funcSw[i].param); if (index <= FuncInstantTrim) { widgetsMask |= CUSTOM_FUNCTION_ENABLE; } } fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_PARAM); fswtchParamTime[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_TIME_PARAM); fswtchParamGV[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_TOOGLE); fswtchParamT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SOURCE_PARAM); fswtchParamArmT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_FILE_PARAM); fswtchEnable[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_ENABLE); if (widgetsMask & CUSTOM_FUNCTION_ENABLE) fswtchEnable[i]->setChecked(model.funcSw[i].enabled); else fswtchEnable[i]->setChecked(false); fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT); fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE); fswtchBLcolor[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_BL_COLOR); #ifdef PHONON playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY); #endif }
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified) { CustomFunctionData & cfn = functions[i]; AssignFunc func = (AssignFunc)fswtchFunc[i]->itemData(fswtchFunc[i]->currentIndex()).toInt(); unsigned int widgetsMask = 0; if (modified) { cfn.swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt()); cfn.func = func; cfn.enabled = fswtchEnable[i]->isChecked(); cfn.adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex(); } if (func>=FuncOverrideCH1 && func<=FuncOverrideCH32) { if (model) { int channelsMax = model->getChannelsMax(true); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setMinimum(-channelsMax); fswtchParam[i]->setMaximum(channelsMax); if (modified) { cfn.param = fswtchParam[i]->value(); } fswtchParam[i]->setValue(cfn.param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE; } } else if (func==FuncLogs) { fswtchParam[i]->setDecimals(1); fswtchParam[i]->setMinimum(0); fswtchParam[i]->setMaximum(25.5); fswtchParam[i]->setSingleStep(0.1); if (modified) cfn.param = fswtchParam[i]->value()*10.0; fswtchParam[i]->setValue(cfn.param/10.0); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } else if (func>=FuncAdjustGV1 && func<=FuncAdjustGVLast) { if (modified) cfn.adjustMode = fswtchGVmode[i]->currentIndex(); widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE; if (cfn.adjustMode==0) { if (modified) cfn.param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); if (IS_ARM(GetEepromInterface()->getBoard())) { fswtchParam[i]->setMinimum(-500); fswtchParam[i]->setMaximum(500); } else { fswtchParam[i]->setMinimum(-125); fswtchParam[i]->setMaximum(125); } fswtchParam[i]->setValue(cfn.param); widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM; } else { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param, cfn.adjustMode); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } else if (func==FuncReset) { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE; } else if (func>=FuncSetTimer1 && func<=FuncSetTimer3) { if (modified) cfn.param = QTimeS(fswtchParamTime[i]->time()).seconds(); fswtchParamTime[i]->setMinimumTime(QTime(0, 0, 0)); fswtchParamTime[i]->setMaximumTime(firmware->getMaxTimerStart()); fswtchParamTime[i]->setTime(QTimeS(cfn.param)); widgetsMask |= CUSTOM_FUNCTION_TIME_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (func>=FuncSetFailsafeInternalModule && func<=FuncBindExternalModule) { widgetsMask |= CUSTOM_FUNCTION_ENABLE; } else if (func==FuncVolume) { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE; } else if (func==FuncPlaySound || func==FuncPlayHaptic || func==FuncPlayValue || func==FuncPlayPrompt || func==FuncPlayBoth || func==FuncBackgroundMusic) { if (func != FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_REPEAT; fswtchRepeat[i]->update(); } if (func==FuncPlayValue) { if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT; } else if (func==FuncPlayPrompt || func==FuncPlayBoth) { if (firmware->getCapability(VoicesAsNumbers)) { fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setMinimum(0); if (func==FuncPlayPrompt) { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT + CUSTOM_FUNCTION_GV_TOOGLE; } else { widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT; fswtchParamGV[i]->setChecked(false); } fswtchParam[i]->setMaximum(func==FuncPlayBoth ? 254 : 255); if (modified) { if (fswtchParamGV[i]->isChecked()) { fswtchParam[i]->setMinimum(1); cfn.param = std::min(fswtchParam[i]->value(),5.0)+(fswtchParamGV[i]->isChecked() ? 250 : 0); } else { cfn.param = fswtchParam[i]->value(); } } if (cfn.param>250 && (func!=FuncPlayBoth)) { fswtchParamGV[i]->setChecked(true); fswtchParam[i]->setValue(cfn.param-250); fswtchParam[i]->setMaximum(5); } else { fswtchParamGV[i]->setChecked(false); fswtchParam[i]->setValue(cfn.param); } if (cfn.param < 251) widgetsMask |= CUSTOM_FUNCTION_PLAY; } else { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength)); } populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; } } } else if (func==FuncBackgroundMusic) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, firmware->getCapability(VoicesMaxLength)); } populateFileComboBox(fswtchParamArmT[i], tracksSet, cfn.paramarm); if (fswtchParamArmT[i]->currentText() != "----") { widgetsMask |= CUSTOM_FUNCTION_PLAY; } } else if (func==FuncPlaySound) { if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } else if (func==FuncPlayHaptic) { if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex(); populateFuncParamCB(fswtchParamT[i], func, cfn.param); widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM; } } else if (func==FuncPlayScript) { widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM; if (modified) { getFileComboBoxValue(fswtchParamArmT[i], cfn.paramarm, 8); } populateFileComboBox(fswtchParamArmT[i], scriptsSet, cfn.paramarm); } else if (func==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) { if (modified) cfn.param = (uint8_t)fswtchBLcolor[i]->value(); fswtchBLcolor[i]->setValue(cfn.param); widgetsMask |= CUSTOM_FUNCTION_BL_COLOR; } else { if (modified) cfn.param = fswtchParam[i]->value(); fswtchParam[i]->setDecimals(0); fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setValue(cfn.param); if (func <= FuncInstantTrim) { widgetsMask |= CUSTOM_FUNCTION_ENABLE; } } fswtchParam[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_NUMERIC_PARAM); fswtchParamTime[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_TIME_PARAM); fswtchParamGV[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_TOOGLE); fswtchParamT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_SOURCE_PARAM); fswtchParamArmT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_FILE_PARAM); fswtchEnable[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_ENABLE); if (widgetsMask & CUSTOM_FUNCTION_ENABLE) fswtchEnable[i]->setChecked(cfn.enabled); else fswtchEnable[i]->setChecked(false); fswtchRepeat[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_REPEAT); fswtchGVmode[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_GV_MODE); fswtchBLcolor[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_BL_COLOR); #ifdef PHONON playBT[i]->setVisible(widgetsMask & CUSTOM_FUNCTION_PLAY); #endif }
burnConfigDialog::burnConfigDialog(QWidget *parent) : QDialog(parent), ui(new Ui::burnConfigDialog) { ui->setupUi(this); setWindowIcon(CompanionIcon("configure.png")); ui->avrdude_programmer->model()->sort(0); getSettings(); populateProgrammers(); EEPROMInterface *eepromInterface = GetEepromInterface(); if (IS_TARANIS(eepromInterface->getBoard())) { setWindowTitle(tr("DFU-UTIL Configuration")); ui->avrArgs->hide(); ui->avrdude_location->hide(); ui->avrdude_port->hide(); ui->avrdude_programmer->hide(); ui->label_av1->hide(); ui->label_av2->hide(); ui->label_av4->hide(); ui->label_av5->hide(); ui->pushButton->hide(); ui->pushButton_3->hide(); ui->pushButton_4->hide(); ui->label_sb1->hide(); ui->label_sb3->hide(); ui->samba_location->hide(); ui->samba_port->hide(); ui->sb_browse->hide(); } else if (IS_SKY9X(eepromInterface->getBoard())) { setWindowTitle(tr("SAM-BA Configuration")); ui->avrArgs->hide(); ui->avrdude_location->hide(); ui->avrdude_port->hide(); ui->avrdude_programmer->hide(); ui->label_av1->hide(); ui->label_av2->hide(); ui->label_av4->hide(); ui->label_av5->hide(); ui->pushButton->hide(); ui->pushButton_3->hide(); ui->pushButton_4->hide(); ui->label_dfu1->hide(); ui->dfu_location->hide(); ui->dfu_browse->hide(); } else { setWindowTitle(tr("AVRDUDE Configuration")); ui->label_sb1->hide(); ui->label_sb3->hide(); ui->samba_location->hide(); ui->samba_port->hide(); ui->sb_browse->hide(); ui->label_dfu1->hide(); ui->label_dfu2->hide(); ui->dfu_location->hide(); ui->dfu_browse->hide(); } ui->label_av3->hide(); ui->avrdude_mcu->hide(); ui->label_sb2->hide(); ui->arm_mcu->hide(); ui->label_dfu2->hide(); ui->dfuArgs->hide(); QTimer::singleShot(0, this, SLOT(shrink())); connect(this,SIGNAL(accepted()),this,SLOT(putSettings())); }
ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) : QDialog(parent), ui(new Ui::ExpoDialog), ed(expoData) { ui->setupUi(this); QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 }; QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; setWindowTitle(tr("DEST -> %1").arg(getStickStr(ed->chn))); QRegExp rx(CHAR_FOR_NAMES_REGEX); if (GetEepromInterface()->getCapability(GvarsAsWeight)) { int gvars=0; if (GetEepromInterface()->getCapability(HasVariants)) { if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) { gvars=1; } } else { gvars=1; } if (gvars==0) { ui->expoGV->setDisabled(true); ui->weightGV->setDisabled(true); ui->expoCurveGV->setDisabled(true); if (ed->expo>100) { ed->expo=0; } if (ed->weight>100 || ed->weight<-100) { ed->weight=100; } if (ed->curveParam>100 || ed->curveParam<-100) { ed->curveParam=0; } } populateGVCB(ui->expoCB,ed->expo); populateGVCB(ui->weightCB,ed->weight); populateGVCB(ui->expoCurveCB,ed->curveParam); ui->weightSB->setMinimum(0); ui->weightSB->setMaximum(100); if (ed->weight>100 || ed->weight<0) { ui->weightGV->setChecked(true); ui->weightSB->hide(); ui->weightCB->show(); } else { ui->weightGV->setChecked(false); ui->weightSB->setValue(ed->weight); ui->weightSB->show(); ui->weightCB->hide(); } ui->expoSB->setMinimum(-100); ui->expoSB->setMaximum(100); if (ed->expo>100 || ed->expo<-100) { ui->expoGV->setChecked(true); ui->expoSB->hide(); ui->expoCB->show(); } else { ui->expoGV->setChecked(false); ui->expoSB->setValue(ed->expo); ui->expoSB->show(); ui->expoCB->hide(); } ui->expoCurveSB->setMinimum(-100); ui->expoCurveSB->setMaximum(100); if (ed->curveParam>100 || ed->curveParam<-100) { ui->expoCurveGV->setChecked(true); ui->expoCurveSB->hide(); ui->expoCurveCB->show(); } else { ui->expoCurveGV->setChecked(false); ui->expoCurveSB->setValue(ed->curveParam); ui->expoCurveSB->show(); ui->expoCurveCB->hide(); } } else { ui->expoGV->hide(); ui->weightGV->hide(); ui->expoCurveGV->hide(); ui->expoSB->setMinimum(-100); ui->expoSB->setMaximum(100); ui->expoSB->setValue(ed->expo); ui->expoCurveSB->setMinimum(-100); ui->expoCurveSB->setMaximum(100); ui->expoCurveSB->setValue(ed->curveParam); ui->weightSB->setMinimum(0); ui->weightSB->setMaximum(100); ui->weightSB->setValue(ed->weight); } populateSwitchCB(ui->switchesCB,ed->swtch); if (ed->curveMode==0) { populateExpoCurvesCB(ui->curvesCB,0); // TODO capacity for er9x } else { populateExpoCurvesCB(ui->curvesCB,ed->curveParam); // TODO capacity for er9x } ui->modeCB->setCurrentIndex(ed->mode-1); if (!GetEepromInterface()->getCapability(HasExpoCurves)) { ui->label_curves->hide(); ui->curvesCB->hide(); ed->curveMode=1; } if (!GetEepromInterface()->getCapability(ExpoIsCurve)) { ui->expoCurveCB->hide(); ui->expoCurveSB->hide(); ui->expoCurveGV->hide(); ui->label_curves->setText(tr("Curve")); } else { ui->label_expo->hide(); ui->expoCB->hide(); ui->expoGV->hide(); ui->expoSB->hide(); } if (!GetEepromInterface()->getCapability(FlightPhases)) { ui->label_phases->hide(); for (int i=0; i<9; i++) { lb_fp[i]->hide(); cb_fp[i]->hide(); } } else { int mask=1; for (int i=0; i<9 ; i++) { if ((ed->phases & mask)==0) { cb_fp[i]->setChecked(true); } mask <<= 1; } for (int i=GetEepromInterface()->getCapability(FlightPhases); i<9;i++) { lb_fp[i]->hide(); cb_fp[i]->hide(); } } int expolength=GetEepromInterface()->getCapability(HasExpoNames); if (!expolength) { ui->label_name->hide(); ui->expoName->hide(); } else { ui->expoName->setMaxLength(expolength); } ui->expoName->setValidator(new QRegExpValidator(rx, this)); ui->expoName->setText(ed->name); valuesChanged(); connect(ui->expoName,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->expoCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->expoSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->expoCurveCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->expoCurveSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged())); connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->curvesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->modeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged())); connect(ui->expoGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); connect(ui->expoCurveGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); for (int i=0; i<9; i++) { connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged())); } QTimer::singleShot(0, this, SLOT(shrink())); }
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; }
Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware): ModelPanel(parent, model, generalSettings, firmware) { QGridLayout * gridLayout = new QGridLayout(this); bool minimize = false; int col = 1; if (firmware->getCapability(ChannelsName)) { minimize=true; addLabel(gridLayout, tr("Name"), col++); } addLabel(gridLayout, tr("Subtrim"), col++, minimize); addLabel(gridLayout, tr("Min"), col++, minimize); addLabel(gridLayout, tr("Max"), col++, minimize); addLabel(gridLayout, tr("Direction"), col++, minimize); if (IS_TARANIS(GetEepromInterface()->getBoard())) addLabel(gridLayout, tr("Curve"), col++, minimize); if (firmware->getCapability(PPMCenter)) addLabel(gridLayout, tr("PPM Center"), col++, minimize); if (firmware->getCapability(SYMLimits)) addLabel(gridLayout, tr("Linear Subtrim"), col++, true); for (int i=0; i<firmware->getCapability(Outputs); i++) { col = 0; // Channel label QLabel *label = new QLabel(this); label->setText(tr("Channel %1").arg(i+1)); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); gridLayout->addWidget(label, i+1, col++, 1, 1); // Channel name int nameLen = firmware->getCapability(ChannelsName); if (nameLen > 0) { QLineEdit * name = new QLineEdit(this); name->setProperty("index", i); name->setMaxLength(nameLen); QRegExp rx(CHAR_FOR_NAMES_REGEX); name->setValidator(new QRegExpValidator(rx, this)); name->setText(model.limitData[i].name); connect(name, SIGNAL(editingFinished()), this, SLOT(nameEdited())); gridLayout->addWidget(name, i+1, col++, 1, 1); } // Channel offset limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].offset, -1000, 1000, 0); // Channel min limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].min, -model.getChannelsMax()*10, 0, -1000); // Channel max limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].max, 0, model.getChannelsMax()*10, 1000); // Channel inversion QComboBox * invCB = new QComboBox(this); invCB->insertItems(0, QStringList() << tr("---") << tr("INV")); invCB->setProperty("index", i); invCB->setCurrentIndex((model.limitData[i].revert) ? 1 : 0); connect(invCB, SIGNAL(currentIndexChanged(int)), this, SLOT(invEdited())); gridLayout->addWidget(invCB, i+1, col++, 1, 1); // Curve if (IS_TARANIS(GetEepromInterface()->getBoard())) { QComboBox * curveCB = new QComboBox(this); curveCB->setProperty("index", i); int numcurves = firmware->getCapability(NumCurves); for (int j=-numcurves; j<=numcurves; j++) { curveCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, j).toString(), j); } curveCB->setCurrentIndex(model.limitData[i].curve.value+numcurves); connect(curveCB, SIGNAL(currentIndexChanged(int)), this, SLOT(curveEdited())); gridLayout->addWidget(curveCB, i+1, col++, 1, 1); } // PPM center if (firmware->getCapability(PPMCenter)) { QSpinBox * center = new QSpinBox(this); center->setProperty("index", i); center->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); center->setSuffix("us"); center->setMinimum(1375); center->setMaximum(1625); center->setValue(1500); center->setValue(model.limitData[i].ppmCenter + 1500); connect(center, SIGNAL(editingFinished()), this, SLOT(ppmcenterEdited())); gridLayout->addWidget(center, i+1, col++, 1, 1); } // Symetrical limits if (firmware->getCapability(SYMLimits)) { QCheckBox * symlimits = new QCheckBox(this); symlimits->setProperty("index", i); symlimits->setChecked(model.limitData[i].symetrical); connect(symlimits, SIGNAL(toggled(bool)), this, SLOT(symlimitsEdited())); gridLayout->addWidget(symlimits, i+1, col++, 1, 1); } }
void ExpoDialog::valuesChanged() { QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 }; if (ui->curvesCB->currentIndex()==0) { if (GetEepromInterface()->getCapability(ExpoIsCurve)) { ed->curveMode = 0; ui->expoCurveGV->show(); if (ui->expoCurveGV->isChecked()) { ui->expoCurveCB->show(); ui->expoCurveSB->hide(); ed->curveParam = ui->expoCurveCB->itemData(ui->expoCurveCB->currentIndex()).toInt(); } else { ui->expoCurveCB->hide(); ui->expoCurveSB->show(); ed->curveParam = ui->expoCurveSB->value(); } ed->expo = ed->curveParam; } else { ui->expoCurveCB->hide(); ui->expoCurveSB->hide(); ui->expoCurveGV->hide(); ed->curveMode = 0; if (ui->expoGV->isChecked()) { ed->expo = ui->expoCB->itemData(ui->expoCB->currentIndex()).toInt(); } else { ed->expo = ui->expoSB->value(); } ed->curveParam = ed->expo; } } else { if (!GetEepromInterface()->getCapability(ExpoIsCurve)) { ed->curveMode = 1; ed->curveParam = ui->curvesCB->currentIndex(); if (ui->expoGV->isChecked()) { ed->expo = ui->expoCB->itemData(ui->expoCB->currentIndex()).toInt(); } else { ed->expo = ui->expoSB->value(); } } else { ed->curveMode = 1; ed->curveParam = ui->curvesCB->currentIndex(); ed->expo = 0; } ui->expoCurveCB->hide(); ui->expoCurveSB->hide(); ui->expoCurveGV->hide(); } if (ui->weightGV->isChecked()) { ed->weight = ui->weightCB->itemData(ui->weightCB->currentIndex()).toInt(); } else { ed->weight = ui->weightSB->value(); } ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt()); ed->mode = ui->modeCB->currentIndex() + 1; int i=0; for (i=0; i<ui->expoName->text().toAscii().length(); i++) { ed->name[i]=ui->expoName->text().toAscii().at(i); } ed->name[i]=0; ed->phases=0; for (int i=8; i>=0 ; i--) { if (!cb_fp[i]->checkState()) { ed->phases+=1; } ed->phases<<=1; } ed->phases>>=1; if (GetEepromInterface()->getCapability(FlightPhases)) { int zeros=0; int ones=0; int phtemp=ed->phases; for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) { if (phtemp & 1) { ones++; } else { zeros++; } phtemp >>=1; } if (zeros==1) { phtemp=ed->phases; for (int i=0; i<GetEepromInterface()->getCapability(FlightPhases); i++) { if ((phtemp & 1)==0) { break; } phtemp >>=1; } }