示例#1
0
void CustomFunctionsPanel::playMusic()
{
  if (!clickObject) {
    clickObject = new Phonon::MediaObject(this);
    clickOutput = new Phonon::AudioOutput(Phonon::NoCategory, this);
    Phonon::createPath(clickObject, clickOutput);
    connect(clickObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(mediaPlayer_state(Phonon::State, Phonon::State)));
  }

  QPushButton * button = qobject_cast<QPushButton*>(sender());
  int index = button->property("index").toInt();
  QString path = g.profile[g.id()].sdPath();
  QDir qd(path);
  QString track;
  if (qd.exists()) {
    if (firmware->getCapability(VoicesAsNumbers)) {
      track = path + QString("/%1.wav").arg(int(fswtchParam[index]->value()), 4, 10, (const QChar)'0');
    }
    else {
      path.append("/SOUNDS/");
      QString lang = generalSettings.ttsLanguage;
      if (lang.isEmpty())
        lang = "en";
      path.append(lang);
      if (fswtchParamArmT[index]->currentText() != "----") {
        track = path + "/" + fswtchParamArmT[index]->currentText() + ".wav";
      }
    }
    QFile file(track);
    if (!file.exists()) {
      QMessageBox::critical(this, tr("Error"), tr("Unable to find sound file %1!").arg(track));
      return;
    }

    if (phononCurrent == index) {
      clickObject->stop();
      clickObject->clear();
      playBT[index]->setIcon(CompanionIcon("play.png"));
      phononCurrent = -1;
    }
    else {
      if (phononCurrent >= 0) {
        playBT[phononCurrent]->setIcon(CompanionIcon("play.png"));
      }
      phononCurrent = index;
      clickObject->clear();
#ifdef __APPLE__
      clickObject->setCurrentSource(QUrl("file://"+track));
#else
      clickObject->setCurrentSource(QUrl(track));
#endif
      clickObject->play();
      playBT[index]->setIcon(CompanionIcon("stop.png"));
    }
  }
}
示例#2
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 CalibrationPanel(this, generalSettings, firmware), tr("Hardware / Calibration"));

  ui->tabWidget->setCurrentIndex( g.generalEditTab() );
}
示例#3
0
FusesDialog::FusesDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FusesDialog)
{
  ui->setupUi(this);
  setWindowIcon(CompanionIcon("fuses.png"));
}
示例#4
0
FirmwarePreferencesDialog::FirmwarePreferencesDialog(QWidget *parent) :
  QDialog(parent),
  ui(new Ui::FirmwarePreferencesDialog)
{
  ui->setupUi(this);
  setWindowIcon(CompanionIcon("fwpreferences.png"));
  initSettings();
}
示例#5
0
void burnConfigDialog::listProgrammers()
{
    QStringList arguments;
    arguments << "-c?";
    avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "List available programmers", AVR_DIALOG_KEEP_OPEN, TRUE);
    ad->setWindowIcon(CompanionIcon("list.png"));
    ad->show();
    delete ad;
}
示例#6
0
MdiChild::MdiChild():
  QWidget(),
  ui(new Ui::mdiChild),
  firmware(GetCurrentFirmware()),
  isUntitled(true),
  fileChanged(false)
{
  ui->setupUi(this);
  setWindowIcon(CompanionIcon("open.png"));
  ui->SimulateTxButton->setIcon(CompanionIcon("simulate.png"));
  setAttribute(Qt::WA_DeleteOnClose);

  eepromInterfaceChanged();

  if (!(this->isMaximized() || this->isMinimized())) {
    adjustSize();
  }
}
示例#7
0
void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
{
    QLabel *label = (QLabel *)sender();
    selectedFunction = label->property("index").toInt();

    QPoint globalPos = label->mapToGlobal(pos);

    const QClipboard *clipboard = QApplication::clipboard();
    const QMimeData *mimeData = clipboard->mimeData();
    bool hasData = mimeData->hasFormat("application/x-companion-fsw");

    QMenu contextMenu;
    contextMenu.addAction(CompanionIcon("copy.png"), tr("&Copy"),this,SLOT(fswCopy()),tr("Ctrl+C"));
    contextMenu.addAction(CompanionIcon("cut.png"), tr("&Cut"),this,SLOT(fswCut()),tr("Ctrl+X"));
    contextMenu.addAction(CompanionIcon("paste.png"), tr("&Paste"),this,SLOT(fswPaste()),tr("Ctrl+V"))->setEnabled(hasData);
    contextMenu.addAction(CompanionIcon("clear.png"), tr("&Delete"),this,SLOT(fswDelete()),tr("Delete"));

    contextMenu.exec(globalPos);
}
示例#8
0
void burnConfigDialog::on_pushButton_4_clicked()
{
    QStringList arguments;
    arguments << "-?";

    avrOutputDialog *ad = new avrOutputDialog(this, ui->avrdude_location->text(), arguments, "Show help", AVR_DIALOG_KEEP_OPEN,TRUE);
    ad->setWindowIcon(CompanionIcon("configure.png"));
    ad->show();
    delete ad;
}
示例#9
0
FirmwarePreferencesDialog::FirmwarePreferencesDialog(QWidget *parent) :
  QDialog(parent),
  ui(new Ui::FirmwarePreferencesDialog)
{
  ui->setupUi(this);
  setWindowIcon(CompanionIcon("fwpreferences.png"));
  initSettings();

  foreach(const char *lang, GetCurrentFirmware()->getFirmwareBase()->ttslanguages) {
    ui->voiceCombo->addItem(lang);
    if (current_firmware_variant->getId().contains(QString("-tts%1").arg(lang)))
      ui->voiceCombo->setCurrentIndex(ui->voiceCombo->count() - 1);
  }
示例#10
0
文件: mixes.cpp 项目: rcbebo82/opentx
MixesPanel::MixesPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware):
  ModelPanel(parent, model, generalSettings, firmware),
  mixInserted(false), 
  highlightedSource(0),
  modelPrinter(firmware, generalSettings, model)
{
  QGridLayout * mixesLayout = new QGridLayout(this);

  MixerlistWidget = new MixersList(this, false); // TODO enum
  QPushButton * qbUp = new QPushButton(this);
  QPushButton * qbDown = new QPushButton(this);
  QPushButton * qbClear = new QPushButton(this);
  qbUp->setText(tr("Move Up"));
  qbUp->setIcon(CompanionIcon("moveup.png"));
  qbUp->setShortcut(QKeySequence(tr("Ctrl+Up")));
  qbDown->setText(tr("Move Down"));
  qbDown->setIcon(CompanionIcon("movedown.png"));
  qbDown->setShortcut(QKeySequence(tr("Ctrl+Down")));
  qbClear->setText(tr("Clear Mixes"));
  qbClear->setIcon(CompanionIcon("clear.png"));

  mixesLayout->addWidget(MixerlistWidget,1,1,1,3);
  mixesLayout->addWidget(qbUp,2,1);
  mixesLayout->addWidget(qbClear,2,2);
  mixesLayout->addWidget(qbDown,2,3);

  connect(MixerlistWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(mixerlistWidget_customContextMenuRequested(QPoint)));
  connect(MixerlistWidget,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(mixerlistWidget_doubleClicked(QModelIndex)));
  connect(MixerlistWidget,SIGNAL(mimeDropped(int,const QMimeData*,Qt::DropAction)),this,SLOT(mimeMixerDropped(int,const QMimeData*,Qt::DropAction)));

  connect(qbUp,SIGNAL(pressed()),SLOT(moveMixUp()));
  connect(qbDown,SIGNAL(pressed()),SLOT(moveMixDown()));
  connect(qbClear,SIGNAL(pressed()),SLOT(clearMixes()));

  connect(MixerlistWidget,SIGNAL(keyWasPressed(QKeyEvent*)), this, SLOT(mixerlistWidget_KeyPress(QKeyEvent*)));
}
示例#11
0
void burnConfigDialog::readFuses()
{
    QStringList args   = avrArgs;
    if(!avrPort.isEmpty()) args << "-P" << avrPort;

    QStringList str;
    str << "-U" << "lfuse:r:-:i" << "-U" << "hfuse:r:-:i" << "-U" << "efuse:r:-:i";

    QStringList arguments;
    arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << str;

    avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Read Fuses",AVR_DIALOG_KEEP_OPEN,TRUE);
    ad->setWindowIcon(CompanionIcon("fuses.png"));
    ad->show();
    delete ad;
}
ReleaseNotesFirmwareDialog::ReleaseNotesFirmwareDialog(QWidget * parent, const QString & rnurl):
  QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
  ui(new Ui::HtmlDialog)
{
  ui->setupUi(this);

  setWindowTitle(tr("OpenTX Release Notes"));
  setWindowIcon(CompanionIcon("changelog.png"));

  manager = new QNetworkAccessManager(this);
  connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyFinished(QNetworkReply *)));
  QUrl url(rnurl);
  QNetworkRequest request(url);
  request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
  manager->get(request);
}
示例#13
0
CompareDialog::CompareDialog(QWidget * parent, Firmware * firmware):
  QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
  multimodelprinter(firmware),
  model1Valid(false),
  model2Valid(false),
  ui(new Ui::CompareDialog)
{
  ui->setupUi(this);

  setWindowIcon(CompanionIcon("compare.png"));
  setAcceptDrops(true);

  //setDragDropOverwriteMode(true);
  //setDropIndicatorShown(true);
  // TODO scroll to top ... ui->textEdit->scrollToAnchor("1");
}
示例#14
0
void CustomFunctionsPanel::mediaPlayer_state(Phonon::State newState, Phonon::State oldState)
{
  if (!lock) {
    lock = true;
    if ((newState==Phonon::ErrorState || newState==Phonon::StoppedState || newState==Phonon::PausedState) && oldState==Phonon::PlayingState) {
      clickObject->stop();
      clickObject->clearQueue();
      clickObject->clear();
      if (phononCurrent >= 0) {
        playBT[phononCurrent]->setIcon(CompanionIcon("play.png"));
        phononCurrent = -1;
      }
    }
    lock = false;
  }
}
示例#15
0
PrintDialog::PrintDialog(QWidget *parent, Firmware * firmware, GeneralSettings & generalSettings, ModelData & model, const QString & filename) :
  QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
  firmware(firmware),
  generalSettings(generalSettings),
  model(model),
  printfilename(filename),
  ui(new Ui::PrintDialog),
  multimodelprinter(firmware)
{
  ui->setupUi(this);
  setWindowIcon(CompanionIcon("print.png"));
  setWindowTitle(model.name);
  multimodelprinter.setModel(0, model);
  ui->textEdit->setHtml(multimodelprinter.print(ui->textEdit->document()));
  if (!printfilename.isEmpty()) {
    printToFile();
    QTimer::singleShot(0, this, SLOT(autoClose()));
  }
}
AppPreferencesDialog::AppPreferencesDialog(QWidget *parent) :
  QDialog(parent),
  ui(new Ui::AppPreferencesDialog)
{
  ui->setupUi(this);
  updateLock=false;
  setWindowIcon(CompanionIcon("apppreferences.png"));

  initSettings();
  connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged()));
  connect(this, SIGNAL(accepted()), this, SLOT(writeValues()));

