mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
OP-1747 Updated code in SetupWizard to use different max rate outputs for pwm and OneShot125.
This commit is contained in:
parent
d77c317e37
commit
d4c562eb11
@ -85,6 +85,15 @@ void EscCalibrationPage::resetAllSecurityCheckboxes()
|
||||
ui->securityCheckBox3->setChecked(false);
|
||||
}
|
||||
|
||||
int EscCalibrationPage::getHighOutputRate()
|
||||
{
|
||||
if (getWizard()->getEscType() == SetupWizard::ESC_ONESHOT) {
|
||||
return HIGH_ONESHOT125_OUTPUT_PULSE_LENGTH_MICROSECONDS;
|
||||
} else {
|
||||
return HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS;
|
||||
}
|
||||
}
|
||||
|
||||
void EscCalibrationPage::startButtonClicked()
|
||||
{
|
||||
if (!m_isCalibrating) {
|
||||
@ -95,7 +104,7 @@ void EscCalibrationPage::startButtonClicked()
|
||||
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));
|
||||
ui->outputLevel->setText(QString(tr("%1 µs")).arg(getHighOutputRate()));
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *uavoManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(uavoManager);
|
||||
@ -123,7 +132,7 @@ void EscCalibrationPage::startButtonClicked()
|
||||
}
|
||||
m_outputUtil.startChannelOutput(m_outputChannels, OFF_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS);
|
||||
QThread::msleep(100);
|
||||
m_outputUtil.setChannelOutputValue(HIGH_PWM_OUTPUT_PULSE_LENGTH_MICROSECONDS);
|
||||
m_outputUtil.setChannelOutputValue(getHighOutputRate());
|
||||
|
||||
ui->stopButton->setEnabled(true);
|
||||
}
|
||||
|
@ -56,10 +56,12 @@ private:
|
||||
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;
|
||||
static const int HIGH_ONESHOT125_OUTPUT_PULSE_LENGTH_MICROSECONDS = 2000;
|
||||
Ui::EscCalibrationPage *ui;
|
||||
bool m_isCalibrating;
|
||||
OutputCalibrationUtil m_outputUtil;
|
||||
QList<quint16> m_outputChannels;
|
||||
int getHighOutputRate();
|
||||
};
|
||||
|
||||
#endif // ESCCALIBRATIONPAGE_H
|
||||
|
@ -77,32 +77,32 @@ void OutputCalibrationPage::setupActuatorMinMaxAndNeutral(int motorChannelStart,
|
||||
for (int servoid = 0; servoid < 12; servoid++) {
|
||||
if (servoid >= motorChannelStart && servoid <= motorChannelEnd) {
|
||||
// Set to motor safe values
|
||||
m_actuatorSettings[servoid].channelMin = 1000;
|
||||
m_actuatorSettings[servoid].channelNeutral = 1000;
|
||||
m_actuatorSettings[servoid].channelMax = 1900;
|
||||
m_actuatorSettings[servoid].channelMin = LOW_OUTPUT_RATE_MILLISECONDS;
|
||||
m_actuatorSettings[servoid].channelNeutral = LOW_OUTPUT_RATE_MILLISECONDS;
|
||||
m_actuatorSettings[servoid].channelMax = getHighOutputRate();
|
||||
m_actuatorSettings[servoid].isReversableMotor = false;
|
||||
// Car and Tank should use reversable Esc/motors
|
||||
if ((getWizard()->getVehicleSubType() == SetupWizard::GROUNDVEHICLE_CAR)
|
||||
|| (getWizard()->getVehicleSubType() == SetupWizard::GROUNDVEHICLE_DIFFERENTIAL)) {
|
||||
m_actuatorSettings[servoid].channelNeutral = 1500;
|
||||
m_actuatorSettings[servoid].channelNeutral = NEUTRAL_OUTPUT_RATE_MILLISECONDS;
|
||||
m_actuatorSettings[servoid].isReversableMotor = true;
|
||||
// Set initial output value
|
||||
m_calibrationUtil->startChannelOutput(servoid, 1500);
|
||||
m_calibrationUtil->startChannelOutput(servoid, NEUTRAL_OUTPUT_RATE_MILLISECONDS);
|
||||
m_calibrationUtil->stopChannelOutput();
|
||||
}
|
||||
} else if (servoid < totalUsedChannels) {
|
||||
// Set to servo safe values
|
||||
m_actuatorSettings[servoid].channelMin = 1500;
|
||||
m_actuatorSettings[servoid].channelNeutral = 1500;
|
||||
m_actuatorSettings[servoid].channelMax = 1500;
|
||||
m_actuatorSettings[servoid].channelMin = NEUTRAL_OUTPUT_RATE_MILLISECONDS;
|
||||
m_actuatorSettings[servoid].channelNeutral = NEUTRAL_OUTPUT_RATE_MILLISECONDS;
|
||||
m_actuatorSettings[servoid].channelMax = NEUTRAL_OUTPUT_RATE_MILLISECONDS;
|
||||
// Set initial servo output value
|
||||
m_calibrationUtil->startChannelOutput(servoid, 1500);
|
||||
m_calibrationUtil->startChannelOutput(servoid, NEUTRAL_OUTPUT_RATE_MILLISECONDS);
|
||||
m_calibrationUtil->stopChannelOutput();
|
||||
} else {
|
||||
// "Disable" these channels
|
||||
m_actuatorSettings[servoid].channelMin = 1000;
|
||||
m_actuatorSettings[servoid].channelNeutral = 1000;
|
||||
m_actuatorSettings[servoid].channelMax = 1000;
|
||||
m_actuatorSettings[servoid].channelMin = LOW_OUTPUT_RATE_MILLISECONDS;
|
||||
m_actuatorSettings[servoid].channelNeutral = LOW_OUTPUT_RATE_MILLISECONDS;
|
||||
m_actuatorSettings[servoid].channelMax = LOW_OUTPUT_RATE_MILLISECONDS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -521,6 +521,15 @@ void OutputCalibrationPage::debugLogChannelValues()
|
||||
qDebug() << "ChannelMax : " << m_actuatorSettings[channel].channelMax;
|
||||
}
|
||||
|
||||
int OutputCalibrationPage::getHighOutputRate()
|
||||
{
|
||||
if (getWizard()->getEscType() == SetupWizard::ESC_ONESHOT) {
|
||||
return HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT125;
|
||||
} else {
|
||||
return HIGH_OUTPUT_RATE_MILLISECONDS_PWM;
|
||||
}
|
||||
}
|
||||
|
||||
void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value)
|
||||
{
|
||||
Q_UNUSED(value);
|
||||
|
@ -72,6 +72,10 @@ private slots:
|
||||
void on_reverseCheckbox_toggled(bool checked);
|
||||
|
||||
private:
|
||||
static const int LOW_OUTPUT_RATE_MILLISECONDS = 1000;
|
||||
static const int NEUTRAL_OUTPUT_RATE_MILLISECONDS = 1500;
|
||||
static const int HIGH_OUTPUT_RATE_MILLISECONDS_PWM = 1900;
|
||||
static const int HIGH_OUTPUT_RATE_MILLISECONDS_ONESHOT125 = 2000;
|
||||
void setupVehicle();
|
||||
void startWizard();
|
||||
void setupVehicleItems();
|
||||
@ -82,6 +86,7 @@ private:
|
||||
void onStartButtonToggle(QAbstractButton *button, quint16 channel, quint16 value, quint16 safeValue, QSlider *slider);
|
||||
bool checkAlarms();
|
||||
void debugLogChannelValues();
|
||||
int getHighOutputRate();
|
||||
quint16 getCurrentChannel();
|
||||
|
||||
Ui::OutputCalibrationPage *ui;
|
||||
|
Loading…
x
Reference in New Issue
Block a user