예제 #1
0
const int OpenTxEepromInterface::getMaxModels()
{
  if (IS_ARM(board))
    return 60;
  else if (board == BOARD_M128)
    return 30;
  else if (board == BOARD_GRUVIN9X)
    return 30;
  else
    return 16;
}
예제 #2
0
파일: file.cpp 프로젝트: aviomotive/opentx
unsigned int EFile::openRd(unsigned int i_fileId)
{
  if (IS_SKY9X(board)) {
    m_fileId = get_current_block_number(i_fileId * 2, &m_size);
    m_pos = sizeof(t_eeprom_header);
    return 1;
  }
  else {
    m_fileId   = i_fileId;
    m_pos      = 0;
    m_currBlk  = (IS_ARM(board) ? eeFsArm->files[m_fileId].startBlk : eeFs->files[m_fileId].startBlk);
    m_ofs      = 0;
    m_zeroes   = 0;
    m_bRlc     = 0;
    m_err      = ERR_NONE;       //error reasons
    if (IS_ARM(board))
      return eeFsArm->files[m_fileId].typ;
    else
      return eeFs->files[m_fileId].typ;
  }
}
예제 #3
0
void TelemetryPanel::populateCurrentSource()
{
    QUnsignedAutoComboBox * cb = ui->frskyCurrentCB;
    cb->setField(&model.frsky.currentSource, this);
    cb->addItem(tr("---"), TELEMETRY_CURRENT_SOURCE_NONE);
    cb->addItem(tr("A1"), TELEMETRY_CURRENT_SOURCE_A1);
    cb->addItem(tr("A2"), TELEMETRY_CURRENT_SOURCE_A2);
    if (IS_ARM(firmware->getBoard())) {
        cb->addItem(tr("A3"), TELEMETRY_CURRENT_SOURCE_A3);
        cb->addItem(tr("A4"), TELEMETRY_CURRENT_SOURCE_A4);
    }
    cb->addItem(tr("FAS"), TELEMETRY_CURRENT_SOURCE_FAS);
}
예제 #4
0
void TelemetryPanel::populateVoltsSource()
{
    QUnsignedAutoComboBox * cb = ui->frskyVoltCB;
    cb->setField(&model.frsky.voltsSource, this);
    cb->addItem(tr("A1"), TELEMETRY_VOLTS_SOURCE_A1);
    cb->addItem(tr("A2"), TELEMETRY_VOLTS_SOURCE_A2);
    if (IS_ARM(firmware->getBoard())) {
        cb->addItem(tr("A3"), TELEMETRY_VOLTS_SOURCE_A3);
        cb->addItem(tr("A4"), TELEMETRY_VOLTS_SOURCE_A4);
    }
    cb->addItem(tr("FAS"), TELEMETRY_VOLTS_SOURCE_FAS);
    cb->addItem(tr("Cells"), TELEMETRY_VOLTS_SOURCE_CELLS);
}
예제 #5
0
파일: file.cpp 프로젝트: aviomotive/opentx
/*
 * free one or more blocks
 */