#ifndef JOYSTICKS
  ui->joystickCB->hide();
  ui->joystickCB->setDisabled(true);
  ui->joystickcalButton->hide();
  ui->joystickChkB->hide();
  ui->label_11->hide();
#endif

  shrink();
}
示例#17
0
WizardDialog::WizardDialog(const GeneralSettings & settings, unsigned int modelId, QWidget *parent):
  QWizard(parent),
  mix(settings, modelId),
  settings(settings)
{
  setWindowIcon(CompanionIcon("wizard.png"));
  setWindowTitle(tr("Model Wizard"));

  setPage(Page_Models, new ModelSelectionPage(this, "models", tr("Model Type"), tr("Enter model name and model type.")));
  setPage(Page_Throttle, new ThrottlePage(this, "throttle", tr("Throttle"), tr("Has your model got a motor or an engine?"), Page_Wingtypes));
  setPage(Page_Wingtypes, new WingtypeSelectionPage(this, "wingtype", tr("Wing Type"), tr("Is your model a flying wing/deltawing or has it a standard wing configuration?")));
  setPage(Page_Ailerons, new AileronsPage(this, "ailerons", tr("Ailerons"), tr("Has your model got ailerons?"), Page_Flaps));
  setPage(Page_Flaps, new FlapsPage(this, "flaps", tr("Flaps"), tr("Has your model got flaps?"), Page_Airbrakes));
  setPage(Page_Airbrakes, new AirbrakesPage(this, "airbrakes", tr("Airbrakes"), tr("Has your model got airbrakes?"), Page_Tails));
  setPage(Page_Elevons, new ElevonsPage(this, "elevons", tr("Flying-wing / Delta-wing"), tr("Select the elevons channels"), Page_Rudder));
  setPage(Page_Rudder, new RudderPage(this, "rudder", tr("Rudder"), tr("Does your model have a rudder?"), Page_Options));
  setPage(Page_Tails, new TailSelectionPage(this, "tails", tr("Tail Type"), tr("Select which type of tail your model is equiped with.")));
  setPage(Page_Tail, new TailPage(this, "tail", tr("Tail"), tr("Select channels for tail control."), Page_Options));
  setPage(Page_Vtail, new VTailPage(this, "vtail", tr("V-Tail"), tr("Select channels for tail control."), Page_Options));
  setPage(Page_Simpletail, new SimpleTailPage(this, "simpletail", tr("Tail"), tr("Select elevator channel."), Page_Options));
  setPage(Page_Cyclic, new CyclicPage(this, "cyclic", tr("Cyclic"), tr("Which type of swash control is installed in your helicopter?"), Page_Gyro));
  setPage(Page_Gyro, new GyroPage(this, "gyro", tr("Tail Gyro"), tr("Has your helicopter got an adjustable gyro for the tail?"), Page_Flybar));
  setPage(Page_Flybar, new FlybarSelectionPage(this, "flybar", tr("Rotor Type"), tr("Has your helicopter got a flybar?")));
  setPage(Page_Fblheli, new FblPage(this, "fblheli", tr("Helicopter"), tr("Select the controls for your helicopter"), Page_Options));
  setPage(Page_Helictrl, new HeliPage(this, "helictrl", tr("Helicopter"), tr("Select the controls for your helicopter"), Page_Options));
  setPage(Page_Multirotor, new MultirotorPage(this, "multirotor", tr("Multirotor"), tr("Select the control channels for your multirotor"), Page_Options));
  setPage(Page_Options, new OptionsPage(this, "options", tr("Model Options"), tr("Select additional options"), Page_Conclusion));
  setPage(Page_Conclusion, new ConclusionPage(this, "conclusion", tr("Save Changes"), tr(
    "Manually check the direction of each control surface and reverse any channels that make controls move in the wrong direction. "
    "Remove the propeller/propellers before you try to control your model for the first time.<br>"
    "Please note that continuing removes all old model settings!"), -1));
  setStartId(Page_Models);

  // Workaround for Qt radio button rendering issue on Mac
  Q_FOREACH(QAbstractButton * rb, findChildren<QAbstractButton *>()) {
    rb->setAttribute(Qt::WA_LayoutUsesWidgetRect);
  }
示例#18
0
void FusesDialog::on_resetFuses_EEdelete_clicked()
{
  ProgressDialog progressDialog(this, tr("Reset Radio Fuses"), CompanionIcon("fuses.png"), true);
  return resetAvrdudeFuses(false, progressDialog.progress());
}
示例#19
0
LogsDialog::LogsDialog(QWidget *parent) :
  QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
  ui(new Ui::LogsDialog)
{
  csvlog.clear();

  ui->setupUi(this);
  setWindowIcon(CompanionIcon("logs.png"));

  plotLock=false;

  colors.append(Qt::green);
  colors.append(Qt::red);
  colors.append(Qt::yellow);
  colors.append(Qt::magenta);
  colors.append(Qt::cyan);
  colors.append(Qt::darkBlue);
  colors.append(Qt::darkGreen);
  colors.append(Qt::darkRed);
  colors.append(Qt::darkYellow);
  colors.append(Qt::darkMagenta);
  colors.append(Qt::darkCyan);
  colors.append(Qt::blue);
  pen.setWidthF(1.0);

  // create and prepare a plot title layout element
  QCPPlotTitle *title = new QCPPlotTitle(ui->customPlot);
  title->setText(tr("Telemetry logs"));

  // add it to the main plot layout
  ui->customPlot->plotLayout()->insertRow(0);
  ui->customPlot->plotLayout()->addElement(0, 0, title);
  ui->customPlot->setNoAntialiasingOnDrag(true);
  ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables);

  axisRect = ui->customPlot->axisRect();
  axisRect->axis(QCPAxis::atBottom)->setLabel(tr("Time (hh:mm:ss)"));
  axisRect->axis(QCPAxis::atBottom)->setTickLabelType(QCPAxis::ltDateTime);
  axisRect->axis(QCPAxis::atBottom)->setDateTimeFormat("hh:mm:ss");
  QDateTime now = QDateTime::currentDateTime();
  axisRect->axis(QCPAxis::atBottom)->setRange(now.addSecs(-60*60*2).toTime_t(), now.toTime_t());
  axisRect->axis(QCPAxis::atLeft)->setTickLabels(false);
  axisRect->addAxis(QCPAxis::atLeft);
  axisRect->addAxis(QCPAxis::atRight);
  axisRect->axis(QCPAxis::atLeft, 1)->setVisible(false);
  axisRect->axis(QCPAxis::atRight, 1)->setVisible(false);

  QFont legendFont = font();
  legendFont.setPointSize(10);
  ui->customPlot->legend->setFont(legendFont);
  ui->customPlot->legend->setSelectedFont(legendFont);
  axisRect->insetLayout()->setInsetAlignment(0, Qt::AlignTop | Qt::AlignLeft);

  rightLegend = new QCPLegend;
  axisRect->insetLayout()->addElement(rightLegend, Qt::AlignTop | Qt::AlignRight);
  rightLegend->setLayer("legend");
  rightLegend->setFont(legendFont);
  rightLegend->setSelectedFont(legendFont);
  rightLegend->setVisible(false);

  ui->customPlot->setAutoAddPlottableToLegend(false);

  QString path = g.gePath();
  if (path.isEmpty() || !QFile(path).exists()) {
    ui->mapsButton->hide();
  }

  // connect slot that ties some axis selections together (especially opposite axes):
  connect(ui->customPlot, SIGNAL(selectionChangedByUser()), this, SLOT(selectionChanged()));
  // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
  connect(ui->customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
  connect(ui->customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

  // make left axes transfer its range to right axes:
  connect(axisRect->axis(QCPAxis::atLeft), SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChangeRanges(QCPRange)));

  // connect some interaction slots:
  connect(ui->customPlot, SIGNAL(titleDoubleClick(QMouseEvent*, QCPPlotTitle*)), this, SLOT(titleDoubleClick(QMouseEvent*, QCPPlotTitle*)));
  connect(ui->customPlot, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(axisLabelDoubleClick(QCPAxis*,QCPAxis::SelectablePart)));
  connect(ui->customPlot, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this, SLOT(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*)));
  connect(ui->FieldsTW, SIGNAL(itemSelectionChanged()), this, SLOT(plotLogs()));
  connect(ui->logTable, SIGNAL(itemSelectionChanged()), this, SLOT(plotLogs()));
  connect(ui->Reset_PB, SIGNAL(clicked()), this, SLOT(plotLogs()));
}
示例#20
0
void burnConfigDialog::restFuses(bool eeProtect)
{
    //fuses
    //avrdude -c usbasp -p m64 -U lfuse:w:<0x0E>:m
    //avrdude -c usbasp -p m64 -U hfuse:w:<0x89>:m  0x81 for eeprom protection
    //avrdude -c usbasp -p m64 -U efuse:w:<0xFF>:m

    QMessageBox::StandardButton ret = QMessageBox::No;
    ret = QMessageBox::warning(this, tr("Companion"),
                               tr("<b><u>WARNING!</u></b><br>This will reset the fuses of  %1 to the factory settings.<br>Writing fuses can mess up your radio.<br>Do this only if you are sure they are wrong!<br>Are you sure you want to continue?").arg(avrMCU),
                               QMessageBox::Yes | QMessageBox::No);
    if (ret == QMessageBox::Yes)
    {
        QStringList args   = avrArgs;
        if(!avrPort.isEmpty()) args << "-P" << avrPort;
        QStringList str;
        if (avrMCU=="m2560") {
            args << "-B8";
            QString erStr = eeProtect ? "hfuse:w:0x11:m" : "hfuse:w:0x19:m";
            str << "-U" << "lfuse:w:0xD7:m" << "-U" << erStr << "-U" << "efuse:w:0xFC:m";
            //use hfuse = 0x81 to prevent eeprom being erased with every flashing
        }
        else {
            QString lfuses;
            QString tempFile = generateProcessUniqueTempFileName("ftemp.bin");
            QStringList argread;
            argread << "-c" << avrProgrammer << "-p" << avrMCU << args  <<"-U" << "lfuse:r:"+tempFile+":r" ;
            avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, argread, "Reset Fuses",AVR_DIALOG_CLOSE_IF_SUCCESSFUL,FALSE);
            ad->setWindowIcon(CompanionIcon("fuses.png"));
            ad->exec();
            delete ad;
            QFile file(tempFile);
            if (file.exists() && file.size()==1) {
                file.open(QIODevice::ReadOnly);
                char bin_flash[1];
                file.read(bin_flash, 1);
                if (bin_flash[0]==0x0E) {
                    lfuses="lfuse:w:0x0E:m";
                }
                else {
                    lfuses="lfuse:w:0x3F:m";
                }
                file.close();
                qunlink(tempFile);
            }
            else {
                lfuses="lfuse:w:0x3F:m";
            }

            QString erStr = eeProtect ? "hfuse:w:0x81:m" : "hfuse:w:0x89:m";
            str << "-U" << lfuses << "-U" << erStr << "-U" << "efuse:w:0xFF:m";
            //use hfuse = 0x81 to prevent eeprom being erased with every flashing
        }
        QStringList arguments;
        if (avrMCU=="m2560") {
            arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-u" << str;
        }
        else {
            arguments << "-c" << avrProgrammer << "-p" << avrMCU << args << "-B" << "100" << "-u" << str;
        }
        avrOutputDialog *ad = new avrOutputDialog(this, avrLoc, arguments, "Reset Fuses",AVR_DIALOG_KEEP_OPEN,TRUE);
        ad->setWindowIcon(CompanionIcon("fuses.png"));
        ad->show();
        delete ad;
    }

}
示例#21
0
void burnConfigDialog::listAvrdudeProgrammers()
{
  ProgressDialog progressDialog(this, tr("List available programmers"), CompanionIcon("list.png"), true);
  FlashProcess flashProcess(ui->avrdude_location->text(), QStringList() << "-c?", progressDialog.progress());
  flashProcess.run();
}
示例#22
0
// TODO choose better name when no merge in progress....
void burnConfigDialog::on_pushButton_4_clicked()
{
  ProgressDialog progressDialog(this, tr("Avrdude help"), CompanionIcon("configure.png"), true);
  FlashProcess flashProcess(ui->avrdude_location->text(), QStringList() << "-?", progressDialog.progress());
  flashProcess.run();
}
示例#23
0
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()));
}
示例#24
0
// Type 1 = Burn EEPROM, Type 2= Burn Flash
burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * backupEE, QString DocName):
  QDialog(parent),
  ui(new Ui::burnDialog),
  hexfileName(fileName),
  backup(backupEE),
  hexType(Type)
{
  ui->setupUi(this);
  setWindowIcon(CompanionIcon("write_flash.png"));

  if (!g.profile[g.id()].splashFile().isEmpty()){
    imageSource=PROFILE;
    imageFile=g.profile[g.id()].splashFile();
  }
  else {
    ui->useProfileImageCB->setDisabled(true);
    imageSource=FIRMWARE;
    imageFile="";
  }
  ui->SplashFrame->hide();
  ui->FramFWInfo->hide();
  ui->EEbackupCB->hide();
  ui->EEbackupCB->setCheckState(*backup ? Qt::Checked : Qt::Unchecked);
  if (Type == FLASH_FILE_TYPE ) {
    ui->EEpromCB->hide();
    ui->profile_label->hide();
    ui->patchcalib_CB->hide();
    ui->patchhw_CB->hide();
    setWindowTitle(tr("Write firmware to Radio"));
    if (IS_TARANIS(GetEepromInterface()->getBoard())) {
      ui->EEbackupCB->hide();
    }
  }
  else {
    ui->FlashLoadButton->setText(tr("Browse for file"));
    ui->profile_label->hide();
    ui->patchcalib_CB->hide();
    ui->patchhw_CB->hide();
    ui->EEpromCB->hide();
    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();
    if (DocName.isEmpty()) {
      setWindowTitle(tr("Write Backup to Radio"));
    }
    else {
      setWindowTitle(tr("Write Backup from %1 to Radio").arg(DocName));
    }
    ui->profile_label->setText(tr("Current profile")+QString(": ")+g.profile[g.id()].name());
  }
  if (!hexfileName->isEmpty()) {
    ui->FWFileName->setText(*hexfileName);
    if (Type==FLASH_FILE_TYPE) {
      checkFw(*hexfileName);
    }
    else {
      burnraw=false;
      if (checkeEprom(*hexfileName)) {
        QString Name = g.profile[g.id()].name();
        QString calib = g.profile[g.id()].stickPotCalib();
        QString trainercalib = g.profile[g.id()].trainerCalib();
        QString DisplaySet = g.profile[g.id()].display();
        QString BeeperSet = g.profile[g.id()].beeper();
        QString HapticSet = g.profile[g.id()].haptic();
        QString SpeakerSet = g.profile[g.id()].speaker();
        if (!Name.isEmpty()) {
          ui->profile_label->show();
          ui->patchcalib_CB->show();
          ui->patchhw_CB->show();
          // TODO I hardcode the number of pots here, should be dependant on the board?
          if (!((calib.length()==(NUM_STICKS+3)*12) && (trainercalib.length()==16))) {
            ui->patchcalib_CB->setDisabled(true);
          }
          if (!((DisplaySet.length()==6) && (BeeperSet.length()==4) && (HapticSet.length()==6) && (SpeakerSet.length()==6))) {
            ui->patchhw_CB->setDisabled(true);
          }
        }
        else {
          ui->profile_label->hide();
        }
        if (!IS_TARANIS(GetEepromInterface()->getBoard())) {
          ui->EEpromCB->show();
        }
        else {
          ui->EEpromCB->setChecked(false);
        }
        ui->BurnFlashButton->setEnabled(true);
      }
    }
    ui->FWFileName->hide();
    ui->FlashLoadButton->hide();   
    hexfileName->clear();
  }
  else if (Type==FLASH_FILE_TYPE) {
    QString FileName = g.profile[g.id()].fwName();
    QFile file(FileName);
    if (file.exists()) {
      checkFw(FileName);
    }
  }
  updateUI();
  resize(0, 0);
}
示例#25
0
void FlashFirmwareDialog::startFlash(const QString &filename)
{
  bool backup = g.backupOnFlash();

  close();

  ProgressDialog progressDialog(this, tr("Write Firmware to Radio"), CompanionIcon("write_flash.png"));

  // check hardware compatibility if requested
  if (g.checkHardwareCompatibility()) {
    QString tempFirmware = generateProcessUniqueTempFileName("flash-check.bin");
    if (!readFirmware(tempFirmware, progressDialog.progress())) {
      QMessageBox::warning(this, tr("Firmware check failed"), tr("Could not check firmware from radio"));
      return;
    }
    FirmwareInterface previousFirmware(tempFirmware);
    qunlink(tempFirmware);
    FirmwareInterface newFirmware(filename);
    qDebug() << "startFlash: checking firmware compatibility between " << tempFirmware << "and" << filename;
    if (!newFirmware.isHardwareCompatible(previousFirmware)) {
      QMessageBox::warning(this, tr("Firmware check failed"), tr("New firmware is not compatible with the one currently installed!"));
      if (isTempFileName(filename)) {
        qDebug() << "startFlash: removing temporary file" << filename;
        qunlink(filename);
      }
      return;
    }
  }

  // backup if requested
  bool result = true;
  QString backupFilename;
  QString backupPath;
  if (backup) {
    backupPath = g.profile[g.id()].pBackupDir();
    if (backupPath.isEmpty()) {
      backupPath=g.backupDir();
    }     
    backupFilename = backupPath + "/backup-" + QDateTime().currentDateTime().toString("yyyy-MM-dd-HHmmss") + ".bin";
    result = readEeprom(backupFilename, progressDialog.progress());
    sleep(2);
  }

  // flash
  result = (result && writeFirmware(filename, progressDialog.progress()));

  // restore if backup requested
  if (backup && result) {
    sleep(2);
    QString restoreFilename = generateProcessUniqueTempFileName("restore.bin");
    if (!convertEEprom(backupFilename, restoreFilename, filename)) {
      QMessageBox::warning(this, tr("Conversion failed"), tr("Cannot convert Models and Settings for use with this firmware, original data will be used"));
      restoreFilename = backupFilename;
    }
    if (!writeEeprom(restoreFilename, progressDialog.progress())) {
      QMessageBox::warning(this, tr("Restore failed"), tr("Could not restore Models and Settings to Radio. The models and settings data file can be found at: %1").arg(backupFilename));
    }
  }

  progressDialog.progress()->setInfo(tr("Flashing done"));
  progressDialog.exec();

  if (isTempFileName(filename)) {
    qDebug() << "startFlash: removing temporary file" << filename;
    qunlink(filename);
  }
}
示例#26
0
void FusesDialog::on_readFuses_clicked()
{
  ProgressDialog progressDialog(this, tr("Read Fuses from Radio"), CompanionIcon("fuses.png"), true);
  return readAvrdudeFuses(progressDialog.progress());
}
示例#27
0
ContributorsDialog::ContributorsDialog(QWidget * parent):
  QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
  ui(new Ui::HtmlDialog)
{
  ui->setupUi(this);

  setWindowTitle(tr("OpenTX Contributors"));
  setWindowIcon(CompanionIcon("contributors.png"));

  QString str = "<html>" \
                "<head>" \
                "  <style type=\"text/css\">" \
                "    .normal { font-weight:normal;color:#000000;vertical-align:top;font-size:10px;text-align:left;font-family:arial,helvetica,sans-serif; }" \
                "    .bold { font-weight:bold;color:#C00000;vertical-align:top;font-size:10px;text-align:left;font-family:arial,helvetica,sans-serif; }" \
                "    .title { font-weight:bold;color:#000000;font-size:14px;text-align:left;font-family:arial,helvetica,sans-serif; }" \
                "  </style>" \
                "</head>"
                "<body class=\"normal\">";

  QFile credits(":/CREDITS.txt");
  if (credits.open(QIODevice::ReadOnly | QIODevice::Text)) {
    QStringList names;
    while (!credits.atEnd()) {
      QByteArray line = credits.readLine();
      if (line.trimmed() == "")
        break;
      names.append(line.trimmed());
    }
    str.append(formatTable(tr("Main Developers"), names, 3));

    names.clear();
    while (!credits.atEnd()) {
      QByteArray line = credits.readLine();
      names.append(line.trimmed());
    }
    str.append(formatTable(tr("Other contributors"), names, 3));
  }

  QFile donations(":/DONATIONS.txt");
  if (donations.open(QIODevice::ReadOnly | QIODevice::Text)) {
    QStringList names;
    while (!donations.atEnd()) {
      QByteArray line = donations.readLine();
      if (line.trimmed() == "")
        break;
      names.append(line.trimmed());
    }
    str.append(formatTable(tr("Companies and projects who have donated to OpenTX"), names, 3));

    names.clear();
    while (!donations.atEnd()) {
      QByteArray line = donations.readLine();
      names.append(line);
    }
    str.append(formatTable(tr("People who have donated to OpenTX"), names, 6));
  }

  str.append("  <tr><td class=\"normal\">&nbsp;</td></tr>" \
             "  <tr><td colspan=3 class=\"normal\">" + tr("Honors go to Rafal Tomczak (RadioClone), Thomas Husterer (th9x) and Erez Raviv (er9x and eePe)") + "<br/></td></tr>" \
             "  <tr><td colspan=3 class=\"normal\">" + tr("Thank you all !!!") + "</td></tr>" \
             "</table>");


  str.append("</body></html>");
  ui->textEditor->setHtml(str);
  ui->textEditor->scroll(0, 0);
  ui->textEditor->setOpenExternalLinks(true);
}