mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
LP-551 Set default values in Output tab when user changes BankMode - Add warning for Bankmode mismatch (servo/motor)
This commit is contained in:
parent
4c9c3c202c
commit
b508e07845
@ -51,8 +51,21 @@
|
|||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#define MAXOUTPUT_VALUE 2500
|
// Motor settings
|
||||||
#define MINOUTPUT_VALUE 500
|
#define DSHOT_MAXOUTPUT_RANGE 2000
|
||||||
|
#define DSHOT_MINTOUTPUT_RANGE 0
|
||||||
|
#define PWMSYNC_MAXOUTPUT_RANGE 1900
|
||||||
|
#define DEFAULT_MAXOUTPUT_RANGE 2000
|
||||||
|
#define DEFAULT_MINOUTPUT_RANGE 900
|
||||||
|
|
||||||
|
#define DEFAULT_MINOUTPUT_VALUE 1000
|
||||||
|
|
||||||
|
// Servo settings
|
||||||
|
#define SERVO_MAXOUTPUT_RANGE 2500
|
||||||
|
#define SERVO_MINOUTPUT_RANGE 500
|
||||||
|
#define SERVO_MAXOUTPUT_VALUE 2000
|
||||||
|
#define SERVO_MINOUTPUT_VALUE 1000
|
||||||
|
#define SERVO_NEUTRAL_VALUE 1500
|
||||||
|
|
||||||
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||||
{
|
{
|
||||||
@ -506,15 +519,62 @@ void ConfigOutputWidget::updateAlwaysStabilizeStatus()
|
|||||||
|
|
||||||
void ConfigOutputWidget::setChannelLimits(OutputChannelForm *channelForm, OutputBankControls *bankControls)
|
void ConfigOutputWidget::setChannelLimits(OutputChannelForm *channelForm, OutputBankControls *bankControls)
|
||||||
{
|
{
|
||||||
|
// Set UI limits according to the bankmode and destination
|
||||||
switch (bankControls->modeCombo()->currentIndex()) {
|
switch (bankControls->modeCombo()->currentIndex()) {
|
||||||
case ActuatorSettings::BANKMODE_DSHOT:
|
case ActuatorSettings::BANKMODE_DSHOT:
|
||||||
channelForm->setLimits(0, 0, 0, 2000);
|
// 0 - 2000 UI limits, DShot min value is fixed to zero
|
||||||
|
if (channelForm->isServoOutput()) {
|
||||||
|
bank_mode_servo_warning = "DShot";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
channelForm->setLimits(DSHOT_MINTOUTPUT_RANGE, DSHOT_MINTOUTPUT_RANGE, DSHOT_MINTOUTPUT_RANGE, DSHOT_MAXOUTPUT_RANGE);
|
||||||
|
channelForm->setRange(DSHOT_MINTOUTPUT_RANGE, DSHOT_MAXOUTPUT_RANGE);
|
||||||
|
channelForm->setNeutral(DSHOT_MINTOUTPUT_RANGE);
|
||||||
break;
|
break;
|
||||||
// case ActuatorSettings::BANKMODE_BRUSHED:
|
case ActuatorSettings::BANKMODE_PWMSYNC:
|
||||||
// channelForm->setLimits(0, 0, 0, 100); // 0 to 100%
|
// 900 - 1900 UI limits
|
||||||
// break;
|
// Default values 1000 - 1900
|
||||||
|
channelForm->setLimits(DEFAULT_MINOUTPUT_RANGE, PWMSYNC_MAXOUTPUT_RANGE, DEFAULT_MINOUTPUT_RANGE, PWMSYNC_MAXOUTPUT_RANGE);
|
||||||
|
channelForm->setRange(DEFAULT_MINOUTPUT_VALUE, PWMSYNC_MAXOUTPUT_RANGE);
|
||||||
|
channelForm->setNeutral(DEFAULT_MINOUTPUT_VALUE);
|
||||||
|
if (channelForm->isServoOutput()) {
|
||||||
|
// Servo: Some of them can handle PWMSync, 500 - 1900 UI limits
|
||||||
|
// Default values 1000 - 1900 + neutral 1500
|
||||||
|
channelForm->setRange(SERVO_MINOUTPUT_VALUE, PWMSYNC_MAXOUTPUT_RANGE);
|
||||||
|
channelForm->setNeutral(SERVO_NEUTRAL_VALUE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ActuatorSettings::BANKMODE_PWM:
|
||||||
|
// PWM motor outputs fall to default
|
||||||
|
if (channelForm->isServoOutput()) {
|
||||||
|
// Servo: 500 - 2500 UI limits
|
||||||
|
// Default values 1000 - 2000 + neutral 1500
|
||||||
|
channelForm->setLimits(SERVO_MINOUTPUT_RANGE, SERVO_MAXOUTPUT_RANGE, SERVO_MINOUTPUT_RANGE, SERVO_MAXOUTPUT_RANGE);
|
||||||
|
channelForm->setRange(SERVO_MINOUTPUT_VALUE, SERVO_MAXOUTPUT_VALUE);
|
||||||
|
channelForm->setNeutral(SERVO_NEUTRAL_VALUE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ActuatorSettings::BANKMODE_ONESHOT125:
|
||||||
|
if (channelForm->isServoOutput()) {
|
||||||
|
bank_mode_servo_warning = "OneShot125";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ActuatorSettings::BANKMODE_ONESHOT42:
|
||||||
|
if (channelForm->isServoOutput()) {
|
||||||
|
bank_mode_servo_warning = "OneShot42";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ActuatorSettings::BANKMODE_MULTISHOT:
|
||||||
|
if (channelForm->isServoOutput()) {
|
||||||
|
bank_mode_servo_warning = "MultiShot";
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
channelForm->setLimits(MINOUTPUT_VALUE, MAXOUTPUT_VALUE, MINOUTPUT_VALUE, MAXOUTPUT_VALUE);
|
// Motors 900 - 2000 UI limits
|
||||||
|
// Default values 1000 - 2000, neutral set to min
|
||||||
|
channelForm->setLimits(DEFAULT_MINOUTPUT_RANGE, DEFAULT_MAXOUTPUT_RANGE, DEFAULT_MINOUTPUT_RANGE, DEFAULT_MAXOUTPUT_RANGE);
|
||||||
|
channelForm->setRange(DEFAULT_MINOUTPUT_VALUE, DEFAULT_MAXOUTPUT_RANGE);
|
||||||
|
channelForm->setNeutral(DEFAULT_MINOUTPUT_VALUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,6 +583,8 @@ void ConfigOutputWidget::onBankTypeChange()
|
|||||||
{
|
{
|
||||||
QComboBox *bankModeCombo = qobject_cast<QComboBox *>(sender());
|
QComboBox *bankModeCombo = qobject_cast<QComboBox *>(sender());
|
||||||
|
|
||||||
|
bank_mode_servo_warning = "";
|
||||||
|
|
||||||
if (bankModeCombo != NULL) {
|
if (bankModeCombo != NULL) {
|
||||||
int bankNumber = 1;
|
int bankNumber = 1;
|
||||||
QList<OutputChannelForm *> outputChannelForms = findChildren<OutputChannelForm *>();
|
QList<OutputChannelForm *> outputChannelForms = findChildren<OutputChannelForm *>();
|
||||||
@ -564,6 +626,12 @@ void ConfigOutputWidget::updateWarnings(UAVObject *)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (bank_mode_servo_warning != "") {
|
||||||
|
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);
|
||||||
|
setWarning(servo_warning_str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setWarning(NULL);
|
setWarning(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +98,7 @@ private:
|
|||||||
int m_mccDataRate;
|
int m_mccDataRate;
|
||||||
UAVObject::Metadata m_accInitialData;
|
UAVObject::Metadata m_accInitialData;
|
||||||
QList<OutputBankControls> m_banks;
|
QList<OutputBankControls> m_banks;
|
||||||
|
QString bank_mode_servo_warning;
|
||||||
|
|
||||||
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);
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "outputchannelform.h"
|
#include "outputchannelform.h"
|
||||||
|
|
||||||
#include "ui_outputchannelform.h"
|
#include "ui_outputchannelform.h"
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
OutputChannelForm::OutputChannelForm(const int index, QWidget *parent) :
|
OutputChannelForm::OutputChannelForm(const int index, QWidget *parent) :
|
||||||
ChannelForm(index, parent), ui(new Ui::outputChannelForm), m_inChannelTest(false)
|
ChannelForm(index, parent), ui(new Ui::outputChannelForm), m_inChannelTest(false)
|
||||||
@ -113,7 +114,7 @@ void OutputChannelForm::enableChannelTest(bool state)
|
|||||||
} else if (m_mixerType != "Disabled") {
|
} else if (m_mixerType != "Disabled") {
|
||||||
ui->actuatorMin->setEnabled(true);
|
ui->actuatorMin->setEnabled(true);
|
||||||
ui->actuatorMax->setEnabled(true);
|
ui->actuatorMax->setEnabled(true);
|
||||||
if (m_mixerType != "Motor") {
|
if (!isNormalMotor()) {
|
||||||
ui->actuatorRev->setEnabled(true);
|
ui->actuatorRev->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,6 +213,9 @@ void OutputChannelForm::setLimits(int actuatorMinMinimum, int actuatorMinMaximum
|
|||||||
ui->actuatorMax->setMaximum(actuatorMaxMaximum);
|
ui->actuatorMax->setMaximum(actuatorMaxMaximum);
|
||||||
ui->actuatorMin->setMinimum(actuatorMinMinimum);
|
ui->actuatorMin->setMinimum(actuatorMinMinimum);
|
||||||
ui->actuatorMax->setMinimum(actuatorMaxMinimum);
|
ui->actuatorMax->setMinimum(actuatorMaxMinimum);
|
||||||
|
// Neutral slider limits
|
||||||
|
ui->actuatorNeutral->setMinimum(actuatorMinMinimum);
|
||||||
|
ui->actuatorNeutral->setMaximum(actuatorMaxMaximum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -233,16 +237,35 @@ void OutputChannelForm::setRange(int minimum, int maximum)
|
|||||||
*/
|
*/
|
||||||
void OutputChannelForm::setChannelRange()
|
void OutputChannelForm::setChannelRange()
|
||||||
{
|
{
|
||||||
|
// Disable outputs not already set in MixerSettings
|
||||||
|
if (isDisabledOutput()) {
|
||||||
|
setLimits(1000, 1000, 1000, 1000);
|
||||||
|
ui->actuatorMin->setValue(1000);
|
||||||
|
ui->actuatorMax->setValue(1000);
|
||||||
|
ui->actuatorMin->setEnabled(false);
|
||||||
|
ui->actuatorMax->setEnabled(false);
|
||||||
|
ui->actuatorRev->setEnabled(false);
|
||||||
|
ui->actuatorLink->setEnabled(false);
|
||||||
|
ui->actuatorValue->setEnabled(false);
|
||||||
|
ui->actuatorRev->setChecked(false);
|
||||||
|
ui->actuatorLink->setChecked(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->actuatorMin->setEnabled(true);
|
||||||
|
ui->actuatorMax->setEnabled(true);
|
||||||
|
ui->actuatorNeutral->setEnabled(true);
|
||||||
|
ui->actuatorValue->setEnabled(true);
|
||||||
|
ui->actuatorLink->setEnabled(true);
|
||||||
|
|
||||||
int minValue = ui->actuatorMin->value();
|
int minValue = ui->actuatorMin->value();
|
||||||
int maxValue = ui->actuatorMax->value();
|
int maxValue = ui->actuatorMax->value();
|
||||||
|
|
||||||
int oldMini = ui->actuatorNeutral->minimum();
|
int oldMini = ui->actuatorNeutral->minimum();
|
||||||
int oldMaxi = ui->actuatorNeutral->maximum();
|
int oldMaxi = ui->actuatorNeutral->maximum();
|
||||||
|
|
||||||
m_mixerType = outputMixerType();
|
|
||||||
|
|
||||||
// Red handle for Motors
|
// Red handle for Motors
|
||||||
if ((m_mixerType == "Motor") || (m_mixerType == "ReversableMotor")) {
|
if (isNormalMotor() || isReversableMotor()) {
|
||||||
ui->actuatorNeutral->setStyleSheet("QSlider::handle:horizontal { background: rgb(255, 100, 100); width: 18px; height: 28px;"
|
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; }");
|
"margin: -3px 0; border-radius: 3px; border: 1px solid #777; }");
|
||||||
} else {
|
} else {
|
||||||
@ -251,7 +274,7 @@ void OutputChannelForm::setChannelRange()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normal motor will be *** never *** reversed : without arming a "Min" value (like 1900) can be applied !
|
// Normal motor will be *** never *** reversed : without arming a "Min" value (like 1900) can be applied !
|
||||||
if (m_mixerType == "Motor") {
|
if (isNormalMotor()) {
|
||||||
if (minValue >= maxValue) {
|
if (minValue >= maxValue) {
|
||||||
// Keep old values
|
// Keep old values
|
||||||
ui->actuatorMin->setValue(oldMini);
|
ui->actuatorMin->setValue(oldMini);
|
||||||
@ -279,25 +302,6 @@ void OutputChannelForm::setChannelRange()
|
|||||||
if (ui->actuatorNeutral->value() == oldMini) {
|
if (ui->actuatorNeutral->value() == oldMini) {
|
||||||
ui->actuatorNeutral->setValue(ui->actuatorNeutral->minimum());
|
ui->actuatorNeutral->setValue(ui->actuatorNeutral->minimum());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable only outputs already set in mixer
|
|
||||||
if (m_mixerType != "Disabled") {
|
|
||||||
ui->actuatorMin->setEnabled(true);
|
|
||||||
ui->actuatorMax->setEnabled(true);
|
|
||||||
ui->actuatorNeutral->setEnabled(true);
|
|
||||||
ui->actuatorValue->setEnabled(true);
|
|
||||||
ui->actuatorLink->setEnabled(true);
|
|
||||||
} else {
|
|
||||||
ui->actuatorMin->setEnabled(false);
|
|
||||||
ui->actuatorMax->setEnabled(false);
|
|
||||||
ui->actuatorRev->setEnabled(false);
|
|
||||||
ui->actuatorLink->setEnabled(false);
|
|
||||||
ui->actuatorMin->setValue(1000);
|
|
||||||
ui->actuatorMax->setValue(1000);
|
|
||||||
ui->actuatorNeutral->setRange(minValue, maxValue);
|
|
||||||
ui->actuatorNeutral->setValue(minValue);
|
|
||||||
ui->actuatorValue->setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -389,3 +393,39 @@ QString OutputChannelForm::outputMixerType()
|
|||||||
|
|
||||||
return mixerType;
|
return mixerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Returns true if a servo output
|
||||||
|
*/
|
||||||
|
bool OutputChannelForm::isServoOutput()
|
||||||
|
{
|
||||||
|
return !isNormalMotor() && !isReversableMotor() && !isDisabledOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Returns true if output is a normal Motor
|
||||||
|
*/
|
||||||
|
bool OutputChannelForm::isNormalMotor()
|
||||||
|
{
|
||||||
|
return outputMixerType() == "Motor";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Returns true if output is a reversable Motor
|
||||||
|
*/
|
||||||
|
bool OutputChannelForm::isReversableMotor()
|
||||||
|
{
|
||||||
|
return outputMixerType() == "ReversableMotor";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Returns true if output is disabled
|
||||||
|
*/
|
||||||
|
bool OutputChannelForm::isDisabledOutput()
|
||||||
|
{
|
||||||
|
return outputMixerType() == "Disabled";
|
||||||
|
}
|
||||||
|
@ -63,6 +63,10 @@ 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);
|
||||||
|
bool isServoOutput();
|
||||||
|
bool isNormalMotor();
|
||||||
|
bool isReversableMotor();
|
||||||
|
bool isDisabledOutput();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void channelChanged(int index, int value);
|
void channelChanged(int index, int value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user