1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

Merged in f5soh/librepilot/laurent/LP-65_Heli_tab_refresh (pull request #6)

LP-65 Heli tab : Custom values refreshed - Check unused/duplicate output channels
This commit is contained in:
alessio morale 2015-07-31 14:44:01 +02:00
commit 58602bebbe
4 changed files with 151 additions and 125 deletions

View File

@ -1050,7 +1050,7 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>200</width> <width>220</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -1098,13 +1098,13 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>85</width> <width>100</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>120</width>
<height>25</height> <height>25</height>
</size> </size>
</property> </property>
@ -1120,13 +1120,13 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>85</width> <width>100</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>120</width>
<height>25</height> <height>25</height>
</size> </size>
</property> </property>
@ -1195,7 +1195,7 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>200</width> <width>220</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -1265,13 +1265,13 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>85</width> <width>100</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>120</width>
<height>25</height> <height>25</height>
</size> </size>
</property> </property>
@ -1287,13 +1287,13 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>85</width> <width>100</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>120</width>
<height>25</height> <height>25</height>
</size> </size>
</property> </property>
@ -1312,13 +1312,13 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>85</width> <width>100</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>120</width>
<height>25</height> <height>25</height>
</size> </size>
</property> </property>
@ -1359,13 +1359,13 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>85</width> <width>100</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>120</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
@ -1426,13 +1426,13 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>85</width> <width>100</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>100</width> <width>120</width>
<height>25</height> <height>25</height>
</size> </size>
</property> </property>
@ -1504,7 +1504,7 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>200</width> <width>220</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -1844,7 +1844,7 @@ margin:1px;
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>200</width> <width>220</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>

View File

@ -3,6 +3,7 @@
* *
* @file configccpmwidget.cpp * @file configccpmwidget.cpp
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @addtogroup ConfigPlugin Config Plugin * @addtogroup ConfigPlugin Config Plugin
@ -254,7 +255,7 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) :
connect(m_aircraft->ccpmCollectivespinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); connect(m_aircraft->ccpmCollectivespinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer()));
connect(m_aircraft->ccpmType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType())); connect(m_aircraft->ccpmType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType()));
connect(m_aircraft->ccpmSingleServo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType())); connect(m_aircraft->ccpmSingleServo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType()));
connect(m_aircraft->TabObject, SIGNAL(currentChanged(QWidget *)), this, SLOT(UpdateType())); connect(m_aircraft->TabObject, SIGNAL(currentChanged(int)), this, SLOT(UpdateType()));
connect(m_aircraft->SwashLvlStartButton, SIGNAL(clicked()), this, SLOT(SwashLvlStartButtonPressed())); connect(m_aircraft->SwashLvlStartButton, SIGNAL(clicked()), this, SLOT(SwashLvlStartButtonPressed()));
connect(m_aircraft->SwashLvlNextButton, SIGNAL(clicked()), this, SLOT(SwashLvlNextButtonPressed())); connect(m_aircraft->SwashLvlNextButton, SIGNAL(clicked()), this, SLOT(SwashLvlNextButtonPressed()));
@ -384,49 +385,21 @@ QString ConfigCcpmWidget::updateConfigObjectsFromWidgets()
void ConfigCcpmWidget::UpdateType() void ConfigCcpmWidget::UpdateType()
{ {
int TypeInt, SingleServoIndex, NumServosDefined; int SingleServoIndex, NumServosDefined;
double AdjustmentAngle = 0; double AdjustmentAngle = 0;
SetUIComponentVisibilities(); SetUIComponentVisibilities();
TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1; typeText = m_aircraft->ccpmType->currentText();
TypeText = m_aircraft->ccpmType->currentText();
SingleServoIndex = m_aircraft->ccpmSingleServo->currentIndex(); SingleServoIndex = m_aircraft->ccpmSingleServo->currentIndex();
// set visibility of user settings (When Custom) AdjustmentAngle = SingleServoIndex * 90;
m_aircraft->ccpmAdvancedSettingsTable->setEnabled(TypeInt == 0);
// Clear advanced settings table if not Custom selected (Keep previous settings)
if (TypeText.compare(QString::fromUtf8("Custom - Advanced Settings"), Qt::CaseInsensitive) != 0) {
m_aircraft->ccpmAdvancedSettingsTable->clearFocus();
}
m_aircraft->ccpmAngleW->setEnabled(TypeInt == 1);
m_aircraft->ccpmAngleX->setEnabled(TypeInt == 1);
m_aircraft->ccpmAngleY->setEnabled(TypeInt == 1);
m_aircraft->ccpmAngleZ->setEnabled(TypeInt == 1);
m_aircraft->ccpmCorrectionAngle->setEnabled(TypeInt != 0);
m_aircraft->ccpmServoWChannel->setEnabled(TypeInt > 0);
m_aircraft->ccpmServoXChannel->setEnabled(TypeInt > 0);
m_aircraft->ccpmServoYChannel->setEnabled(TypeInt > 0);
m_aircraft->ccpmServoZChannel->setEnabled(TypeInt > 0);
m_aircraft->ccpmSingleServo->setEnabled(TypeInt > 1);
m_aircraft->ccpmEngineChannel->setEnabled(TypeInt > 0);
m_aircraft->ccpmTailChannel->setEnabled(TypeInt > 0);
m_aircraft->ccpmCollectiveSlider->setEnabled(TypeInt > 0);
m_aircraft->ccpmCollectivespinBox->setEnabled(TypeInt > 0);
m_aircraft->ccpmRevoSlider->setEnabled(TypeInt > 0);
m_aircraft->ccpmREVOspinBox->setEnabled(TypeInt > 0);
AdjustmentAngle = SingleServoIndex * 90;
m_aircraft->PitchCurve->setVisible(1); m_aircraft->PitchCurve->setVisible(1);
NumServosDefined = 4; NumServosDefined = 4;
// set values for pre defined heli types // set values for pre defined heli types
if (TypeText.compare(QString::fromUtf8("CCPM 2 Servo 90º"), Qt::CaseInsensitive) == 0) { if (typeText.compare(QString::fromUtf8("CCPM 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(0); m_aircraft->ccpmAngleY->setValue(0);
@ -438,7 +411,7 @@ void ConfigCcpmWidget::UpdateType()
m_aircraft->ccpmServoYChannel->setEnabled(0); m_aircraft->ccpmServoYChannel->setEnabled(0);
m_aircraft->ccpmServoZChannel->setEnabled(0); m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined = 2; NumServosDefined = 2;
} else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive) == 0) { } else if (typeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360)); m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360));
@ -447,7 +420,7 @@ void ConfigCcpmWidget::UpdateType()
m_aircraft->ccpmServoZChannel->setCurrentIndex(0); m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setEnabled(0); m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined = 3; NumServosDefined = 3;
} else if (TypeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive) == 0) { } else if (typeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360)); m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360));
@ -455,7 +428,7 @@ void ConfigCcpmWidget::UpdateType()
m_aircraft->ccpmSingleServo->setEnabled(0); m_aircraft->ccpmSingleServo->setEnabled(0);
m_aircraft->ccpmSingleServo->setCurrentIndex(0); m_aircraft->ccpmSingleServo->setCurrentIndex(0);
NumServosDefined = 4; NumServosDefined = 4;
} else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive) == 0) { } else if (typeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120, 360)); m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120, 360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240, 360)); m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240, 360));
@ -464,7 +437,7 @@ void ConfigCcpmWidget::UpdateType()
m_aircraft->ccpmServoZChannel->setCurrentIndex(0); m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setEnabled(0); m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined = 3; NumServosDefined = 3;
} else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive) == 0) { } else if (typeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140, 360)); m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140, 360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220, 360)); m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220, 360));
@ -473,7 +446,7 @@ void ConfigCcpmWidget::UpdateType()
m_aircraft->ccpmServoZChannel->setCurrentIndex(0); m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setEnabled(0); m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined = 3; NumServosDefined = 3;
} else if (TypeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive) == 0) { } else if (typeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(0); m_aircraft->ccpmAngleY->setValue(0);
@ -491,7 +464,7 @@ void ConfigCcpmWidget::UpdateType()
m_aircraft->ccpmCollectiveSlider->setValue(0); m_aircraft->ccpmCollectiveSlider->setValue(0);
m_aircraft->PitchCurve->setVisible(0); m_aircraft->PitchCurve->setVisible(0);
NumServosDefined = 2; NumServosDefined = 2;
} else if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { } else if (typeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(0); m_aircraft->ccpmAngleY->setValue(0);
@ -512,7 +485,7 @@ void ConfigCcpmWidget::UpdateType()
} }
// Set the text of the motor boxes // Set the text of the motor boxes
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { if (typeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmEngineLabel->setText("CW motor"); m_aircraft->ccpmEngineLabel->setText("CW motor");
m_aircraft->ccpmTailLabel->setText("CCW motor"); m_aircraft->ccpmTailLabel->setText("CCW motor");
} else { } else {
@ -671,9 +644,14 @@ void ConfigCcpmWidget::UpdateMixer()
float ThisAngle[6]; float ThisAngle[6];
QString Channel; QString Channel;
if (throwConfigError(QString("HeliCP"))) { int typeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1;
// Exit if currently updatingToHardware or ConfigError
// Avoid mixer changes if something wrong in config
if (throwConfigError(typeInt) || updatingToHardware) {
return; return;
} }
GUIConfigDataUnion config = getConfigData(); GUIConfigDataUnion config = getConfigData();
useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState);
@ -694,16 +672,18 @@ void ConfigCcpmWidget::UpdateMixer()
; ;
} }
} }
int TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1;
if (TypeInt != 0) { // not advanced settings
// get the channel data from the ui
MixerChannelData[0] = m_aircraft->ccpmEngineChannel->currentIndex();
MixerChannelData[1] = m_aircraft->ccpmTailChannel->currentIndex();
MixerChannelData[2] = m_aircraft->ccpmServoWChannel->currentIndex();
MixerChannelData[3] = m_aircraft->ccpmServoXChannel->currentIndex();
MixerChannelData[4] = m_aircraft->ccpmServoYChannel->currentIndex();
MixerChannelData[5] = m_aircraft->ccpmServoZChannel->currentIndex();
// get the channel data from the ui
MixerChannelData[0] = m_aircraft->ccpmEngineChannel->currentIndex();
MixerChannelData[1] = m_aircraft->ccpmTailChannel->currentIndex();
MixerChannelData[2] = m_aircraft->ccpmServoWChannel->currentIndex();
MixerChannelData[3] = m_aircraft->ccpmServoXChannel->currentIndex();
MixerChannelData[4] = m_aircraft->ccpmServoYChannel->currentIndex();
MixerChannelData[5] = m_aircraft->ccpmServoZChannel->currentIndex();
QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable;
if (typeInt != 0) { // not advanced settings
// get the angle data from the ui // get the angle data from the ui
ThisAngle[2] = m_aircraft->ccpmAngleW->value(); ThisAngle[2] = m_aircraft->ccpmAngleW->value();
ThisAngle[3] = m_aircraft->ccpmAngleX->value(); ThisAngle[3] = m_aircraft->ccpmAngleX->value();
@ -722,11 +702,9 @@ void ConfigCcpmWidget::UpdateMixer()
ServosText[3]->setPlainText(QString("%1").arg(MixerChannelData[5])); ServosText[3]->setPlainText(QString("%1").arg(MixerChannelData[5]));
// go through the user data and update the mixer matrix // go through the user data and update the mixer matrix
QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable;
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
if ((MixerChannelData[i] > 0) && ((ThisEnable[i]) || (i < 2))) { if (((MixerChannelData[i] > 0) && ThisEnable[i]) || (i < 2)) {
table->item(i, 0)->setText(QString("%1").arg(MixerChannelData[i])); table->item(i, 0)->setText(QString("%1").arg(MixerChannelData[i]));
// Generate the mixer vector // Generate the mixer vector
if (i == 0) { // main motor-engine if (i == 0) { // main motor-engine
table->item(i, 1)->setText(QString("%1").arg(127)); // ThrottleCurve1 table->item(i, 1)->setText(QString("%1").arg(127)); // ThrottleCurve1
@ -734,7 +712,7 @@ void ConfigCcpmWidget::UpdateMixer()
table->item(i, 3)->setText(QString("%1").arg(0)); // Roll table->item(i, 3)->setText(QString("%1").arg(0)); // Roll
table->item(i, 4)->setText(QString("%1").arg(0)); // Pitch table->item(i, 4)->setText(QString("%1").arg(0)); // Pitch
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { if (typeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
// Yaw // Yaw
table->item(i, 5)->setText(QString("%1").arg(-127)); table->item(i, 5)->setText(QString("%1").arg(-127));
} else { } else {
@ -744,7 +722,7 @@ void ConfigCcpmWidget::UpdateMixer()
} }
if (i == 1) { if (i == 1) {
// tailrotor --or-- counter-clockwise motor // tailrotor --or-- counter-clockwise motor
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { if (typeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
// ThrottleCurve1 // ThrottleCurve1
table->item(i, 1)->setText(QString("%1").arg(127)); table->item(i, 1)->setText(QString("%1").arg(127));
// Yaw // Yaw
@ -787,14 +765,34 @@ void ConfigCcpmWidget::UpdateMixer()
} }
} else { } else {
// advanced settings // advanced settings
QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable; UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
// Populate custom mixer table from board values
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
Channel = table->item(i, 0)->text(); if (MixerChannelData[i] > 0) {
if (Channel == "-") { // Channel number
Channel = QString((int)ConfigCcpmWidget::CHANNEL_NUMELEM + 1); table->item(i, 0)->setText(QString("%1").arg(MixerChannelData[i]));
// Throttle1
table->item(i, 1)->setText(QString("%1").arg(getMixerVectorValue(mixer, MixerChannelData[i] - 1,
VehicleConfig::MIXERVECTOR_THROTTLECURVE1)));
// Throttle2
table->item(i, 2)->setText(QString("%1").arg(getMixerVectorValue(mixer, MixerChannelData[i] - 1,
VehicleConfig::MIXERVECTOR_THROTTLECURVE2)));
// Roll
table->item(i, 3)->setText(QString("%1").arg(getMixerVectorValue(mixer, MixerChannelData[i] - 1,
VehicleConfig::MIXERVECTOR_ROLL)));
// Pitch
table->item(i, 4)->setText(QString("%1").arg(getMixerVectorValue(mixer, MixerChannelData[i] - 1,
VehicleConfig::MIXERVECTOR_PITCH)));
// Yaw
table->item(i, 5)->setText(QString("%1").arg(getMixerVectorValue(mixer, MixerChannelData[i] - 1,
VehicleConfig::MIXERVECTOR_YAW)));
} else {
for (int j = 0; j < 6; j++) {
table->item(i, j)->setText(QString("-"));
}
} }
MixerChannelData[i] = Channel.toInt();
} }
} }
} }
@ -893,6 +891,31 @@ void ConfigCcpmWidget::SetUIComponentVisibilities()
m_aircraft->SwashLvlStepList->item(1)->setBackground(Qt::transparent); m_aircraft->SwashLvlStepList->item(1)->setBackground(Qt::transparent);
m_aircraft->SwashLvlStepList->item(2)->setBackground(Qt::transparent); m_aircraft->SwashLvlStepList->item(2)->setBackground(Qt::transparent);
m_aircraft->SwashLvlStepList->item(3)->setBackground(Qt::transparent); m_aircraft->SwashLvlStepList->item(3)->setBackground(Qt::transparent);
// Enable / disable by typeInt : 0 is custom
int typeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1;
// set visibility of user settings (When Custom)
m_aircraft->ccpmAdvancedSettingsTable->setEnabled(typeInt == 0);
m_aircraft->ccpmAngleW->setEnabled(typeInt == 1);
m_aircraft->ccpmAngleX->setEnabled(typeInt == 1);
m_aircraft->ccpmAngleY->setEnabled(typeInt == 1);
m_aircraft->ccpmAngleZ->setEnabled(typeInt == 1);
m_aircraft->ccpmCorrectionAngle->setEnabled(typeInt != 0);
m_aircraft->ccpmServoWChannel->setEnabled(typeInt > 0);
m_aircraft->ccpmServoXChannel->setEnabled(typeInt > 0);
m_aircraft->ccpmServoYChannel->setEnabled(typeInt > 0);
m_aircraft->ccpmServoZChannel->setEnabled(typeInt > 0);
m_aircraft->ccpmSingleServo->setEnabled(typeInt > 1);
m_aircraft->ccpmEngineChannel->setEnabled(typeInt > 0);
m_aircraft->ccpmTailChannel->setEnabled(typeInt > 0);
m_aircraft->ccpmCollectiveSlider->setEnabled(typeInt > 0);
m_aircraft->ccpmCollectivespinBox->setEnabled(typeInt > 0);
m_aircraft->ccpmRevoSlider->setEnabled(typeInt > 0);
m_aircraft->ccpmREVOspinBox->setEnabled(typeInt > 0);
} }
/** /**
@ -942,6 +965,14 @@ void ConfigCcpmWidget::setMixer()
{ {
int i, j; int i, j;
int typeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1;
// Exit if currently updatingToHardware or ConfigError
// Avoid mixer changes if something wrong in config
if (throwConfigError(typeInt) || updatingToHardware) {
return;
}
if (SwashLvlConfigurationInProgress) { if (SwashLvlConfigurationInProgress) {
return; return;
} }
@ -986,15 +1017,16 @@ void ConfigCcpmWidget::setMixer()
&mixerSettingsData.Mixer12Type &mixerSettingsData.Mixer12Type
}; };
// reset all to Disabled // reset all outputs to Disabled
for (i = 0; i < 8; i++) { for (i = 0; i < (int)ConfigCcpmWidget::CHANNEL_NUMELEM; i++) {
*mixerTypes[i] = 0; *mixerTypes[i] = 0;
} }
// go through the user data and update the mixer matrix // go through the user data and update the mixer matrix
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if ((MixerChannelData[i] > 0) && (MixerChannelData[i] < (int)ConfigCcpmWidget::CHANNEL_NUMELEM + 1)) { if ((MixerChannelData[i] > 0) && (MixerChannelData[i] < (int)ConfigCcpmWidget::CHANNEL_NUMELEM + 1)) {
// Set the mixer type. If Coax, then first two are motors. Otherwise, only first is motor // Set the mixer type. If Coax, then first two are motors. Otherwise, only first is motor
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { if (typeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
*(mixerTypes[MixerChannelData[i] - 1]) = i > 1 ? *(mixerTypes[MixerChannelData[i] - 1]) = i > 1 ?
MixerSettings::MIXER1TYPE_SERVO : MixerSettings::MIXER1TYPE_SERVO :
MixerSettings::MIXER1TYPE_MOTOR; MixerSettings::MIXER1TYPE_MOTOR;
@ -1560,52 +1592,44 @@ void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value)
/** /**
This function displays text and color formatting in order to help the user understand what channels have not yet been configured. This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
*/ */
bool ConfigCcpmWidget::throwConfigError(QString airframeType) bool ConfigCcpmWidget::throwConfigError(int typeInt)
{ {
Q_UNUSED(airframeType);
bool error = false; bool error = false;
if ((m_aircraft->ccpmServoWChannel->currentIndex() == 0) && (m_aircraft->ccpmServoWChannel->isVisible())) { // Custom no need check, always return no error
m_aircraft->ccpmServoWLabel->setText("<font color=red>" + m_aircraft->ccpmServoWLabel->text() + "</font>"); if (typeInt == 0) {
error = true; return false;
} else {
m_aircraft->ccpmServoWLabel->setText(QTextEdit(m_aircraft->ccpmServoWLabel->text()).toPlainText());
} }
if ((m_aircraft->ccpmServoXChannel->currentIndex() == 0) && (m_aircraft->ccpmServoXChannel->isVisible())) { QList<QComboBox *> comboChannelsName;
m_aircraft->ccpmServoXLabel->setText("<font color=red>" + m_aircraft->ccpmServoXLabel->text() + "</font>"); comboChannelsName << m_aircraft->ccpmEngineChannel << m_aircraft->ccpmTailChannel << m_aircraft->ccpmServoWChannel
error = true; << m_aircraft->ccpmServoXChannel << m_aircraft->ccpmServoYChannel << m_aircraft->ccpmServoZChannel;
} else { QString channelNames = "";
m_aircraft->ccpmServoXLabel->setText(QTextEdit(m_aircraft->ccpmServoXLabel->text()).toPlainText());
}
if ((m_aircraft->ccpmServoYChannel->currentIndex() == 0) && (m_aircraft->ccpmServoYChannel->isVisible())) { for (int i = 0; i < 6; i++) {
m_aircraft->ccpmServoYLabel->setText("<font color=red>" + m_aircraft->ccpmServoYLabel->text() + "</font>"); QComboBox *combobox = comboChannelsName[i];
error = true; if (combobox && (combobox->isVisible())) {
} else { if (combobox->currentText() == "None") {
m_aircraft->ccpmServoYLabel->setText(QTextEdit(m_aircraft->ccpmServoYLabel->text()).toPlainText()); int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
QPixmap pixmap(size, size);
pixmap.fill(QColor("red"));
combobox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
error = true;
} else if (channelNames.contains(combobox->currentText(), Qt::CaseInsensitive)) {
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
QPixmap pixmap(size, size);
pixmap.fill(QColor("orange"));
combobox->setItemData(combobox->currentIndex(), pixmap, Qt::DecorationRole); // Set color palettes
combobox->setToolTip(tr("Channel already used"));
error = true;
} else {
for (int index = 0; index < (int)ConfigCcpmWidget::CHANNEL_NUMELEM; index++) {
combobox->setItemData(index, 0, Qt::DecorationRole); // Reset all color palettes
combobox->setToolTip("");
}
}
channelNames += (combobox->currentText() == "None") ? "" : combobox->currentText();
}
} }
if ((m_aircraft->ccpmServoZChannel->currentIndex() == 0) && (m_aircraft->ccpmServoZChannel->isVisible())) {
m_aircraft->ccpmServoZLabel->setText("<font color=red>" + m_aircraft->ccpmServoZLabel->text() + "</font>");
error = true;
} else {
m_aircraft->ccpmServoZLabel->setText(QTextEdit(m_aircraft->ccpmServoZLabel->text()).toPlainText());
}
if ((m_aircraft->ccpmEngineChannel->currentIndex() == 0) && (m_aircraft->ccpmEngineChannel->isEnabled())) {
m_aircraft->ccpmEngineLabel->setText("<font color=red>" + m_aircraft->ccpmEngineLabel->text() + "</font>");
} else {
m_aircraft->ccpmEngineLabel->setText(QTextEdit(m_aircraft->ccpmEngineLabel->text()).toPlainText());
}
if ((m_aircraft->ccpmTailChannel->currentIndex() == 0) && (m_aircraft->ccpmTailChannel->isEnabled())) {
m_aircraft->ccpmTailLabel->setText("<font color=red>" + m_aircraft->ccpmTailLabel->text() + "</font>");
error = true;
} else {
m_aircraft->ccpmTailLabel->setText(QTextEdit(m_aircraft->ccpmTailLabel->text()).toPlainText());
}
return error; return error;
} }

