Skip to content

Commit 76118a2

Browse files
committed
LP-514 Changes from review - Simplify and rename.
1 parent 498aba5 commit 76118a2

2 files changed

Lines changed: 26 additions & 28 deletions

File tree

ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,25 @@ void OutputCalibrationPage::setupActuatorMinMaxAndNeutral(int motorChannelStart,
9191
|| (getWizard()->getVehicleSubType() == SetupWizard::GROUNDVEHICLE_DIFFERENTIAL)
9292
|| (getWizard()->getVehicleSubType() == SetupWizard::GROUNDVEHICLE_BOAT)
9393
|| (getWizard()->getVehicleSubType() == SetupWizard::GROUNDVEHICLE_DIFFERENTIAL_BOAT)) {
94-
m_actuatorSettings[servoid].channelNeutral = NEUTRAL_OUTPUT_RATE_MILLISECONDS;
94+
m_actuatorSettings[servoid].channelNeutral = NEUTRAL_OUTPUT_RATE_MS;
9595
m_actuatorSettings[servoid].isReversableMotor = true;
9696
}
9797
// Set initial output value
9898
m_calibrationUtil->startChannelOutput(servoid, m_actuatorSettings[servoid].channelNeutral);
9999
m_calibrationUtil->stopChannelOutput();
100100
} else if (servoid < totalUsedChannels) {
101101
// Set to servo safe values
102-
m_actuatorSettings[servoid].channelMin = NEUTRAL_OUTPUT_RATE_MILLISECONDS;
103-
m_actuatorSettings[servoid].channelNeutral = NEUTRAL_OUTPUT_RATE_MILLISECONDS;
104-
m_actuatorSettings[servoid].channelMax = NEUTRAL_OUTPUT_RATE_MILLISECONDS;
102+
m_actuatorSettings[servoid].channelMin = NEUTRAL_OUTPUT_RATE_MS;
103+
m_actuatorSettings[servoid].channelNeutral = NEUTRAL_OUTPUT_RATE_MS;
104+
m_actuatorSettings[servoid].channelMax = NEUTRAL_OUTPUT_RATE_MS;
105105
// Set initial servo output value
106-
m_calibrationUtil->startChannelOutput(servoid, NEUTRAL_OUTPUT_RATE_MILLISECONDS);
106+
m_calibrationUtil->startChannelOutput(servoid, NEUTRAL_OUTPUT_RATE_MS);
107107
m_calibrationUtil->stopChannelOutput();
108108
} else {
109109
// "Disable" these channels
110-
m_actuatorSettings[servoid].channelMin = LOW_OUTPUT_RATE_MILLISECONDS;
111-
m_actuatorSettings[servoid].channelNeutral = LOW_OUTPUT_RATE_MILLISECONDS;
112-
m_actuatorSettings[servoid].channelMax = LOW_OUTPUT_RATE_MILLISECONDS;
110+
m_actuatorSettings[servoid].channelMin = LOW_OUTPUT_RATE_MS;
111+
m_actuatorSettings[servoid].channelNeutral = LOW_OUTPUT_RATE_MS;
112+
m_actuatorSettings[servoid].channelMax = LOW_OUTPUT_RATE_MS;
113113
}
114114
}
115115
}
@@ -472,9 +472,9 @@ void OutputCalibrationPage::setWizardPage()
472472
ui->motorNeutralSlider->setMaximum(m_actuatorSettings[currentChannel].channelMin + NEUTRAL_OUTPUT_RATE_RANGE);
473473
if (ui->motorNeutralSlider->minimum() == LOW_OUTPUT_RATE_DSHOT) {
474474
// DShot output
475-
ui->motorPWMValue->setText(QString(tr("Digital output value : <b>%1</b>")).arg(m_actuatorSettings[currentChannel].channelNeutral));
475+
ui->motorPWMValue->setText(tr("Digital output value : <b>%1</b>").arg(m_actuatorSettings[currentChannel].channelNeutral));
476476
} else {
477-
ui->motorPWMValue->setText(QString(tr("Output value : <b>%1</b> µs")).arg(m_actuatorSettings[currentChannel].channelNeutral));
477+
ui->motorPWMValue->setText(tr("Output value : <b>%1</b> µs").arg(m_actuatorSettings[currentChannel].channelNeutral));
478478
}
479479
// Reversable motor found
480480
if (m_actuatorSettings[currentChannel].isReversableMotor) {
@@ -788,10 +788,10 @@ bool OutputCalibrationPage::checkAlarms()
788788

789789
if (data.Alarm[SystemAlarms::ALARM_ACTUATOR] != SystemAlarms::ALARM_OK) {
790790
QMessageBox mbox(this);
791-
mbox.setText(QString(tr("The actuator module is in an error state.\n\n"
792-
"Please make sure the correct firmware version is used then "
793-
"restart the wizard and try again. If the problem persists please "
794-
"consult the librepilot.org support forum.")));
791+
mbox.setText(tr("The actuator module is in an error state.\n\n"
792+
"Please make sure the correct firmware version is used then "
793+
"restart the wizard and try again. If the problem persists please "
794+
"consult the librepilot.org support forum."));
795795
mbox.setStandardButtons(QMessageBox::Ok);
796796
mbox.setIcon(QMessageBox::Critical);
797797

@@ -829,24 +829,22 @@ int OutputCalibrationPage::getLowOutputRate()
829829
getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT600 ||
830830
getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT1200) {
831831
return LOW_OUTPUT_RATE_DSHOT;
832-
} else {
833-
return LOW_OUTPUT_RATE_MILLISECONDS_PWM;
834832
}
833+
return LOW_OUTPUT_RATE_PWM_MS;
835834
}
836835

