1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

LP-551 Changes from review, change names and fix typos.

This commit is contained in:
Laurent Lalanne 2018-01-15 23:42:56 +01:00
parent 5ecf3f22eb
commit a053c015cf
7 changed files with 90 additions and 86 deletions

View File

@ -77,8 +77,6 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
QWidget *widget;
QWidget *inputWidget;
QWidget *outputWidget;
QIcon *icon;
icon = new QIcon();
@ -100,7 +98,7 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
widget = new ConfigInputWidget(this);
static_cast<ConfigTaskWidget *>(widget)->bind();
stackWidget->insertTab(ConfigGadgetWidget::Input, widget, *icon, QString("Input"));
inputWidget = widget;
QWidget *inputWidget = widget;
icon = new QIcon();
icon->addFile(":/configgadget/images/output_normal.png", QSize(), QIcon::Normal, QIcon::Off);
@ -108,7 +106,7 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
widget = new ConfigOutputWidget(this);
static_cast<ConfigTaskWidget *>(widget)->bind();
stackWidget->insertTab(ConfigGadgetWidget::Output, widget, *icon, QString("Output"));
outputWidget = widget;
QWidget *outputWidget = widget;
icon = new QIcon();
icon->addFile(":/configgadget/images/ins_normal.png", QSize(), QIcon::Normal, QIcon::Off);
@ -169,10 +167,11 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
onOPLinkConnect();
}
// Connect output tab and input tab for safe
// output config and input calibration
connect(outputWidget, SIGNAL(outputConfigSafe(bool)), inputWidget, SLOT(outputConfigSafe(bool)));
connect(inputWidget, SIGNAL(inputCalibrationStatus(bool)), outputWidget, SLOT(inputCalibrationStatus(bool)));
// Connect output tab and input tab
// Input tab do not start calibration if Output tab is not safe
// Output tab uses the signal from Input tab and freeze all output UI while calibrating inputs
connect(outputWidget, SIGNAL(outputConfigSafeChanged(bool)), inputWidget, SLOT(setOutputConfigSafe(bool)));
connect(inputWidget, SIGNAL(inputCalibrationStateChanged(bool)), outputWidget, SLOT(setInputCalibrationState(bool)));
help = 0;
connect(stackWidget, SIGNAL(currentAboutToShow(int, bool *)), this, SLOT(tabAboutToChange(int, bool *)));

View File

