dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
outputpage.cpp
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  */
27 
28 #include "outputpage.h"
29 #include "ui_outputpage.h"
30 #include "setupwizard.h"
31 
32 OutputPage::OutputPage(SetupWizard *wizard, QWidget *parent)
33  : AbstractWizardPage(wizard, parent)
34  ,
35 
36  ui(new Ui::OutputPage)
37 {
38  ui->setupUi(this);
39 }
40 
42 {
43  delete ui;
44 }
45 
47 void OutputPage::setOutputRanges(quint16 minPulse, quint16 neutralPulse, quint16 maxPulse)
48 {
50  for (int i = 0; i < allSettings.count(); i++) {
51  actuatorChannelSettings settings = allSettings[i];
52  settings.channelMin = minPulse;
53  settings.channelNeutral = neutralPulse;
54  settings.channelMax = maxPulse;
55  allSettings[i] = settings;
56  }
57  getWizard()->setActuatorSettings(allSettings);
58 }
59 
61 {
62  QPointer<SetupWizard> wizard = getWizard();
63  if (!wizard) {
64  Q_ASSERT(false);
65  qCritical() << "No wizard!";
66  return false;
67  }
68 
69  if (ui->oneShot125Button->isChecked()) {
70  wizard->setESCType(SetupWizard::ESC_ONESHOT125);
71  // This is safe to do even if they are wrong. Normal ESCS
72  // ignore oneshot.
73  setOutputRanges(125, 125, 250);
74  } else if (ui->oneShot42Button->isChecked()) {
75  wizard->setESCType(SetupWizard::ESC_ONESHOT42);
76  // oneshot42 is actually oneshot125/3
77  setOutputRanges(42, 42, 83);
78  } else if (ui->dshot300Button->isChecked()) {
79  wizard->setESCType(SetupWizard::ESC_DSHOT300);
80  setOutputRanges(0, 48, 2047);
81  } else if (ui->dshot600Button->isChecked()) {
82  wizard->setESCType(SetupWizard::ESC_DSHOT600);
83  setOutputRanges(0, 48, 2047);
84  } else if (ui->dshot1200Button->isChecked()) {
85  wizard->setESCType(SetupWizard::ESC_DSHOT1200);
86  setOutputRanges(0, 48, 2047);
87  } else {
88  wizard->setESCType(SetupWizard::ESC_RAPID);
89  setOutputRanges(1000, 1000, 2000);
90  }
91 
92  return true;
93 }
The SetupWizard class is the main interface to the setup wizard. It provides selects the sequence of ...
Definition: setupwizard.h:47
SetupWizard * getWizard() const
for i
Definition: OPPlots.m:140
void setActuatorSettings(QList< actuatorChannelSettings > actuatorSettings)
Definition: setupwizard.h:84
QList< actuatorChannelSettings > getActuatorSettings() const
Definition: setupwizard.h:89
bool validatePage()
Definition: outputpage.cpp:60
OutputPage(SetupWizard *wizard, QWidget *parent=nullptr)
Definition: outputpage.cpp:32