Пример #1
0
void TelemetryPanel::populateVarioSource()
{
    QUnsignedAutoComboBox * cb = ui->varioSourceCB;
    cb->setField(&model.frsky.varioSource, this);
    if (!IS_TARANIS(firmware->getBoard())) {
        cb->addItem(tr("Alti"), TELEMETRY_VARIO_SOURCE_ALTI);
        cb->addItem(tr("Alti+"), TELEMETRY_VARIO_SOURCE_ALTI_PLUS);
    }
    cb->addItem(tr("VSpeed"), TELEMETRY_VARIO_SOURCE_VSPEED);
    cb->addItem(tr("A1"), TELEMETRY_VARIO_SOURCE_A1);
    cb->addItem(tr("A2"), TELEMETRY_VARIO_SOURCE_A2);
    if (IS_TARANIS(firmware->getBoard())) {
        cb->addItem(tr("dTE"), TELEMETRY_VARIO_SOURCE_DTE);
    }
}
Пример #2
0
int ModelData::getChannelsMax()
{
  if (extendedLimits)
    return IS_TARANIS(GetCurrentFirmware()->getBoard()) ? 150 : 125;
  else
    return 100;
}
Пример #3
0
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;
}
Пример #4
0
void CalibrationPanel::setupPotConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type)
{
    bool enabled = false;

    if (IS_TARANIS_X9E(firmware->getBoard()) && index < 4) {
        label->setText(RawSource(SOURCE_TYPE_STICK, index+NUM_STICKS).toString());
        enabled = true;
    }
    else if (IS_TARANIS_PLUS(firmware->getBoard()) && index < 3) {
        enabled = true;
    }
    else if (IS_TARANIS(firmware->getBoard()) && index < 2) {
        enabled = true;
    }

    if (enabled) {
        type->addItem(tr("None"), GeneralSettings::POT_NONE);
        type->addItem(tr("Pot with detent"), GeneralSettings::POT_WITH_DETENT);
        type->addItem(tr("Multipos switch"), GeneralSettings::POT_MULTIPOS_SWITCH);
        type->addItem(tr("Pot without detent"), GeneralSettings::POT_WITHOUT_DETENT);
        name->setField(generalSettings.potName[index], 3, this);
        type->setField(generalSettings.potConfig[index], this);
    }
    else {
        label->hide();
        name->hide();
        type->hide();
    }
}
Пример #5
0
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() );
}
Пример #6
0
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
        }
    }
}
Пример #7
0
void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
{
  b->clear();
  for (unsigned int i=0; i<FuncCount; i++) {
    if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && (!model || !firmware->getCapability(SafetyChannelCustomFunction))) ||
        ((i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) ||
        ((i==FuncPlayScript && !IS_TARANIS(firmware->getBoard()))) ||
        ((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) ||
        ((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) ||
        ((i==FuncLogs) && !firmware->getCapability(HasSDLogs)) ||
        ((i==FuncSetTimer3) && firmware->getCapability(Timers) < 3) ||
        ((i>=FuncRangeCheckInternalModule && i<=FuncBindExternalModule) && (!model || !firmware->getCapability(DangerousFunctions))) ||
        ((i>=FuncAdjustGV1 && i<=FuncAdjustGVLast) && !firmware->getCapability(Gvars))
        ) {
      // skipped
      // b->addItem(CustomFunctionData(AssignFunc(i)).funcToString(), i);
      // QModelIndex index = b->model()->index(i, 0);
      // QVariant v(0);
      // b->model()->setData(index, v, Qt::UserRole - 1);
    }
    else {
      b->addItem(CustomFunctionData(AssignFunc(i)).funcToString(), i);
      if (i == value) {
        b->setCurrentIndex(b->count()-1);
      }
    }
  }
}
Пример #8
0
QString ModelPrinter::printCenterBeep()
{
  QStringList strl;
  if (model.beepANACenter & 0x01)
    strl << tr("Rudder");
  if (model.beepANACenter & 0x02)
    strl << tr("Elevator");
  if (model.beepANACenter & 0x04)
    strl << tr("Throttle");
  if (model.beepANACenter & 0x08)
    strl << tr("Aileron");
  if (IS_TARANIS(firmware->getBoard())) {
    if (model.beepANACenter & 0x10)
      strl << "S1";
    if (model.beepANACenter & 0x20)
      strl << "S2";
    if (model.beepANACenter & 0x40)
      strl << "S3";
    if (model.beepANACenter & 0x80)
      strl << "LS";
    if (model.beepANACenter & 0x100)
      strl << "RS";
  }
  else {
    if (model.beepANACenter & 0x10)
      strl << "P1";
    if (model.beepANACenter & 0x20)
      strl << "P2";
    if (model.beepANACenter & 0x40)
      strl << "P3";
  }
  return strl.join(", ");
}
Пример #9
0
void EFile::EeFsCreate(uint8_t *eeprom, int size, BoardEnum board)
{
  this->eeprom = eeprom;
  this->eeprom_size = size;
  this->board = board;

  if (IS_SKY9X(board)) {
    memset(eeprom, 0xFF, size);
  }
  else if (IS_TARANIS(board)) {
    eeFsArm = (EeFsArm *)eeprom;
    eeFsVersion = 5;
    eeFsSize = 8+4*62;
    eeFsBlockSize = 64;
    eeFsFirstBlock = 1;
    eeFsBlocksOffset = eeFsSize - eeFsBlockSize;
    eeFsBlocksMax = 1 + (EESIZE_TARANIS-eeFsSize)/eeFsBlockSize;
    eeFsLinkSize = sizeof(int16_t);
    memset(eeprom, 0, size);
    eeFsArm->version  = eeFsVersion;
    eeFsArm->mySize   = eeFsSize;
    eeFsArm->freeList = 0;
    eeFsArm->bs       = 64;
    for (unsigned int i=eeFsFirstBlock; i<eeFsBlocksMax-1; i++)
      EeFsSetLink(i, i+1);
    EeFsSetLink(eeFsBlocksMax-1, 0);
    eeFsArm->freeList = eeFsFirstBlock;
    // EeFsFlush();
  }
  else {
    eeFs = (EeFs *)eeprom;
    eeFsVersion = (board==BOARD_GRUVIN9X || board==BOARD_M128) ? 5 : 4;
    eeFsBlockSize = 16;
    eeFsLinkSize = 1;

    if (eeFsVersion == 5) {
      eeFsSize = 4+3*36;
      eeFsFirstBlock = 1;
      eeFsBlocksOffset = 112 - 16;
      eeFsBlocksMax = 1 + (4096-112)/16;
    }
    else {
      eeFsSize = 4+3*20;
      eeFsFirstBlock = 4;
      eeFsBlocksOffset = 0;
      eeFsBlocksMax = 2048/16;
    }

    memset(eeprom, 0, size);
    eeFs->version  = eeFsVersion;
    eeFs->mySize   = eeFsSize;
    eeFs->freeList = 0;
    eeFs->bs       = eeFsBlockSize;
    for (unsigned int i=eeFsFirstBlock; i<eeFsBlocksMax-1; i++)
      EeFsSetLink(i, i+1);
    EeFsSetLink(eeFsBlocksMax-1, 0);
    eeFs->freeList = eeFsFirstBlock;
    // EeFsFlush();
  }
}
Пример #10
0
void CalibrationPanel::setupSliderConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type)
{
    bool enabled = false;

    if (IS_TARANIS(firmware->getBoard()) && index < 2) {
        type->setEnabled(false);
        enabled = true;
    }
    else if (IS_TARANIS_X9E(firmware->getBoard()) && index < 4) {
        enabled = true;
    }

    if (IS_TARANIS_X9E(firmware->getBoard())) {
        label->setText(RawSource(SOURCE_TYPE_STICK, index+NUM_STICKS+4).toString());
    }

    if (enabled) {
        type->addItem(tr("None"), GeneralSettings::SLIDER_NONE);
        type->addItem(tr("Slider with detent"), GeneralSettings::SLIDER_WITH_DETENT);
        name->setField(generalSettings.sliderName[index], 3, this);
        type->setField(generalSettings.sliderConfig[index], this);
    }
    else {
        label->hide();
        name->hide();
        type->hide();
    }
}
Пример #11
0
void CalibrationPanel::setupSwitchConfig(int index, QLabel *label, AutoLineEdit *name, AutoComboBox *type)
{
    bool enabled = false;

    if (IS_TARANIS(firmware->getBoard())) {
        if (IS_TARANIS_X9E(firmware->getBoard())) {
            enabled = true;
            type->addItem(tr("None"), GeneralSettings::SWITCH_NONE);
        }
        else if (index < 8) {
            enabled = true;
        }
    }

    if (enabled) {
        type->addItem(tr("2 Positions Toggle"), GeneralSettings::SWITCH_TOGGLE);
        type->addItem(tr("2 Positions"), GeneralSettings::SWITCH_2POS);
        type->addItem(tr("3 Positions"), GeneralSettings::SWITCH_3POS);
        name->setField(generalSettings.switchName[index], 3, this);
        type->setField(generalSettings.switchConfig[index], this);
    }
    else {
        label->hide();
        name->hide();
        type->hide();
    }
}
Пример #12
0
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);
    }
  }
}
Пример #13
0
bool OpenTxFirmware::isTelemetrySourceAvailable(int source)
{
  if (IS_TARANIS(board) && (source == TELEMETRY_SOURCE_RSSI_TX))
    return false;

  if (source == TELEMETRY_SOURCE_DTE)
    return false;

  return true;
}
Пример #14
0
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));
}
Пример #15
0
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;
}
Пример #16
0
void TelemetryPanel::update()
{
    if (IS_TARANIS(firmware->getBoard())) {
        if (model.moduleData[0].protocol == OFF && model.moduleData[1].protocol == PPM) {
            ui->telemetryProtocol->setEnabled(true);
        }
        else {
            ui->telemetryProtocol->setEnabled(false);
            ui->telemetryProtocol->setCurrentIndex(0);
        }
    }
}
Пример #17
0
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);
    }
  }
}
Пример #18
0
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);
  }
}
Пример #19
0
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();
  }
}
Пример #20
0
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;
}
Пример #21
0
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()));
}
Пример #22
0
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(firmware->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"));
    }

    disableMouseScrolling();
}
Пример #23
0
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();
}
Пример #24
0
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);
  }
}
Пример #25
0
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);
  }
}
Пример #26
0
bool EFile::EeFsOpen(uint8_t *eeprom, int size, BoardEnum board)
{
  this->eeprom = eeprom;
  this->eeprom_size = size;
  this->board = board;

  if (IS_SKY9X(board)) {
    return 1;
  }
  else if (IS_TARANIS(board)) {
    eeFsArm = (EeFsArm *)eeprom;
    eeFsVersion = eeFsArm->version;
    eeFsSize = 8+4*62;
    eeFsBlockSize = 64;
    eeFsLinkSize = sizeof(int16_t);
    eeFsFirstBlock = 1;
    eeFsBlocksOffset = eeFsSize - eeFsBlockSize;
    eeFsBlocksMax = 1 + (EESIZE_TARANIS-eeFsSize)/eeFsBlockSize;
    return eeFsArm->mySize == eeFsSize;
  }
  else {
    eeFs = (EeFs *)eeprom;
    eeFsVersion = eeFs->version;
    eeFsBlockSize = 16;
    eeFsLinkSize = 1;
    if (eeFsVersion == 5) {
      eeFsSize = 4+3*36;
      eeFsFirstBlock = 1;
      eeFsBlocksOffset = 112 - 16;
      eeFsBlocksMax = 1 + (4096-112)/16;
    }
    else if (eeFsVersion == 4) {
      eeFsSize = 4+3*20;
      eeFsFirstBlock = 4;
      eeFsBlocksOffset = 0;
      eeFsBlocksMax = 2048/16;
    }
    else {
      return 0;
    }

    return eeFs->mySize == eeFsSize;
  }
}
Пример #27
0
LimitsGroup::LimitsGroup(FirmwareInterface * firmware, QGridLayout *gridLayout, int row, int col, int & value, int min, int max, int deflt):
  firmware(firmware),
  spinbox(new QDoubleSpinBox()),
  value(value),
  displayStep(0.1)
{
  bool allowGVars = false;
  int internalStep = 1;

  spinbox->setProperty("index", row);
  spinbox->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
  spinbox->setAccelerated(true);

  if (firmware->getCapability(PPMUnitMicroseconds)) {
    displayStep = 0.512;
    spinbox->setDecimals(1);
    spinbox->setSuffix("us");
  }
  else {
    spinbox->setDecimals(0);
    spinbox->setSuffix("%");
  }

  if (IS_TARANIS(firmware->getBoard()) || deflt == 0 /*it's the offset*/) {
    spinbox->setDecimals(1);
    allowGVars = true;
  }
  else {
    internalStep *= 10;
  }
  
  spinbox->setSingleStep(displayStep*internalStep);

  QHBoxLayout * horizontalLayout = new QHBoxLayout();
  QCheckBox * gv = new QCheckBox(QObject::tr("GV"));
  horizontalLayout->addWidget(gv);
  QComboBox * cb = new QComboBox();
  horizontalLayout->addWidget(cb);
  horizontalLayout->addWidget(spinbox);
  gridLayout->addLayout(horizontalLayout, row, col, 1, 1);
  gvarGroup = new GVarGroup(gv, spinbox, cb, value, deflt, min, max, displayStep, allowGVars);
}
Пример #28
0
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;
}
Пример #29
0
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?
}
Пример #30
0
void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
{
  b->clear();
  for (unsigned int i=0; i<FuncCount; i++) {
    b->addItem(FuncSwData(AssignFunc(i)).funcToString());
    if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && !firmware->getCapability(SafetyChannelCustomFunction)) ||
        ((i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) ||
        ((i==FuncPlayScript && !IS_TARANIS(firmware->getBoard()))) ||
        ((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) ||
        ((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) ||
        ((i==FuncLogs) && !firmware->getCapability(HasSDLogs)) ||
        ((i>=FuncAdjustGV1 && i<=FuncAdjustGVLast) && !firmware->getCapability(Gvars))
        ) {
      QModelIndex index = b->model()->index(i, 0);
      QVariant v(0);
      b->model()->setData(index, v, Qt::UserRole - 1);
    }
  }
  b->setCurrentIndex(value);
  b->setMaxVisibleItems(10);
}