View File

@ -3,6 +3,7 @@
* *
* @file configccpmtwidget.h * @file configccpmtwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @addtogroup ConfigPlugin Config Plugin * @addtogroup ConfigPlugin Config Plugin
@ -84,7 +85,7 @@ private:
QGraphicsEllipseItem *ServosTextCircles[CCPM_MAX_SWASH_SERVOS]; QGraphicsEllipseItem *ServosTextCircles[CCPM_MAX_SWASH_SERVOS];
QSpinBox *SwashLvlSpinBoxes[CCPM_MAX_SWASH_SERVOS]; QSpinBox *SwashLvlSpinBoxes[CCPM_MAX_SWASH_SERVOS];
QString TypeText; QString typeText;
bool SwashLvlConfigurationInProgress; bool SwashLvlConfigurationInProgress;
UAVObject::Metadata SwashLvlaccInitialData; UAVObject::Metadata SwashLvlaccInitialData;
@ -112,7 +113,7 @@ private:
private slots: private slots:
virtual void setupUI(QString airframeType); virtual void setupUI(QString airframeType);
virtual bool throwConfigError(QString airframeType); virtual bool throwConfigError(int typeInt);
void ccpmSwashplateUpdate(); void ccpmSwashplateUpdate();
void ccpmSwashplateRedraw(); void ccpmSwashplateRedraw();

