mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
LP-551 Add warning for neutral setting with reversable motors
This commit is contained in:
parent
b508e07845
commit
893264273f
@ -52,20 +52,21 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
// Motor settings
|
// Motor settings
|
||||||
#define DSHOT_MAXOUTPUT_RANGE 2000
|
#define DSHOT_MAXOUTPUT_RANGE 2000
|
||||||
#define DSHOT_MINTOUTPUT_RANGE 0
|
#define DSHOT_MINTOUTPUT_RANGE 0
|
||||||
#define PWMSYNC_MAXOUTPUT_RANGE 1900
|
#define PWMSYNC_MAXOUTPUT_RANGE 1900
|
||||||
#define DEFAULT_MAXOUTPUT_RANGE 2000
|
#define DEFAULT_MAXOUTPUT_RANGE 2000
|
||||||
#define DEFAULT_MINOUTPUT_RANGE 900
|
#define DEFAULT_MINOUTPUT_RANGE 900
|
||||||
|
#define DEFAULT_MINOUTPUT_VALUE 1000
|
||||||
#define DEFAULT_MINOUTPUT_VALUE 1000
|
#define REVMOTOR_NEUTRAL_TARGET_VALUE 1500
|
||||||
|
#define REVMOTOR_NEUTRAL_DIFF_VALUE 250
|
||||||
|
|
||||||
// Servo settings
|
// Servo settings
|
||||||
#define SERVO_MAXOUTPUT_RANGE 2500
|
#define SERVO_MAXOUTPUT_RANGE 2500
|
||||||
#define SERVO_MINOUTPUT_RANGE 500
|
#define SERVO_MINOUTPUT_RANGE 500
|
||||||
#define SERVO_MAXOUTPUT_VALUE 2000
|
#define SERVO_MAXOUTPUT_VALUE 2000
|
||||||
#define SERVO_MINOUTPUT_VALUE 1000
|
#define SERVO_MINOUTPUT_VALUE 1000
|
||||||
#define SERVO_NEUTRAL_VALUE 1500
|
#define SERVO_NEUTRAL_VALUE 1500
|
||||||
|
|
||||||
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||||
{
|
{
|
||||||
@ -527,6 +528,9 @@ void ConfigOutputWidget::setChannelLimits(OutputChannelForm *channelForm, Output
|
|||||||
bank_mode_servo_warning = "DShot";
|
bank_mode_servo_warning = "DShot";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (channelForm->isReversableMotor()) {
|
||||||
|
reversable_motor_warning = "DShot";
|
||||||
|
}
|
||||||
channelForm->setLimits(DSHOT_MINTOUTPUT_RANGE, DSHOT_MINTOUTPUT_RANGE, DSHOT_MINTOUTPUT_RANGE, DSHOT_MAXOUTPUT_RANGE);
|
channelForm->setLimits(DSHOT_MINTOUTPUT_RANGE, DSHOT_MINTOUTPUT_RANGE, DSHOT_MINTOUTPUT_RANGE, DSHOT_MAXOUTPUT_RANGE);
|
||||||
channelForm->setRange(DSHOT_MINTOUTPUT_RANGE, DSHOT_MAXOUTPUT_RANGE);
|
channelForm->setRange(DSHOT_MINTOUTPUT_RANGE, DSHOT_MAXOUTPUT_RANGE);
|
||||||
channelForm->setNeutral(DSHOT_MINTOUTPUT_RANGE);
|
channelForm->setNeutral(DSHOT_MINTOUTPUT_RANGE);
|
||||||
@ -534,9 +538,13 @@ void ConfigOutputWidget::setChannelLimits(OutputChannelForm *channelForm, Output
|
|||||||
case ActuatorSettings::BANKMODE_PWMSYNC:
|
case ActuatorSettings::BANKMODE_PWMSYNC:
|
||||||
// 900 - 1900 UI limits
|
// 900 - 1900 UI limits
|
||||||
// Default values 1000 - 1900
|
// Default values 1000 - 1900
|
||||||
|
currentNeutralValue = channelForm->getNeutralValue();
|
||||||
channelForm->setLimits(DEFAULT_MINOUTPUT_RANGE, PWMSYNC_MAXOUTPUT_RANGE, DEFAULT_MINOUTPUT_RANGE, PWMSYNC_MAXOUTPUT_RANGE);
|
channelForm->setLimits(DEFAULT_MINOUTPUT_RANGE, PWMSYNC_MAXOUTPUT_RANGE, DEFAULT_MINOUTPUT_RANGE, PWMSYNC_MAXOUTPUT_RANGE);
|
||||||
channelForm->setRange(DEFAULT_MINOUTPUT_VALUE, PWMSYNC_MAXOUTPUT_RANGE);
|
channelForm->setRange(DEFAULT_MINOUTPUT_VALUE, PWMSYNC_MAXOUTPUT_RANGE);
|
||||||
channelForm->setNeutral(DEFAULT_MINOUTPUT_VALUE);
|
channelForm->setNeutral(DEFAULT_MINOUTPUT_VALUE);
|
||||||
|
if (channelForm->isReversableMotor() && (reversable_motor_warning == "")) {
|
||||||
|
reversable_motor_warning = "PWMSync";
|
||||||
|
}
|
||||||
if (channelForm->isServoOutput()) {
|
if (channelForm->isServoOutput()) {
|
||||||
// Servo: Some of them can handle PWMSync, 500 - 1900 UI limits
|
// Servo: Some of them can handle PWMSync, 500 - 1900 UI limits
|
||||||
// Default values 1000 - 1900 + neutral 1500
|
// Default values 1000 - 1900 + neutral 1500
|
||||||
@ -546,6 +554,9 @@ void ConfigOutputWidget::setChannelLimits(OutputChannelForm *channelForm, Output
|
|||||||
break;
|
break;
|
||||||
case ActuatorSettings::BANKMODE_PWM:
|
case ActuatorSettings::BANKMODE_PWM:
|
||||||
// PWM motor outputs fall to default
|
// PWM motor outputs fall to default
|
||||||
|
if (channelForm->isReversableMotor() && (reversable_motor_warning == "")) {
|
||||||
|
reversable_motor_warning = "PWM";
|
||||||
|
}
|
||||||
if (channelForm->isServoOutput()) {
|
if (channelForm->isServoOutput()) {
|
||||||
// Servo: 500 - 2500 UI limits
|
// Servo: 500 - 2500 UI limits
|
||||||
// Default values 1000 - 2000 + neutral 1500
|
// Default values 1000 - 2000 + neutral 1500
|
||||||
@ -559,31 +570,51 @@ void ConfigOutputWidget::setChannelLimits(OutputChannelForm *channelForm, Output
|
|||||||
bank_mode_servo_warning = "OneShot125";
|
bank_mode_servo_warning = "OneShot125";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (channelForm->isReversableMotor() && (reversable_motor_warning == "")) {
|
||||||
|
reversable_motor_warning = "OneShot125";
|
||||||
|
}
|
||||||
case ActuatorSettings::BANKMODE_ONESHOT42:
|
case ActuatorSettings::BANKMODE_ONESHOT42:
|
||||||
if (channelForm->isServoOutput()) {
|
if (channelForm->isServoOutput()) {
|
||||||
bank_mode_servo_warning = "OneShot42";
|
bank_mode_servo_warning = "OneShot42";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (channelForm->isReversableMotor() && (reversable_motor_warning == "")) {
|
||||||
|
reversable_motor_warning = "OneShot42";
|
||||||
|
}
|
||||||
case ActuatorSettings::BANKMODE_MULTISHOT:
|
case ActuatorSettings::BANKMODE_MULTISHOT:
|
||||||
if (channelForm->isServoOutput()) {
|
if (channelForm->isServoOutput()) {
|
||||||
bank_mode_servo_warning = "MultiShot";
|
bank_mode_servo_warning = "MultiShot";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (channelForm->isReversableMotor() && (reversable_motor_warning == "")) {
|
||||||
|
reversable_motor_warning = "MultiShot";
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// Motors 900 - 2000 UI limits
|
// Motors 900 - 2000 UI limits
|
||||||
// Default values 1000 - 2000, neutral set to min
|
// Default values 1000 - 2000, neutral set to min
|
||||||
|
currentNeutralValue = channelForm->getNeutralValue();
|
||||||
channelForm->setLimits(DEFAULT_MINOUTPUT_RANGE, DEFAULT_MAXOUTPUT_RANGE, DEFAULT_MINOUTPUT_RANGE, DEFAULT_MAXOUTPUT_RANGE);
|
channelForm->setLimits(DEFAULT_MINOUTPUT_RANGE, DEFAULT_MAXOUTPUT_RANGE, DEFAULT_MINOUTPUT_RANGE, DEFAULT_MAXOUTPUT_RANGE);
|
||||||
channelForm->setRange(DEFAULT_MINOUTPUT_VALUE, DEFAULT_MAXOUTPUT_RANGE);
|
channelForm->setRange(DEFAULT_MINOUTPUT_VALUE, DEFAULT_MAXOUTPUT_RANGE);
|
||||||
channelForm->setNeutral(DEFAULT_MINOUTPUT_VALUE);
|
channelForm->setNeutral(DEFAULT_MINOUTPUT_VALUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Implement bi-directional DShot
|
||||||
|
if (channelForm->isReversableMotor() && (bankControls->modeCombo()->currentIndex() != ActuatorSettings::BANKMODE_DSHOT)) {
|
||||||
|
int neutralDiff = qAbs(REVMOTOR_NEUTRAL_TARGET_VALUE - currentNeutralValue);
|
||||||
|
if (neutralDiff < REVMOTOR_NEUTRAL_DIFF_VALUE) {
|
||||||
|
// Reset warning
|
||||||
|
reversable_motor_warning = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigOutputWidget::onBankTypeChange()
|
void ConfigOutputWidget::onBankTypeChange()
|
||||||
{
|
{
|
||||||
QComboBox *bankModeCombo = qobject_cast<QComboBox *>(sender());
|
QComboBox *bankModeCombo = qobject_cast<QComboBox *>(sender());
|
||||||
|
|
||||||
bank_mode_servo_warning = "";
|
bank_mode_servo_warning = "";
|
||||||
|
reversable_motor_warning = "";
|
||||||
|
|
||||||
if (bankModeCombo != NULL) {
|
if (bankModeCombo != NULL) {
|
||||||
int bankNumber = 1;
|
int bankNumber = 1;
|
||||||
@ -626,12 +657,28 @@ void ConfigOutputWidget::updateWarnings(UAVObject *)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reversable_motor_warning != "") {
|
||||||
|
QString revmotor_warning_str;
|
||||||
|
if (reversable_motor_warning == "DShot") {
|
||||||
|
// TODO: Implement bi-directional DShot
|
||||||
|
revmotor_warning_str = "There is at least one reversable motor using <b>DShot</b> in your configuration."
|
||||||
|
"<p>Bi-directional DShot is not currently supported, you should use PWM, OneShotXXX or MultiShot.</p>";
|
||||||
|
} else {
|
||||||
|
revmotor_warning_str = QString("There is at least one reversable motor using <b>%1</b> in your configuration.</b>"
|
||||||
|
"<p>Be sure you set the appropriate neutral value before saving and applying power to the vehicule.</p>").arg(reversable_motor_warning);
|
||||||
|
}
|
||||||
|
setWarning(revmotor_warning_str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (bank_mode_servo_warning != "") {
|
if (bank_mode_servo_warning != "") {
|
||||||
QString servo_warning_str = QString("Bank using <b>%1</b> cannot drive a <b>servo output!</b>"
|
QString servo_warning_str = QString("Bank using <b>%1</b> cannot drive a <b>servo output!</b>"
|
||||||
"<p>You must use PWM for this Bank or move the servo output to another compatible Bank.</p>").arg(bank_mode_servo_warning);
|
"<p>You must use PWM for this Bank or move the servo output to another compatible Bank.</p>").arg(bank_mode_servo_warning);
|
||||||
setWarning(servo_warning_str);
|
setWarning(servo_warning_str);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setWarning(NULL);
|
setWarning(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +99,8 @@ private:
|
|||||||
UAVObject::Metadata m_accInitialData;
|
UAVObject::Metadata m_accInitialData;
|
||||||
QList<OutputBankControls> m_banks;
|
QList<OutputBankControls> m_banks;
|
||||||
QString bank_mode_servo_warning;
|
QString bank_mode_servo_warning;
|
||||||
|
QString reversable_motor_warning;
|
||||||
|
int currentNeutralValue;
|
||||||
|
|
||||||
OutputChannelForm *getOutputChannelForm(const int index) const;
|
OutputChannelForm *getOutputChannelForm(const int index) const;
|
||||||
void updateChannelInSlider(QSlider *slider, QLabel *min, QLabel *max, QCheckBox *rev, int value);
|
void updateChannelInSlider(QSlider *slider, QLabel *min, QLabel *max, QCheckBox *rev, int value);
|
||||||
|
@ -376,6 +376,15 @@ void OutputChannelForm::sendChannelTest(int value)
|
|||||||
emit channelChanged(index(), value);
|
emit channelChanged(index(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Returns current neutral value
|
||||||
|
*/
|
||||||
|
int OutputChannelForm::getNeutralValue()
|
||||||
|
{
|
||||||
|
return ui->actuatorNeutral->value();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Returns MixerType
|
* Returns MixerType
|
||||||
|
@ -63,6 +63,7 @@ public slots:
|
|||||||
void enableChannelTest(bool state);
|
void enableChannelTest(bool state);
|
||||||
QString outputMixerType();
|
QString outputMixerType();
|
||||||
void setLimits(int actuatorMinMinimum, int actuatorMinMaximum, int actuatorMaxMinimum, int actuatorMaxMaximum);
|
void setLimits(int actuatorMinMinimum, int actuatorMinMaximum, int actuatorMaxMinimum, int actuatorMaxMaximum);
|
||||||
|
int getNeutralValue();
|
||||||
bool isServoOutput();
|
bool isServoOutput();
|
||||||
bool isNormalMotor();
|
bool isNormalMotor();
|
||||||
bool isReversableMotor();
|
bool isReversableMotor();
|
||||||
|
Loading…
Reference in New Issue
Block a user