void EFile::EeFsFree(unsigned int blk)
{
  unsigned int i = blk;
  while (EeFsGetLink(i)) i = EeFsGetLink(i);
  if (IS_ARM(board)) {
    EeFsSetLink(i, eeFsArm->freeList);
    eeFsArm->freeList = blk; //chain in front
  }
  else {
    EeFsSetLink(i, eeFs->freeList);
    eeFs->freeList = blk; //chain in front
  }
}
예제 #6
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();
}
예제 #7
0
파일: file.cpp 프로젝트: aviomotive/opentx
unsigned int EFile::EeFsGetFree()
{
  unsigned int ret = 0;
  unsigned int i;
  if (IS_ARM(board))
    i = eeFsArm->freeList;
  else
    i = eeFs->freeList;

  while (i) {
    ret += eeFsBlockSize-eeFsLinkSize;
    i = EeFsGetLink(i);
  }
  return ret;
}
예제 #8
0
QString MultiModelPrinter::printTelemetry()
{
  QString str = printTitle(tr("Telemetry Settings"));

  // Analogs on non ARM boards
  if (!IS_ARM(firmware->getBoard())) {
    MultiColumns columns(models.size());
    columns.append("<table border='0' cellspacing='0' cellpadding='1' width='100%'>" \
                   "<tr><td width='22%'><b>" + tr("Analogs") + "</b></td><td width='26%'><b>" + tr("Unit") + "</b></td><td width='26%'><b>" + tr("Scale") + "</b></td><td width='26%'><b>" + tr("Offset") + "</b></td></tr>");
    for (int i=0; i<2; i++) {
      columns.append("<tr><td><b>"+tr("A%1").arg(i+1)+"</b></td><td>");
      COMPARE(getFrSkyUnits(model->frsky.channels[i].type));
      columns.append("</td><td>");
      COMPARE(QString::number((model->frsky.channels[i].ratio / (model->frsky.channels[i].type==0 ? 10.0 : 1)), 10, (model->frsky.channels[i].type==0 ? 1 : 0)));
      columns.append("</td><td>");
      COMPARE(QString::number((model->frsky.channels[i].offset*(model->frsky.channels[i].ratio / (model->frsky.channels[i].type==0 ?10.0 : 1)))/255, 10, (model->frsky.channels[i].type==0 ? 1 : 0)));
      columns.append("</td></tr>");
    }
    columns.append("</table><br/>");
    str.append(columns.print());
    // TODO I remove the analogs alarms for now
  }

  // RSSI alarms
  {
    MultiColumns columns(models.size());
    columns.append("<table border='0' cellspacing='0' cellpadding='1' width='100%'>");
    for (int i=0; i<2; i++) {
      columns.append("<tr><td><b>" + QString(i==0 ? tr("RSSI Alarms") : "") + "</b></td><td>");
      COMPARE(getFrSkyAlarmType(model->frsky.rssiAlarms[i].level));
      columns.append("</td><td>&lt;</td><td>");
      COMPARE(QString::number(model->frsky.rssiAlarms[i].value, 10));
      columns.append("</td></tr>");
    }
    columns.append("</table><br/>");
    str.append(columns.print());
  }
  
  return str;
}
예제 #9
0
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)));
}
예제 #10
0
GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, Firmware * firmware) :
  QDialog(parent),
  ui(new Ui::GeneralEdit),
  generalSettings(radioData.generalSettings),
  firmware(firmware)
{
  ui->setupUi(this);
  this->setWindowIcon(CompanionIcon("open.png"));

  QString firmware_id = g.profile[g.id()].fwType();
  QString name=g.profile[g.id()].name();
  if (name.isEmpty()) {
    ui->calstore_PB->setDisabled(true);
  }

  ui->profile_CB->clear();
  for (int i=0; i<MAX_PROFILES; ++i) {
    QString name=g.profile[i].name();
    if (!name.isEmpty()) {
      ui->profile_CB->addItem(name, i);
      if (i==g.id()) {
        ui->profile_CB->setCurrentIndex(ui->profile_CB->count()-1);
      }
    }
  }

  addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup"));
  if (IS_ARM(firmware->getBoard())) {
    addTab(new CustomFunctionsPanel(this, NULL, generalSettings, firmware), tr("Global Functions"));
  }
  addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer"));
  addTab(new HardwarePanel(this, generalSettings, firmware), tr("Hardware"));
  addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration"));

  ui->tabWidget->setCurrentIndex( g.generalEditTab() );
}
예제 #11
0
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
}
예제 #12
0
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
}
예제 #13
0
void TelemetryPanel::setup()
{
    QString firmware_id = g.profile[g.id()].fwType();

    lock = true;

    if (IS_ARM(firmware->getBoard())) {
        ui->telemetryProtocol->addItem(tr("FrSky S.PORT"), 0);
        ui->telemetryProtocol->addItem(tr("FrSky D"), 1);
        if (IS_9XRPRO(firmware->getBoard())) {
            ui->telemetryProtocol->addItem(tr("FrSky D (cable)"), 2);
        }
        ui->telemetryProtocol->setCurrentIndex(model.telemetryProtocol);
    }
    else {
        ui->telemetryProtocolLabel->hide();
        ui->telemetryProtocol->hide();
    }

    ui->rssiAlarm1SB->setValue(model.frsky.rssiAlarms[0].value);
    ui->rssiAlarm2SB->setValue(model.frsky.rssiAlarms[1].value);
    if (!IS_TARANIS(firmware->getBoard())) {
        ui->rssiAlarm1CB->setCurrentIndex(model.frsky.rssiAlarms[0].level);
        ui->rssiAlarm2CB->setCurrentIndex(model.frsky.rssiAlarms[1].level);
    }
    else {
        ui->rssiAlarm1CB->hide();
        ui->rssiAlarm2CB->hide();
        ui->rssiAlarm1Label->setText(tr("Low Alarm"));
        ui->rssiAlarm2Label->setText(tr("Critical Alarm"));
    }

    if (!firmware->getCapability(HasAltitudeSel)) {
        ui->AltitudeGPS_ChkB->hide();
    }
    else {
        ui->AltitudeGPS_ChkB->setChecked(model.frsky.FrSkyGpsAlt);
    }

    if (IS_TARANIS(firmware->getBoard())) {
        ui->AltitudeToolbar_ChkB->setChecked(model.frsky.altitudeDisplayed);
    }
    else {
        ui->AltitudeToolbar_ChkB->hide();
    }

    int varioCap = firmware->getCapability(HasVario);
    if (!varioCap) {
        ui->varioLimitMax_DSB->hide();
        ui->varioLimitMin_DSB->hide();
        ui->varioLimitCenterMin_DSB->hide();
        ui->varioLimitCenterMax_DSB->hide();
        ui->varioLimit_label->hide();
        ui->VarioLabel_1->hide();
        ui->VarioLabel_2->hide();
        ui->VarioLabel_3->hide();
        ui->VarioLabel_4->hide();
        ui->varioSourceCB->hide();
        ui->varioSource_label->hide();
    }
    else {
        if (!firmware->getCapability(HasVarioSink)) {
            ui->varioLimitMin_DSB->hide();
            ui->varioLimitCenterMin_DSB->hide();
            ui->VarioLabel_1->hide();
            ui->VarioLabel_2->hide();
        }
        ui->varioLimitMin_DSB->setValue(model.frsky.varioMin-10);
        ui->varioLimitMax_DSB->setValue(model.frsky.varioMax+10);
        ui->varioLimitCenterMax_DSB->setValue((model.frsky.varioCenterMax/10.0)+0.5);
        ui->varioLimitCenterMin_DSB->setValue((model.frsky.varioCenterMin/10.0)-0.5);
    }

    ui->altimetryGB->setVisible(firmware->getCapability(HasAltitudeSel) || firmware->getCapability(HasVario)),
    ui->frskyProtoCB->setDisabled(firmware->getCapability(NoTelemetryProtocol));

    if (firmware->getCapability(Telemetry) & TM_HASWSHH) {
        ui->frskyProtoCB->addItem(tr("Winged Shadow How High"));
    }
    else {
        ui->frskyProtoCB->addItem(tr("Winged Shadow How High (not supported)"));
    }

    ui->variousGB->hide();
    if (!(firmware->getCapability(HasFasOffset)) && !(firmware_id.contains("fasoffset"))) {
        ui->fasOffset_label->hide();
        ui->fasOffset_DSB->hide();
    }
    else {
        ui->fasOffset_DSB->setValue(model.frsky.fasOffset/10.0);
        ui->variousGB->show();
    }

    if (!(firmware->getCapability(HasMahPersistent))) {
        ui->mahCount_label->hide();
        ui->mahCount_SB->hide();
        ui->mahCount_ChkB->hide();
    }
    else {
        if (model.frsky.mAhPersistent) {
            ui->mahCount_ChkB->setChecked(true);
            ui->mahCount_SB->setValue(model.frsky.storedMah);
        }
        else {
            ui->mahCount_SB->setDisabled(true);
        }
        ui->variousGB->show();
    }

    ui->frskyProtoCB->setCurrentIndex(model.frsky.usrProto);
    ui->bladesCount->setValue(model.frsky.blades);

    populateVoltsSource();
    populateCurrentSource();
    populateVarioSource();

    lock = false;
}
예제 #14
0
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();
      }
    }
  }
}
예제 #15
0
파일: file.cpp 프로젝트: aviomotive/opentx
unsigned int EFile::size(unsigned int id)
{
  return IS_ARM(board) ? eeFsArm->files[id].size : eeFs->files[id].size;
}
예제 #16
0
int OpenTxFirmware::getCapability(const Capability capability)
{
  switch (capability) {
    case Imperial:
      if (IS_ARM(board))
        return 0;
      else
        return id.contains("imperial") ? 1 : 0;
    case ModelImage:
      if (IS_TARANIS(board))
        return 1;
      else
        return 0;
    case HasBeeper:
      if (IS_ARM(board))
        return 0;
      else
        return 1;
    case HasPxxCountry:
      return 1;
    case HasGeneralUnits:
      if (IS_ARM(board))
        return 1;
      else
        return 0;
    case HasNegAndSwitches:
      if (IS_ARM(board))
        return 1;
      else
        return 0;
    case PPMExtCtrl:
      return 1;
    case PPMFrameLength:
      return 40;
    case FlightModes:
      if (IS_ARM(board))
        return 9;
      else if (board==BOARD_GRUVIN9X)
        return 6;
      else
        return 5;
    case FlightModesHaveFades:
      return 1;
    case Heli:
      if (IS_TARANIS(board))
        return id.contains("noheli") ? 0 : 1;
      else
        return id.contains("heli") ? 1 : 0;
    case Gvars:
      if (IS_TARANIS(board))
        return id.contains("nogvars") ? 0 : 9;
      else if (id.contains("gvars"))
        return IS_ARM(board) ? 9 : 5;
      else
        return 0;
    case FlightModesName:
      return (IS_TARANIS(board) ? 10 : 6);
    case GvarsName:
      return 6;
    case HasChNames:
      return (IS_TARANIS(board) ? 1 : 0);
    case GvarsInCS:
    case HasFAIMode:
      return 1;
    case GvarsAreNamed:
    case GvarsFlightModes:
      return ((IS_ARM(board) || board==BOARD_GRUVIN9X) ? 1 : 0);
    case Mixes:
      return (IS_ARM(board) ? O9X_ARM_MAX_MIXERS : O9X_MAX_MIXERS);
    case OffsetWeight:
      return (IS_ARM(board) ? 500 : 245);
    case Timers:
      return 2;
    case PermTimers:
      if (board == BOARD_GRUVIN9X || IS_ARM(board))
        return 1;
      else
        return 0;
    case Pots:
      return (IS_TARANIS(board) ? 5 : 3);
    case Switches:
      return (IS_TARANIS(board) ? 8 : 7);
    case SwitchesPositions:
      return (IS_TARANIS(board) ? 22 : 9);
    case CustomFunctions:
      if (IS_ARM(board))
        return 64;
      else if (board==BOARD_GRUVIN9X||board==BOARD_M128)
        return 24;
      else
        return 16;
    case LogicalSwitches:
      if (IS_ARM(board))
        return 32;
      else if (board==BOARD_GRUVIN9X||board==BOARD_M128)
        return 15;
      else
        return 12;
    case CustomAndSwitches:
      if (IS_ARM(board))
        return getCapability(LogicalSwitches);
      else
        return 15/*4bits*/-9/*sw positions*/;
    case LogicalSwitchesExt:
      return (IS_ARM(board) ? true : false);
    case RotaryEncoders:
      if (board == BOARD_GRUVIN9X)
        return 2;
      else if (IS_SKY9X(board))
        return 1;
      else
        return 0;
    case Outputs:
      return (IS_ARM(board) ? O9X_ARM_NUM_CHNOUT : O9X_NUM_CHNOUT);
    case NumCurvePoints:
      return (IS_ARM(board) ? 512 : 104);
    case VoicesAsNumbers:
      return (IS_ARM(board) ? 0 : 1);
    case VoicesMaxLength:
      return (IS_ARM(board) ? (IS_TARANIS(board) ? 8 :  6) : 0);
    case MultiLangVoice:
      return (IS_ARM(board) ? 1 : 0);
    case SoundPitch:
      return 1;
    case Haptic:
      return (board == BOARD_GRUVIN9X || IS_SKY9X(board) || board == BOARD_TARANIS_PLUS || id.contains("haptic"));
    case ModelTrainerEnable:
      if (IS_ARM(board))
        return 1;
      else
        return 0;
    case MaxVolume:
      return (IS_ARM(board) ? 23 : 7);
    case HasSoundMixer:
      return (IS_ARM(board) ? 1 : 0);
    case ExtraInputs:
      return 1;
    case ExtendedTrims:
      return 500;
    case Simulation:
      return 1;
    case DSM2Indexes:
      return 1;
    case NumCurves:
      return (IS_TARANIS(board) ? 32 : (IS_ARM(board) ? 16 : 8));
    case HasMixerNames:
      return (IS_ARM(board) ? (IS_TARANIS(board) ? 8 : 6) : false);
    case HasExpoNames:
      return (IS_ARM(board) ? (IS_TARANIS(board) ? 8 : 6) : false);
    case HasNoExpo:
      return (IS_TARANIS(board) ? false : true);
    case ChannelsName:
      return (IS_TARANIS(board) ? 6 : 0);
    case HasCvNames:
      return (IS_TARANIS(board) ? 1 : 0);
    case Telemetry:
      return TM_HASTELEMETRY|TM_HASOFFSET|TM_HASWSHH;
    case TelemetryBars:
      return 1;
    case TelemetryCustomScreens:
      return IS_TARANIS(board) ? 3 : 2;
    case TelemetryCustomScreensFieldsPerLine:
      return IS_TARANIS(board) ? 3 : 2;
    case NoTelemetryProtocol:
      return IS_TARANIS(board) ? 1 : 0;
    case TelemetryUnits:
      return 0;
    case TelemetryTimeshift:
      return 1;
    case TelemetryMaxMultiplier:
      return (IS_ARM(board) ? 32 : 8);
    case PPMCenter:
      return 1;
    case SYMLimits:
      return 1;
    case OptrexDisplay:
      return (board==BOARD_SKY9X ? true : false);
    case HasVario:
      return 1;
    case HasVarioSink:
      return ((board == BOARD_GRUVIN9X || IS_ARM(board)) ? true : false);
    case HasFailsafe:
      return (IS_ARM(board) ? 32 : 0);
    case NumModules:
      return (IS_ARM(board) && !IS_9XRPRO(board)) ? 2 : 1;
    case HasPPMStart:
      return (IS_ARM(board) ? true : false);
    case HasCurrentCalibration:
      return (IS_SKY9X(board) ? true : false);
    case HasVolume:
      return (IS_ARM(board) ? true : false);
    case HasBrightness:
      return (IS_ARM(board) ? true : false);
    case PerModelTimers:
      return 1;
    case SlowScale:
      return (IS_ARM(board) ? 10 : 2);
    case SlowRange:
      return (IS_ARM(board) ? 250 : 15);
    case CSFunc:
      return 18;
    case HasSDLogs:
      return ((board == BOARD_GRUVIN9X || IS_ARM(board)) ? true : false);
    case LCDWidth:
      return (IS_TARANIS(board) ? 212 : 128) ;
    case GetThrSwitch:
      return (IS_TARANIS(board) ? SWITCH_SF1 : SWITCH_THR) ;
    case HasDisplayText:
      return IS_ARM(board) ? 1 : 0;
    case VirtualInputs:
      return IS_TARANIS(board) ? 32 : 0;
    case TrainerInputs:
      return IS_ARM(board) ? 16 : 8;
    case LuaScripts:
      return IS_TARANIS(board) ? 7 : 0;
    case LuaInputsPerScript:
      return IS_TARANIS(board) ? 10 : 0;
    case LuaOutputsPerScript:
      return IS_TARANIS(board) ? 6 : 0;
    case LimitsPer1000:
    case EnhancedCurves:
      return IS_TARANIS(board);
    case HasFasOffset:
      return (IS_STOCK(board) ? false : true);
    case HasMahPersistent:
      return (IS_ARM(board) ? true : false);
    case MultiposPots:
      return IS_TARANIS(board) ? 3 : 0;
    case MultiposPotsPositions:
      return IS_TARANIS(board) ? 6 : 0;
    case SimulatorVariant:
      if (board == BOARD_STOCK)
        return SIMU_STOCK_VARIANTS;
      else if (board == BOARD_M128)
        return SIMU_M128_VARIANTS;
      else
        return 0;
    case MavlinkTelemetry:
      return id.contains("mavlink") ? 1 : 0;
    default:
      return 0;
  }
}
예제 #17
0
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;
}