View File

@ -3,6 +3,7 @@
* *
* @file vehicleconfig.h * @file vehicleconfig.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
* @{ * @{
* @addtogroup ConfigPlugin Config Plugin * @addtogroup ConfigPlugin Config Plugin
@ -60,7 +61,7 @@ typedef struct {
} __attribute__((packed)) multiGUISettingsStruct; } __attribute__((packed)) multiGUISettingsStruct;
typedef struct { typedef struct {
uint SwashplateType : 3; uint SwashplateType : 4;
uint FirstServoIndex : 2; uint FirstServoIndex : 2;
uint CorrectionAngle : 9; uint CorrectionAngle : 9;
uint ccpmCollectivePassthroughState : 1; uint ccpmCollectivePassthroughState : 1;
@ -75,7 +76,7 @@ typedef struct {
uint ServoIndexZ : 4; // 57 bits uint ServoIndexZ : 4; // 57 bits
uint Throttle : 4; uint Throttle : 4;
uint Tail : 4; // 65bits uint Tail : 4; // 65bits
quint32 padding : 31; // 96 bits quint32 padding : 30; // 96 bits
quint32 padding1; // 128 bits quint32 padding1; // 128 bits
} __attribute__((packed)) heliGUISettingsStruct; } __attribute__((packed)) heliGUISettingsStruct;