diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp index da1090626..c3bfcfac8 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp @@ -46,9 +46,10 @@ EscCalibrationPage::EscCalibrationPage(SetupWizard *wizard, QWidget *parent) : ui->outputHigh->setEnabled(false); ui->outputLow->setEnabled(true); ui->outputLevel->setEnabled(true); - ui->outputLevel->setText(QString(tr("%1 µs")).arg(0)); + ui->outputLevel->setText(QString(tr("%1 µs")).arg(OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS)); - connect(ui->startStopButton, SIGNAL(clicked()), this, SLOT(startStopButtonClicked())); + connect(ui->startButton, SIGNAL(clicked()), this, SLOT(startButtonClicked())); + connect(ui->stopButton, SIGNAL(clicked()), this, SLOT(stopButtonClicked())); connect(ui->securityCheckBox1, SIGNAL(toggled(bool)), this, SLOT(securityCheckBoxesToggled())); connect(ui->securityCheckBox2, SIGNAL(toggled(bool)), this, SLOT(securityCheckBoxesToggled())); @@ -84,14 +85,16 @@ void EscCalibrationPage::resetAllSecurityCheckboxes() ui->securityCheckBox3->setChecked(false); } -void EscCalibrationPage::startStopButtonClicked() +void EscCalibrationPage::startButtonClicked() { if (!m_isCalibrating) { m_isCalibrating = true; - ui->startStopButton->setEnabled(false); + ui->startButton->setEnabled(false); enableButtons(false); ui->outputHigh->setEnabled(true); ui->outputLow->setEnabled(false); + ui->nonconnectedLabel->setEnabled(false); + ui->connectedLabel->setEnabled(true); ui->outputLevel->setText(QString(tr("%1 µs")).arg(HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS)); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *uavoManager = pm->getObject(); @@ -104,43 +107,59 @@ void EscCalibrationPage::startStopButtonClicked() Q_ASSERT(field); if (field->getValue().toString() == field->getOptions().at(VehicleConfigurationHelper::MIXER_TYPE_MOTOR)) { OutputCalibrationUtil *output = new OutputCalibrationUtil(); - output->startChannelOutput(i, 0); + output->startChannelOutput(i, OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS); output->setChannelOutputValue(HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS); m_outputs << output; } } - ui->startStopButton->setText(tr("Stop")); - ui->startStopButton->setEnabled(true); - } else { - m_isCalibrating = false; - ui->startStopButton->setEnabled(false); + ui->stopButton->setEnabled(true); + } +} + +void EscCalibrationPage::stopButtonClicked() +{ + if (m_isCalibrating) { + ui->stopButton->setEnabled(false); ui->outputHigh->setEnabled(false); + + // Set to low pwm out foreach(OutputCalibrationUtil * output, m_outputs) { output->setChannelOutputValue(LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS); } ui->outputLevel->setText(QString(tr("%1 µs")).arg(LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS)); + QApplication::processEvents(); + QThread::msleep(2000); - qApp->processEvents(QEventLoop::AllEvents); - QThread::msleep(1000); + // Ramp down to off pwm out + for (int i = LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS; i >= OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS; i -= 10) { + foreach(OutputCalibrationUtil * output, m_outputs) { + output->setChannelOutputValue(i); + } + ui->outputLevel->setText(QString(tr("%1 µs")).arg(i)); + QApplication::processEvents(); + QThread::msleep(200); + } + // Stop output foreach(OutputCalibrationUtil * output, m_outputs) { output->stopChannelOutput(); delete output; } - ui->outputLevel->setText(QString(tr("%1 µs")).arg(0)); + ui->outputLevel->setText(QString(tr("%1 µs")).arg(OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS)); ui->outputHigh->setEnabled(false); ui->outputLow->setEnabled(true); + ui->nonconnectedLabel->setEnabled(true); + ui->connectedLabel->setEnabled(false); m_outputs.clear(); m_isCalibrating = false; resetAllSecurityCheckboxes(); - ui->startStopButton->setText(tr("Start")); enableButtons(true); } } void EscCalibrationPage::securityCheckBoxesToggled() { - ui->startStopButton->setEnabled(ui->securityCheckBox1->isChecked() && + ui->startButton->setEnabled(ui->securityCheckBox1->isChecked() && ui->securityCheckBox2->isChecked() && ui->securityCheckBox3->isChecked()); } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.h index 5aca966c3..1b20fc0c8 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.h @@ -46,13 +46,15 @@ public: void initializePage(); private slots: - void startStopButtonClicked(); + void startButtonClicked(); + void stopButtonClicked(); void securityCheckBoxesToggled(); void enableButtons(bool enable); void resetAllSecurityCheckboxes(); private: - static const int LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS = 1000; + static const int LOW_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS = 1050; + static const int OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS = 900; static const int HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS = 1900; Ui::EscCalibrationPage *ui; bool m_isCalibrating; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.ui index 8e62e6ce8..acacc0215 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.ui @@ -7,7 +7,7 @@ 0 0 600 - 507 + 585 @@ -16,6 +16,12 @@ + + + 16777215 + 16777215 + + <html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">OpenPilot ESC Calibration Procedure</span></p><p><span style=" font-size:10pt;">As you have selected to use a MultiRotor and Fast / Flashed ESCs, we need to calibrate the endpoints of these ESCs so they can see the full throttle range sent from the flight controller. </span></p><p><span style=" font-size:10pt;">This part of the wizard will tell you to connect the battery to your aircraft, before doing so you absolutely </span><span style=" font-size:10pt; font-weight:600; color:#f30f1d;">must remove the propellers from all motors</span><span style=" font-size:10pt;">. </span></p><p><span style=" font-size:10pt;">The steps to perform this calibration are as follows:</span></p><p><span style=" font-size:10pt;">1. Confirm all safety questions<br/>2. Press the Start button when it becomes enabled<br/>3. Connect the battery to your airframe<br/>4. Wait for ESC calibration beep(s)<br/>5. Press the Stop button<br/>6. Wait for ESC confirmation beep(s)<br/>7. Disconnect battery</span></p></body></html> @@ -65,354 +71,403 @@ - - - ESC Output Level + + + 0 - - - 9 - - - 9 - - - 9 - - - - - false - - - - 100 - 22 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 159 - 158 - 158 - - - - - - - 100 - 150 - 255 - - - - - - - 159 - 158 - 158 - - - - - - - 159 - 158 - 158 - - - - - - - 255 - 255 - 255 - - - - - - - 242 - 241 - 240 - - - - - - - - QPushButton:enabled { + + + + + 155 + 70 + + + + + 155 + 70 + + + + + + + :/setupwizard/resources/not-connected.png + + + true + + + + + + + false + + + + 155 + 70 + + + + + 155 + 70 + + + + + + + :/setupwizard/resources/connected.png + + + true + + + + + + + + + 0 + + + + + false + + + + 100 + 22 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 159 + 158 + 158 + + + + + + + 100 + 150 + 255 + + + + + + + 159 + 158 + 158 + + + + + + + 159 + 158 + 158 + + + + + + + 255 + 255 + 255 + + + + + + + 242 + 241 + 240 + + + + + + + + QPushButton:enabled { background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(34, 34, 200, 255), stop:0.78607 rgba(6, 6, 150, 255)); color: rgb(255, 255, 255); border-radius: 5; } - - - Low/Off - - - true - - - - - - - - 0 - 0 - - - - QFrame::Sunken - - - 1 - - - Qt::Horizontal - - - - - - - false - - - N/A - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - - - - - false - - - - 100 - 22 - - - - QPushButton:enabled { + + + Low/Off + + + true + + + + + + + + 0 + 0 + + + + QFrame::Sunken + + + 1 + + + Qt::Horizontal + + + + + + + false + + + N/A + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + + + false + + + + 100 + 22 + + + + QPushButton:enabled { background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(200, 14, 14, 255), stop:0.78607 rgba(160, 6, 6, 255)); color: rgb(255, 255, 255); border-radius: 5; } - - - High - - - true - - - - - + + + High + + + true + + + + @@ -433,7 +488,7 @@ - + false @@ -448,6 +503,22 @@ + + + + false + + + + 0 + 0 + + + + Stop + + + @@ -482,8 +553,10 @@ securityCheckBox1 securityCheckBox2 securityCheckBox3 - startStopButton + startButton - + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index fcc8c836b..936d520f5 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -376,12 +376,7 @@ void OutputCalibrationPage::on_motorNeutralButton_toggled(bool checked) ui->motorNeutralButton->setText(checked ? tr("Stop") : tr("Start")); ui->motorNeutralSlider->setEnabled(checked); quint16 channel = getCurrentChannel(); - quint16 safeValue = 0; - if (!checked) { - // Set pwm output to 1000/low for 500ms before turning it to 0 - m_calibrationUtil->setChannelOutputValue(1000); - QThread::msleep(500); - } + quint16 safeValue = m_actuatorSettings[channel].channelMin; onStartButtonToggle(ui->motorNeutralButton, channel, m_actuatorSettings[channel].channelNeutral, safeValue, ui->motorNeutralSlider); } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/resources/connected.png b/ground/openpilotgcs/src/plugins/setupwizard/resources/connected.png new file mode 100644 index 000000000..d1fd2d044 Binary files /dev/null and b/ground/openpilotgcs/src/plugins/setupwizard/resources/connected.png differ diff --git a/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes-wizard.svg b/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes-wizard.svg index 9115c41a0..20806af24 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes-wizard.svg +++ b/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes-wizard.svg @@ -944,7 +944,16 @@ x1="21.957001" y1="254.2417" x2="249.5493" - y2="254.2417" />6 4 6 resources/bttn-flash-up.png resources/bttn-upgrade-down.png resources/bttn-upgrade-up.png + resources/not-connected.png + resources/connected.png