@ -505,7 +505,7 @@ void ConfigInputWidget::enableControls(bool enable)
// Close manual calibration
ui->runCalibration->setChecked(false);
ui->runCalibration->setText(tr("Start Manual Calibration"));
emit inputCalibrationStatus(false);
emit inputCalibrationStateChanged(false);
}
}
}
@ -519,9 +519,9 @@ void ConfigInputWidget::resizeEvent(QResizeEvent *event)
void ConfigInputWidget::goToWizard()
{
if (!safeOutputConfig) {
QMessageBox::warning(this, tr("Warning"), tr("There is something wrong in <b>Output tab</b>."
"<p>Please fix the issue before starting the Transmitter wizard</p>"), QMessageBox::Ok);
if (!outputConfigIsSafe) {
QMessageBox::warning(this, tr("Warning"), tr("There is something wrong in <b>Output</b> tab."
"<p>Please fix the issue before starting the Transmitter wizard.</p>"), QMessageBox::Ok);
return;
}
@ -536,7 +536,7 @@ void ConfigInputWidget::goToWizard()
msgBox.exec();
// Tell Output tab we freeze actuators soon
emit inputCalibrationStatus(true);
emit inputCalibrationStateChanged(true);
// Set correct tab visible before starting wizard.
if (ui->tabWidget->currentIndex() != 0) {
@ -608,7 +608,7 @@ void ConfigInputWidget::wzCancel()
systemSettingsObj->setData(memento.systemSettingsData);
// Tell Output tab the calibration is ended
emit inputCalibrationStatus(false);
emit inputCalibrationStateChanged(false);
}
void ConfigInputWidget::registerControlActivity()
@ -706,7 +706,7 @@ void ConfigInputWidget::wzNext()
ui->tabWidget->setCurrentIndex(3);
// Tell Output tab the calibration is ended
emit inputCalibrationStatus(false);
emit inputCalibrationStateChanged(false);
break;
default:
Q_ASSERT(0);
@ -1897,7 +1897,7 @@ void ConfigInputWidget::updateConfigAlarmStatus()
switch (systemAlarms.ExtendedAlarmStatus[SystemAlarms::EXTENDEDALARMSTATUS_SYSTEMCONFIGURATION]) {
case SystemAlarms::EXTENDEDALARMSTATUS_FLIGHTMODE:
message = tr("Config error");
tooltipMessage = tr("There is something wrong with your config,\nusually a Thrust mode or Assisted mode not supported.\n\n"
tooltipMessage = tr("There is something wrong in the current config,\nusually a Thrust mode or Assisted mode not supported.\n\n"
"Tip: Reduce the Flight Mode Count to find the culprit.");
bgColor = "red";
}
@ -1945,10 +1945,10 @@ void ConfigInputWidget::simpleCalibration(bool enable)
return;
}
if (!safeOutputConfig) {
if (!outputConfigIsSafe) {
if (enable) {
QMessageBox::warning(this, tr("Warning"), tr("There is something wrong in <b>Output tab</b>."
"<p>Please fix the issue before starting the Manual Calibration</p>"), QMessageBox::Ok);
QMessageBox::warning(this, tr("Warning"), tr("There is something wrong in <b>Output</b> tab."
"<p>Please fix the issue before starting the Manual Calibration.</p>"), QMessageBox::Ok);
ui->runCalibration->setChecked(false);
}
return;
@ -1971,7 +1971,7 @@ void ConfigInputWidget::simpleCalibration(bool enable)
msgBox.exec();
// Tell Output tab we freeze actuators soon
emit inputCalibrationStatus(true);
emit inputCalibrationStateChanged(true);
manualCommandData = manualCommandObj->getData();
@ -2041,7 +2041,7 @@ void ConfigInputWidget::simpleCalibration(bool enable)
ui->runCalibration->setText(tr("Start Manual Calibration"));
// Tell Output tab the calibration is ended
emit inputCalibrationStatus(false);
emit inputCalibrationStateChanged(false);
disconnect(manualCommandObj, SIGNAL(objectUnpacked(UAVObject *)), this, SLOT(updateCalibration()));
}
@ -2234,7 +2234,7 @@ void ConfigInputWidget::enableControlsChanged(bool enabled)
ui->failsafeBatteryCriticalFlightModeCb->setEnabled(enabled && batteryModuleEnabled);
}
void ConfigInputWidget::outputConfigSafe(bool status)
void ConfigInputWidget::setOutputConfigSafe(bool status)
{
safeOutputConfig = status;
outputConfigIsSafe = status;
}

View File

@ -73,16 +73,16 @@ public:
bool shouldObjectBeSaved(UAVObject *object);
public slots:
void outputConfigSafe(bool status);
void setOutputConfigSafe(bool status);
signals:
void inputCalibrationStatus(bool started);
void inputCalibrationStateChanged(bool newState);
private:
bool throttleError;
bool growing;
bool reverse[ManualControlSettings::CHANNELNEUTRAL_NUMELEM];
bool safeOutputConfig;
bool outputConfigIsSafe;
txMovements currentMovement;
int movePos;
void setTxMovement(txMovements movement);

View File

@ -193,7 +193,7 @@ void ConfigOutputWidget::runChannelTests(bool state)
{
if (!checkOutputConfig()) {
m_ui->channelOutTest->setChecked(false);
QMessageBox::warning(this, tr("Warning"), tr("There is something wrong in current config."
QMessageBox::warning(this, tr("Warning"), tr("There is something wrong in the current config."
"<p>Please fix the issue before starting testing outputs.</p>"), QMessageBox::Ok);
return;
}
@ -233,13 +233,13 @@ void ConfigOutputWidget::runChannelTests(bool state)
channelTestsStarted = state;
// Emit signal to be received by Input tab
emit outputConfigSafe(!state);
emit outputConfigSafeChanged(!state);
m_ui->spinningArmed->setEnabled(!state);
m_ui->alwaysStabilizedSwitch->setEnabled((m_ui->spinningArmed->isChecked()) && !state);
m_ui->alwayStabilizedLabel1->setEnabled((m_ui->spinningArmed->isChecked()) && !state);
m_ui->alwayStabilizedLabel2->setEnabled((m_ui->spinningArmed->isChecked()) && !state);
enableBanks(!state);
setBanksEnabled(!state);
ActuatorCommand *obj = ActuatorCommand::GetInstance(getObjectManager());
UAVObject::Metadata mdata = obj->getMetadata();
@ -526,9 +526,9 @@ void ConfigOutputWidget::updateObjectsFromWidgetsImpl()
void ConfigOutputWidget::updateSpinStabilizeCheckComboBoxes()
{
m_ui->alwayStabilizedLabel1->setEnabled(m_ui->spinningArmed->isChecked());
m_ui->alwayStabilizedLabel2->setEnabled(m_ui->spinningArmed->isChecked());
m_ui->alwaysStabilizedSwitch->setEnabled(m_ui->spinningArmed->isChecked());
m_ui->alwayStabilizedLabel1->setEnabled((m_ui->spinningArmed->isChecked()) && (m_ui->spinningArmed->isEnabled()));
m_ui->alwayStabilizedLabel2->setEnabled((m_ui->spinningArmed->isChecked()) && (m_ui->spinningArmed->isEnabled()));
m_ui->alwaysStabilizedSwitch->setEnabled((m_ui->spinningArmed->isChecked()) && (m_ui->spinningArmed->isEnabled()));
if (!m_ui->spinningArmed->isChecked()) {
m_ui->alwaysStabilizedSwitch->setCurrentIndex(FlightModeSettings::ALWAYSSTABILIZEWHENARMEDSWITCH_DISABLED);
@ -608,7 +608,7 @@ ConfigOutputWidget::ChannelConfigWarning ConfigOutputWidget::checkChannelConfig(
int currentNeutralValue = channelForm->neutralValue();
// Check if RevMotor has neutral value around center
if (channelForm->isReversableMotor()) {
if (channelForm->isReversibleMotorOutput()) {
warning = IsReversibleMotorCheckNeutral;
int neutralDiff = qAbs(REVMOTOR_NEUTRAL_TARGET_VALUE - currentNeutralValue);
if (neutralDiff < REVMOTOR_NEUTRAL_DIFF_VALUE) {
@ -618,7 +618,7 @@ ConfigOutputWidget::ChannelConfigWarning ConfigOutputWidget::checkChannelConfig(
}
// Check if NormalMotor neutral is not too high
if (channelForm->isNormalMotor()) {
if (channelForm->isNormalMotorOutput()) {
warning = IsNormalMotorCheckNeutral;
int neutralDiff = currentNeutralValue - DEFAULT_MINOUTPUT_VALUE;
if (neutralDiff < MOTOR_NEUTRAL_DIFF_VALUE) {
@ -632,7 +632,7 @@ ConfigOutputWidget::ChannelConfigWarning ConfigOutputWidget::checkChannelConfig(
if (channelForm->isServoOutput()) {
// Driving a servo using DShot doest not make sense
warning = CannotDriveServo;
} else if (channelForm->isReversableMotor()) {
} else if (channelForm->isReversibleMotorOutput()) {
// Bi-directional DShot not yet supported
warning = BiDirectionalDShotNotSupported;
}
@ -659,8 +659,7 @@ void ConfigOutputWidget::onBankTypeChange()
{
QComboBox *bankModeCombo = qobject_cast<QComboBox *>(sender());
ChannelConfigWarning current_warning = None;
ChannelConfigWarning warning_found = None;
ChannelConfigWarning new_warning = None;
if (bankModeCombo != NULL) {
int bankNumber = 1;
@ -673,9 +672,9 @@ void ConfigOutputWidget::onBankTypeChange()
foreach(OutputChannelForm * outputChannelForm, outputChannelForms) {
if (outputChannelForm->bank().toInt() == bankNumber) {
setChannelLimits(outputChannelForm, &controls);
current_warning = checkChannelConfig(outputChannelForm, &controls);
if (current_warning > None) {
warning_found = current_warning;
ChannelConfigWarning warning = checkChannelConfig(outputChannelForm, &controls);
if (warning > None) {
new_warning = warning;
}
}
}
@ -686,13 +685,12 @@ void ConfigOutputWidget::onBankTypeChange()
}
}
updateChannelConfigWarning(warning_found);
updateChannelConfigWarning(new_warning);
}
bool ConfigOutputWidget::checkOutputConfig()
{
ChannelConfigWarning current_warning = None;
ChannelConfigWarning warning_found = None;
ChannelConfigWarning new_warning = None;
int bankNumber = 1;
@ -701,9 +699,9 @@ bool ConfigOutputWidget::checkOutputConfig()
foreach(OutputBankControls controls, m_banks) {
foreach(OutputChannelForm * outputChannelForm, outputChannelForms) {
if (!outputChannelForm->isDisabledOutput() && (outputChannelForm->bank().toInt() == bankNumber)) {
current_warning = checkChannelConfig(outputChannelForm, &controls);
if (current_warning > None) {
warning_found = current_warning;
ChannelConfigWarning warning = checkChannelConfig(outputChannelForm, &controls);
if (warning > None) {
new_warning = warning;
}
}
}
@ -711,12 +709,12 @@ bool ConfigOutputWidget::checkOutputConfig()
bankNumber++;
}
updateChannelConfigWarning(warning_found);
updateChannelConfigWarning(new_warning);
// Emit signal to be received by Input tab
emit outputConfigSafe(warning_found == None);
emit outputConfigSafeChanged(new_warning == None);
return warning_found == None;
return new_warning == None;
}
void ConfigOutputWidget::stopTests()
@ -749,29 +747,29 @@ void ConfigOutputWidget::updateChannelConfigWarning(ChannelConfigWarning warning
if (warning == BiDirectionalDShotNotSupported) {
// TODO: Implement bi-directional DShot
warning_str = "There is at least <b>one reversable motor using DShot</b> in your configuration.<br>"
"Bi-directional DShot is not currently supported, you should use PWM, OneShotXXX or MultiShot.";
warning_str = "There is <b>one reversible motor</b> using DShot is configured.<br>"
"Bi-directional DShot is currently not supported. Please use PWM, OneShotXXX or MultiShot.";
}
if (warning == IsNormalMotorCheckNeutral) {
warning_str = "Seems there is at least one pretty <b>high neutral value</b> set in your configuration.<br>"
"Be sure all Esc are calibrated and no mechanical stress in all motors.";
warning_str = "There is at least one pretty <b>high neutral value</b> set in your configuration.<br>"
"Make sure all ESCs are calibrated and no mechanical stress in all motors.";
}
if (warning == IsReversibleMotorCheckNeutral) {
warning_str = "There is at least one <b>reversable motor</b> in your configuration.<br>"
"Be sure you set a appropriate neutral value before saving and applying power to the vehicule.";
warning_str = "A least one <b>reversible motor</b> is configured.<br>"
"Make sure a appropriate neutral value is set before saving and applying power to the vehicule.";
}
if (warning == CannotDriveServo) {
warning_str = "One Bank cannot drive a <b>servo output!</b><br>"
warning_str = "One bank cannot drive a <b>servo output</b>!<br>"
"You must use PWM for this bank or move the servo output to another compatible bank.";
}
setConfigWarning(warning_str);
}
void ConfigOutputWidget::enableBanks(bool state)
void ConfigOutputWidget::setBanksEnabled(bool state)
{
// Disable/Enable banks
for (int i = 0; i < m_banks.count(); i++) {
@ -800,22 +798,27 @@ void ConfigOutputWidget::setConfigWarning(QString message)
m_ui->configWarningTxt->setText(message);
}
void ConfigOutputWidget::inputCalibrationStatus(bool started)
void ConfigOutputWidget::setInputCalibrationState(bool started)
{
inputCalibrationStarted = started;
// Disable UI when a input calibration is started
// so user cannot manipulate settings.
enableControls(!started);
enableBanks(!started);
setBanksEnabled(!started);
// Disable ASWA
m_ui->spinningArmed->setEnabled(!started);
m_ui->alwaysStabilizedSwitch->setEnabled((m_ui->spinningArmed->isChecked()) && !started);
m_ui->alwayStabilizedLabel1->setEnabled((m_ui->spinningArmed->isChecked()) && !started);
m_ui->alwayStabilizedLabel2->setEnabled((m_ui->spinningArmed->isChecked()) && !started);
// Disable every channel form when needed
for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) {
OutputChannelForm *form = getOutputChannelForm(i);
form->ui->actuatorRev->setChecked(false);
form->ui->actuatorLink->setChecked(false);
form->inputCalibrationStatus(started);
form->enableControls(!started);
form->setChannelRangeEnabled(!started);
form->setControlsEnabled(!started);
}
}

View File

@ -86,10 +86,10 @@ public:
~ConfigOutputWidget();
public slots:
void inputCalibrationStatus(bool started);
void setInputCalibrationState(bool state);
signals:
void outputConfigSafe(bool status);
void outputConfigSafeChanged(bool newStatus);
protected:
void enableControls(bool enable);
@ -106,7 +106,7 @@ private:
UAVObject::Metadata m_accInitialData;
QList<OutputBankControls> m_banks;
int activeBanksCount;
void enableBanks(bool state);
void setBanksEnabled(bool state);
bool inputCalibrationStarted;
bool channelTestsStarted;

View File

@ -31,7 +31,7 @@
#include <QDebug>
OutputChannelForm::OutputChannelForm(const int index, QWidget *parent) :
ChannelForm(index, parent), ui(new Ui::outputChannelForm), m_inChannelTest(false), m_isCalibratingInput(false)
ChannelForm(index, parent), ui(new Ui::outputChannelForm), m_inChannelTest(false), m_updateChannelRangeEnabled(true)
{
ui->setupUi(this);
@ -114,21 +114,21 @@ void OutputChannelForm::enableChannelTest(bool state)
} else if (!isDisabledOutput()) {
ui->actuatorMin->setEnabled(true);
ui->actuatorMax->setEnabled(true);
if (!isNormalMotor()) {
if (!isNormalMotorOutput()) {
ui->actuatorRev->setEnabled(true);
}
}
}
/**
* Update the input calibration status
* Enable/Disable setChannelRange
*/
void OutputChannelForm::inputCalibrationStatus(bool state)
void OutputChannelForm::setChannelRangeEnabled(bool state)
{
if (m_isCalibratingInput == state) {
if (m_updateChannelRangeEnabled == state) {
return;
}
m_isCalibratingInput = state;
m_updateChannelRangeEnabled = state;
}
/**
@ -255,16 +255,16 @@ void OutputChannelForm::setChannelRange()
ui->actuatorMax->setValue(1000);
ui->actuatorRev->setChecked(false);
ui->actuatorLink->setChecked(false);
enableControls(false);
setControlsEnabled(false);
return;
}
if (m_isCalibratingInput) {
if (!m_updateChannelRangeEnabled) {
// Nothing to do here
return;
}
enableControls(true);
setControlsEnabled(true);
int minValue = ui->actuatorMin->value();
int maxValue = ui->actuatorMax->value();
@ -273,7 +273,7 @@ void OutputChannelForm::setChannelRange()
int oldMaxi = ui->actuatorNeutral->maximum();
// Red handle for Motors
if (isNormalMotor() || isReversableMotor()) {
if (isNormalMotorOutput() || isReversibleMotorOutput()) {
ui->actuatorNeutral->setStyleSheet("QSlider::handle:horizontal { background: rgb(255, 100, 100); width: 18px; height: 28px;"
"margin: -3px 0; border-radius: 3px; border: 1px solid #777; }");
} else {
@ -282,7 +282,7 @@ void OutputChannelForm::setChannelRange()
}
// Normal motor will be *** never *** reversed : without arming a "Min" value (like 1900) can be applied !
if (isNormalMotor()) {
if (isNormalMotorOutput()) {
if (minValue > maxValue) {
// Keep old values
ui->actuatorMin->setValue(oldMini);
@ -334,7 +334,7 @@ void OutputChannelForm::reverseChannel(bool state)
/**
* Enable/Disable UI controls
*/
void OutputChannelForm::enableControls(bool state)
void OutputChannelForm::setControlsEnabled(bool state)
{
if (isDisabledOutput()) {
state = false;
@ -345,7 +345,7 @@ void OutputChannelForm::enableControls(bool state)
ui->actuatorLink->setEnabled(state);
// Reverse checkbox will be never checked
// or enabled for normal motor
if (isNormalMotor()) {
if (isNormalMotorOutput()) {
ui->actuatorRev->setChecked(false);
ui->actuatorRev->setEnabled(false);
} else {
@ -439,23 +439,23 @@ QString OutputChannelForm::outputMixerType()
*/
bool OutputChannelForm::isServoOutput()
{
return !isNormalMotor() && !isReversableMotor() && !isDisabledOutput();
return !isNormalMotorOutput() && !isReversibleMotorOutput() && !isDisabledOutput();
}
/**
*
* Returns true if output is a normal Motor
*/
bool OutputChannelForm::isNormalMotor()
bool OutputChannelForm::isNormalMotorOutput()
{
return outputMixerType() == "Motor";
}
/**
*
* Returns true if output is a reversable Motor
* Returns true if output is a reversible Motor
*/
bool OutputChannelForm::isReversableMotor()
bool OutputChannelForm::isReversibleMotorOutput()
{
return outputMixerType() == "ReversableMotor";
}

View File

@ -61,14 +61,16 @@ public slots:
void setNeutral(int value);
void setRange(int minimum, int maximum);
void enableChannelTest(bool state);
void inputCalibrationStatus(bool state);
void enableControls(bool state);
void setChannelRangeEnabled(bool state);
void setControlsEnabled(bool state);
QString outputMixerType();
void setLimits(int actuatorMinMinimum, int actuatorMinMaximum, int actuatorMaxMinimum, int actuatorMaxMaximum);
int neutralValue();
// output type helper methods
bool isServoOutput();
bool isNormalMotor();
bool isReversableMotor();
bool isNormalMotorOutput();
bool isReversibleMotorOutput();
bool isDisabledOutput();
signals:
@ -77,7 +79,7 @@ signals:
private:
Ui::outputChannelForm *ui;
bool m_inChannelTest;
bool m_isCalibratingInput;
bool m_updateChannelRangeEnabled;
QString m_mixerType;
private slots: