@@ -497,6 +497,16 @@ void ConfigInputWidget::enableControls(bool enable)
497497 } else {
498498 // Hide configAlarmStatus when disconnected
499499 ui->configAlarmStatus ->setVisible (false );
500+ if (wizardStep != wizardNone) {
501+ // Close input wizard
502+ wzCancel ();
503+ }
504+ if (ui->runCalibration ->isChecked ()) {
505+ // Close manual calibration
506+ ui->runCalibration ->setChecked (false );
507+ ui->runCalibration ->setText (tr (" Start Manual Calibration" ));
508+ emit inputCalibrationStateChanged (false );
509+ }
500510 }
501511}
502512
@@ -509,6 +519,12 @@ void ConfigInputWidget::resizeEvent(QResizeEvent *event)
509519
510520void ConfigInputWidget::goToWizard ()
511521{
522+ if (!outputConfigIsSafe) {
523+ QMessageBox::warning (this , tr (" Warning" ), tr (" There is something wrong in <b>Output</b> tab."
524+ " <p>Please fix the issue before starting the Transmitter wizard.</p>" ), QMessageBox::Ok);
525+ return ;
526+ }
527+
512528 QMessageBox msgBox;
513529
514530 msgBox.setText (tr (" Arming Settings are now set to 'Always Disarmed' for your safety." ));
@@ -519,6 +535,9 @@ void ConfigInputWidget::goToWizard()
519535 msgBox.setDefaultButton (QMessageBox::Ok);
520536 msgBox.exec ();
521537
538+ // Tell Output tab we freeze actuators soon
539+ emit inputCalibrationStateChanged (true );
540+
522541 // Set correct tab visible before starting wizard.
523542 if (ui->tabWidget ->currentIndex () != 0 ) {
524543 ui->tabWidget ->setCurrentIndex (0 );
@@ -587,6 +606,9 @@ void ConfigInputWidget::wzCancel()
587606 flightModeSettingsObj->setData (memento.flightModeSettingsData );
588607 actuatorSettingsObj->setData (memento.actuatorSettingsData );
589608 systemSettingsObj->setData (memento.systemSettingsData );
609+
610+ // Tell Output tab the calibration is ended
611+ emit inputCalibrationStateChanged (false );
590612}
591613
592614void ConfigInputWidget::registerControlActivity ()
@@ -682,6 +704,9 @@ void ConfigInputWidget::wzNext()
682704 // move to Arming Settings tab
683705 ui->stackedWidget ->setCurrentIndex (0 );
684706 ui->tabWidget ->setCurrentIndex (3 );
707+
708+ // Tell Output tab the calibration is ended
709+ emit inputCalibrationStateChanged (false );
685710 break ;
686711 default :
687712 Q_ASSERT (0 );
@@ -1872,7 +1897,7 @@ void ConfigInputWidget::updateConfigAlarmStatus()
18721897 switch (systemAlarms.ExtendedAlarmStatus [SystemAlarms::EXTENDEDALARMSTATUS_SYSTEMCONFIGURATION]) {
18731898 case SystemAlarms::EXTENDEDALARMSTATUS_FLIGHTMODE:
18741899 message = tr (" Config error" );
1875- tooltipMessage = tr (" There is something wrong with your config,\n usually a Thrust mode or Assisted mode not supported.\n\n "
1900+ tooltipMessage = tr (" There is something wrong in the current config,\n usually a Thrust mode or Assisted mode not supported.\n\n "
18761901 " Tip: Reduce the Flight Mode Count to find the culprit." );
18771902 bgColor = " red" ;
18781903 }
@@ -1916,6 +1941,19 @@ void ConfigInputWidget::updateCalibration()
19161941
19171942void ConfigInputWidget::simpleCalibration (bool enable)
19181943{
1944+ if (!isConnected ()) {
1945+ return ;
1946+ }
1947+
1948+ if (!outputConfigIsSafe) {
1949+ if (enable) {
1950+ QMessageBox::warning (this , tr (" Warning" ), tr (" There is something wrong in <b>Output</b> tab."
1951+ " <p>Please fix the issue before starting the Manual Calibration.</p>" ), QMessageBox::Ok);
1952+ ui->runCalibration ->setChecked (false );
1953+ }
1954+ return ;
1955+ }
1956+
19191957 if (enable) {
19201958 ui->configurationWizard ->setEnabled (false );
19211959 ui->applyButton ->setEnabled (false );
@@ -1932,6 +1970,9 @@ void ConfigInputWidget::simpleCalibration(bool enable)
19321970 msgBox.setDefaultButton (QMessageBox::Ok);
19331971 msgBox.exec ();
19341972
1973+ // Tell Output tab we freeze actuators soon
1974+ emit inputCalibrationStateChanged (true );
1975+
19351976 manualCommandData = manualCommandObj->getData ();
19361977
19371978 manualSettingsData = manualSettingsObj->getData ();
@@ -1999,6 +2040,9 @@ void ConfigInputWidget::simpleCalibration(bool enable)
19992040 ui->saveButton ->setEnabled (true );
20002041 ui->runCalibration ->setText (tr (" Start Manual Calibration" ));
20012042
2043+ // Tell Output tab the calibration is ended
2044+ emit inputCalibrationStateChanged (false );
2045+
20022046 disconnect (manualCommandObj, SIGNAL (objectUnpacked (UAVObject *)), this , SLOT (updateCalibration ()));
20032047 }
20042048}
@@ -2082,7 +2126,7 @@ void ConfigInputWidget::resetActuatorSettings()
20822126 QString mixerType;
20832127
20842128 // Clear all output data : Min, max, neutral at same value
2085- // 1000 for motors and 1500 for all others (Reversable motor included )
2129+ // min value for motors and neutral for all others (Reversable motor, servo )
20862130 for (unsigned int output = 0 ; output < ActuatorSettings::CHANNELMAX_NUMELEM; output++) {
20872131 QString mixerNumType = QString (" Mixer%1Type" ).arg (output + 1 );
20882132 UAVObjectField *field = mixer->getField (mixerNumType);
@@ -2092,13 +2136,13 @@ void ConfigInputWidget::resetActuatorSettings()
20922136 mixerType = field->getValue ().toString ();
20932137 }
20942138 if ((mixerType == " Motor" ) || (mixerType == " Disabled" )) {
2095- actuatorSettingsData. ChannelMax [output] = 1000 ;
2096- actuatorSettingsData.ChannelMin [output] = 1000 ;
2097- actuatorSettingsData.ChannelNeutral [output] = 1000 ;
2139+ // Apply current min setting to neutral/max values
2140+ actuatorSettingsData.ChannelMax [output] = actuatorSettingsData. ChannelMin [output] ;
2141+ actuatorSettingsData.ChannelNeutral [output] = actuatorSettingsData. ChannelMin [output] ;
20982142 } else {
2099- actuatorSettingsData. ChannelMax [output] = 1500 ;
2100- actuatorSettingsData.ChannelMin [output] = 1500 ;
2101- actuatorSettingsData.ChannelNeutral [output] = 1500 ;
2143+ // Apply current neutral setting to min/max values
2144+ actuatorSettingsData.ChannelMax [output] = actuatorSettingsData. ChannelNeutral [output] ;
2145+ actuatorSettingsData.ChannelMin [output] = actuatorSettingsData. ChannelNeutral [output] ;
21022146 }
21032147 UAVObjectUpdaterHelper updateHelper;
21042148 actuatorSettingsObj->setData (actuatorSettingsData, false );
@@ -2189,3 +2233,8 @@ void ConfigInputWidget::enableControlsChanged(bool enabled)
21892233 ui->failsafeBatteryWarningFlightModeCb ->setEnabled (enabled && batteryModuleEnabled);
21902234 ui->failsafeBatteryCriticalFlightModeCb ->setEnabled (enabled && batteryModuleEnabled);
21912235}
2236+
2237+ void ConfigInputWidget::setOutputConfigSafe (bool status)
2238+ {
2239+ outputConfigIsSafe = status;
2240+ }
0 commit comments