Skip to content

Commit b0e3093

Browse files
f5sohfilnet
authored andcommitted
Merged in f5soh/librepilot/LP-551_Tx_Wizard_output (pull request #488)
LP-551 Tx Wizard output Approved-by: Lalanne Laurent <f5soh@free.fr> Approved-by: Philippe Renon <philippe_renon@yahoo.fr>
2 parents cd94147 + 7cfa989 commit b0e3093

8 files changed

Lines changed: 549 additions & 67 deletions

File tree

ground/gcs/src/plugins/config/configgadgetwidget.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
9898
widget = new ConfigInputWidget(this);
9999
static_cast<ConfigTaskWidget *>(widget)->bind();
100100
stackWidget->insertTab(ConfigGadgetWidget::Input, widget, *icon, QString("Input"));
101+
QWidget *inputWidget = widget;
101102

102103
icon = new QIcon();
103104
icon->addFile(":/configgadget/images/output_normal.png", QSize(), QIcon::Normal, QIcon::Off);
104105
icon->addFile(":/configgadget/images/output_selected.png", QSize(), QIcon::Selected, QIcon::Off);
105106
widget = new ConfigOutputWidget(this);
106107
static_cast<ConfigTaskWidget *>(widget)->bind();
107108
stackWidget->insertTab(ConfigGadgetWidget::Output, widget, *icon, QString("Output"));
109+
QWidget *outputWidget = widget;
108110

109111
icon = new QIcon();
110112
icon->addFile(":/configgadget/images/ins_normal.png", QSize(), QIcon::Normal, QIcon::Off);
@@ -165,6 +167,12 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
165167
onOPLinkConnect();
166168
}
167169

170+
// Connect output tab and input tab
171+
// Input tab do not start calibration if Output tab is not safe
172+
// Output tab uses the signal from Input tab and freeze all output UI while calibrating inputs
173+
connect(outputWidget, SIGNAL(outputConfigSafeChanged(bool)), inputWidget, SLOT(setOutputConfigSafe(bool)));
174+
connect(inputWidget, SIGNAL(inputCalibrationStateChanged(bool)), outputWidget, SLOT(setInputCalibrationState(bool)));
175+
168176
help = 0;
169177
connect(stackWidget, SIGNAL(currentAboutToShow(int, bool *)), this, SLOT(tabAboutToChange(int, bool *)));
170178
}

ground/gcs/src/plugins/config/configinputwidget.cpp

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

510520
void 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

592614
void 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,\nusually a Thrust mode or Assisted mode not supported.\n\n"
1900+
tooltipMessage = tr("There is something wrong in the current config,\nusually 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

19171942
void 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+
}

ground/gcs/src/plugins/config/configinputwidget.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,17 @@ class ConfigInputWidget : public ConfigTaskWidget {
7272
void enableControls(bool enable);
7373
bool shouldObjectBeSaved(UAVObject *object);
7474

75+
public slots:
76+
void setOutputConfigSafe(bool status);
77+
78+
signals:
79+
void inputCalibrationStateChanged(bool newState);
80+
7581
private:
7682
bool throttleError;
7783
bool growing;
7884
bool reverse[ManualControlSettings::CHANNELNEUTRAL_NUMELEM];
85+
bool outputConfigIsSafe;
7986
txMovements currentMovement;
8087
int movePos;
8188
void setTxMovement(txMovements movement);

0 commit comments

Comments
 (0)