837836
int OutputCalibrationPage::getHighOutputRate()
838837
{
839838
if (getWizard()->getEscType() == VehicleConfigurationSource::ESC_ONESHOT125 ||
840839
getWizard()->getEscType() == VehicleConfigurationSource::ESC_ONESHOT42 ||
841840
getWizard()->getEscType() == VehicleConfigurationSource::ESC_MULTISHOT) {
842-
return HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT_MULTISHOT;
841+
return HIGH_OUTPUT_RATE_ONESHOT_MULTISHOT_MS;
843842
} else if (getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT150 ||
844843
getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT600 ||
845844
getWizard()->getEscType() == VehicleConfigurationSource::ESC_DSHOT1200) {
846845
return HIGH_OUTPUT_RATE_DSHOT;
847-
} else {
848-
return HIGH_OUTPUT_RATE_MILLISECONDS_PWM;
849846
}
847+
return HIGH_OUTPUT_RATE_PWM_MS;
850848
}
851849

852850
void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value)
@@ -855,9 +853,9 @@ void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value)
855853

856854
if (ui->motorNeutralSlider->minimum() == LOW_OUTPUT_RATE_DSHOT) {
857855
// DShot output
858-
ui->motorPWMValue->setText(QString(tr("Digital output value : <b>%1</b>")).arg(value));
856+
ui->motorPWMValue->setText(tr("Digital output value : <b>%1</b>").arg(value));
859857
} else {
860-
ui->motorPWMValue->setText(QString(tr("Output value : <b>%1</b> µs")).arg(value));
858+
ui->motorPWMValue->setText(tr("Output value : <b>%1</b> µs").arg(value));
861859
}
862860
if (ui->motorNeutralButton->isChecked()) {
863861
quint16 value = ui->motorNeutralSlider->value();

ground/gcs/src/plugins/setupwizard/pages/outputcalibrationpage.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ private slots:
8787

8888
private:
8989
enum ElementType { FULL, FRAME, MOTOR, SERVO };
90-
static const int LOW_OUTPUT_RATE_DSHOT = 0;
91-
static const int HIGH_OUTPUT_RATE_DSHOT = 2000;
92-
static const int LOW_OUTPUT_RATE_MILLISECONDS = 1000;
93-
static const int LOW_OUTPUT_RATE_MILLISECONDS_PWM = 1000;
94-
static const int HIGH_OUTPUT_RATE_MILLISECONDS_PWM = 1900;
90+
static const int LOW_OUTPUT_RATE_DSHOT = 0;
91+
static const int HIGH_OUTPUT_RATE_DSHOT = 2000;
92+
static const int LOW_OUTPUT_RATE_MS = 1000;
93+
static const int LOW_OUTPUT_RATE_PWM_MS = 1000;
94+
static const int HIGH_OUTPUT_RATE_PWM_MS = 1900;
9595
static const int NEUTRAL_OUTPUT_RATE_RANGE = 500;
96-
static const int NEUTRAL_OUTPUT_RATE_MILLISECONDS = 1500;
97-
static const int HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT_MULTISHOT = 2000;
96+
static const int NEUTRAL_OUTPUT_RATE_MS = 1500;
97+
static const int HIGH_OUTPUT_RATE_ONESHOT_MULTISHOT_MS = 2000;
9898

9999
void setupVehicle();
100100
void startWizard();

0 commit comments

Comments
 (0)