1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

OP-907 step 3: cleaned up vehicleconfig.h + related cleanups

This commit is contained in:
Philippe Renon 2013-04-03 01:42:42 +02:00
parent 3ab96ed3cc
commit 90b0c5ca21
12 changed files with 381 additions and 394 deletions

View File

@ -42,6 +42,71 @@
#define Pi 3.14159265358979323846
QStringList ConfigCcpmWidget::getChannelDescriptions()
{
int i;
QStringList channelDesc;
// init a channel_numelem list of channel desc defaults
for (i=0; i < (int)(ConfigCcpmWidget::CHANNEL_NUMELEM); i++)
{
channelDesc.append(QString("-"));
}
// get the gui config data
GUIConfigDataUnion configData = GetConfigData();
heliGUISettingsStruct heli = configData.heli;
if (heli.Throttle > 0)
channelDesc[heli.Throttle - 1] = QString("Throttle");
if (heli.Tail > 0)
channelDesc[heli.Tail - 1] = QString("Tail");
switch(heli.FirstServoIndex)
{
case 0: //front
if (heli.ServoIndexW > 0)
channelDesc[heli.ServoIndexW - 1] = QString("Elevator");
if (heli.ServoIndexX > 0)
channelDesc[heli.ServoIndexX - 1] = QString("Roll1");
if (heli.ServoIndexY > 0)
channelDesc[heli.ServoIndexY - 1] = QString("Roll2");
break;
case 1: //right
if (heli.ServoIndexW > 0)
channelDesc[heli.ServoIndexW - 1] = QString("ServoW");
if (heli.ServoIndexX > 0)
channelDesc[heli.ServoIndexX - 1] = QString("ServoX");
if (heli.ServoIndexY > 0)
channelDesc[heli.ServoIndexY - 1] = QString("ServoY");
break;
case 2: //rear
if (heli.ServoIndexW > 0)
channelDesc[heli.ServoIndexW - 1] = QString("Elevator");
if (heli.ServoIndexX > 0)
channelDesc[heli.ServoIndexX - 1] = QString("Roll1");
if (heli.ServoIndexY > 0)
channelDesc[heli.ServoIndexY - 1] = QString("Roll2");
break;
case 3: //left
if (heli.ServoIndexW > 0)
channelDesc[heli.ServoIndexW - 1] = QString("ServoW");
if (heli.ServoIndexX > 0)
channelDesc[heli.ServoIndexX - 1] = QString("ServoX");
if (heli.ServoIndexY > 0)
channelDesc[heli.ServoIndexY - 1] = QString("ServoY");
break;
}
if (heli.ServoIndexZ > 0)
channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ");
return channelDesc;
}
ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) :
VehicleConfig(parent), m_aircraft(new Ui_CcpmConfigWidget())
{
@ -210,7 +275,7 @@ void ConfigCcpmWidget::setupUI(QString frameType)
Q_UNUSED(frameType);
}
void ConfigCcpmWidget::ResetActuators(GUIConfigDataUnion* configData)
void ConfigCcpmWidget::resetActuators(GUIConfigDataUnion *configData)
{
configData->heli.Throttle = 0;
configData->heli.Tail = 0;
@ -220,197 +285,96 @@ void ConfigCcpmWidget::ResetActuators(GUIConfigDataUnion* configData)
configData->heli.ServoIndexZ = 0;
}
QStringList ConfigCcpmWidget::getChannelDescriptions()
{
int i;
QStringList channelDesc;
// init a channel_numelem list of channel desc defaults
for (i=0; i < (int)(ConfigCcpmWidget::CHANNEL_NUMELEM); i++)
{
channelDesc.append(QString("-"));
}
// get the gui config data
GUIConfigDataUnion configData = GetConfigData();
heliGUISettingsStruct heli = configData.heli;
if (heli.Throttle > 0)
channelDesc[heli.Throttle - 1] = QString("Throttle");
if (heli.Tail > 0)
channelDesc[heli.Tail - 1] = QString("Tail");
switch(heli.FirstServoIndex)
{
case 0: //front
if (heli.ServoIndexW > 0)
channelDesc[heli.ServoIndexW - 1] = QString("Elevator");
if (heli.ServoIndexX > 0)
channelDesc[heli.ServoIndexX - 1] = QString("Roll1");
if (heli.ServoIndexY > 0)
channelDesc[heli.ServoIndexY - 1] = QString("Roll2");
break;
case 1: //right
if (heli.ServoIndexW > 0)
channelDesc[heli.ServoIndexW - 1] = QString("ServoW");
if (heli.ServoIndexX > 0)
channelDesc[heli.ServoIndexX - 1] = QString("ServoX");
if (heli.ServoIndexY > 0)
channelDesc[heli.ServoIndexY - 1] = QString("ServoY");
break;
case 2: //rear
if (heli.ServoIndexW > 0)
channelDesc[heli.ServoIndexW - 1] = QString("Elevator");
if (heli.ServoIndexX > 0)
channelDesc[heli.ServoIndexX - 1] = QString("Roll1");
if (heli.ServoIndexY > 0)
channelDesc[heli.ServoIndexY - 1] = QString("Roll2");
break;
case 3: //left
if (heli.ServoIndexW > 0)
channelDesc[heli.ServoIndexW - 1] = QString("ServoW");
if (heli.ServoIndexX > 0)
channelDesc[heli.ServoIndexX - 1] = QString("ServoX");
if (heli.ServoIndexY > 0)
channelDesc[heli.ServoIndexY - 1] = QString("ServoY");
break;
}
if (heli.ServoIndexZ > 0)
channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ");
return channelDesc;
}
void ConfigCcpmWidget::UpdateType()
{
int TypeInt,SingleServoIndex,NumServosDefined;
double AdjustmentAngle=0;
int TypeInt, SingleServoIndex, NumServosDefined;
double AdjustmentAngle = 0;
SetUIComponentVisibilities();
TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1;
TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1;
TypeText = m_aircraft->ccpmType->currentText();
SingleServoIndex = m_aircraft->ccpmSingleServo->currentIndex();
//set visibility of user settings
m_aircraft->ccpmAdvancedSettingsTable->setEnabled(TypeInt==0);
m_aircraft->ccpmAdvancedSettingsTable->clearFocus();;
m_aircraft->ccpmAdvancedSettingsTable->setEnabled(TypeInt == 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->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->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);
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;
AdjustmentAngle = SingleServoIndex * 90;
m_aircraft->PitchCurve->setVisible(1);
NumServosDefined=4;
NumServosDefined = 4;
//set values for pre defined heli types
if (TypeText.compare(QString::fromUtf8("CCPM 2 Servo 90º"), Qt::CaseInsensitive)==0)
{
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
m_aircraft->ccpmAngleY->setValue(0);
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleY->setEnabled(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoYChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoYChannel->setEnabled(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined=2;
}
else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive)==0)
{
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360));
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined=3;
}
else if (TypeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive)==0)
{
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360));
m_aircraft->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270,360));
m_aircraft->ccpmSingleServo->setEnabled(0);
m_aircraft->ccpmSingleServo->setCurrentIndex(0);
NumServosDefined=4;
}
else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive)==0)
{
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120,360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240,360));
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined=3;
}
else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive)==0)
{
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140,360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220,360));
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined=3;
}
else if (TypeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive)==0)
{
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
m_aircraft->ccpmAngleY->setValue(0);
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleY->setEnabled(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoYChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoYChannel->setEnabled(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
m_aircraft->ccpmCollectivespinBox->setEnabled(0);
m_aircraft->ccpmCollectiveSlider->setEnabled(0);
m_aircraft->ccpmCollectivespinBox->setValue(0);
m_aircraft->ccpmCollectiveSlider->setValue(0);
m_aircraft->PitchCurve->setVisible(0);
NumServosDefined=2;
}
else if (TypeText.compare(QString::fromUtf8("Coax 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->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360));
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(0);
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleY->setEnabled(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoYChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoYChannel->setEnabled(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined = 2;
} else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360));
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined = 3;
} else if (TypeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360));
m_aircraft->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270, 360));
m_aircraft->ccpmSingleServo->setEnabled(0);
m_aircraft->ccpmSingleServo->setCurrentIndex(0);
NumServosDefined = 4;
} else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120, 360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240, 360));
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined = 3;
} else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140, 360));
m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220, 360));
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
NumServosDefined = 3;
} else if (TypeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(0);
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleY->setEnabled(0);
@ -425,55 +389,66 @@ void ConfigCcpmWidget::UpdateType()
m_aircraft->ccpmCollectivespinBox->setValue(0);
m_aircraft->ccpmCollectiveSlider->setValue(0);
m_aircraft->PitchCurve->setVisible(0);
NumServosDefined=2;
NumServosDefined = 2;
} else if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0);
m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360));
m_aircraft->ccpmAngleY->setValue(0);
m_aircraft->ccpmAngleZ->setValue(0);
m_aircraft->ccpmAngleY->setEnabled(0);
m_aircraft->ccpmAngleZ->setEnabled(0);
m_aircraft->ccpmServoYChannel->setCurrentIndex(0);
m_aircraft->ccpmServoZChannel->setCurrentIndex(0);
m_aircraft->ccpmServoYChannel->setEnabled(0);
m_aircraft->ccpmServoZChannel->setEnabled(0);
m_aircraft->ccpmCollectivespinBox->setEnabled(0);
m_aircraft->ccpmCollectiveSlider->setEnabled(0);
m_aircraft->ccpmCollectivespinBox->setValue(0);
m_aircraft->ccpmCollectiveSlider->setValue(0);
m_aircraft->PitchCurve->setVisible(0);
NumServosDefined = 2;
}
//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->ccpmTailLabel->setText("CCW motor");
}
else{
} else {
m_aircraft->ccpmEngineLabel->setText("Engine");
m_aircraft->ccpmTailLabel->setText("Tail rotor");
}
//set the visibility of the swashplate servo selection boxes
m_aircraft->ccpmServoWLabel->setVisible(NumServosDefined>=1);
m_aircraft->ccpmServoXLabel->setVisible(NumServosDefined>=2);
m_aircraft->ccpmServoYLabel->setVisible(NumServosDefined>=3);
m_aircraft->ccpmServoZLabel->setVisible(NumServosDefined>=4);
m_aircraft->ccpmServoWChannel->setVisible(NumServosDefined>=1);
m_aircraft->ccpmServoXChannel->setVisible(NumServosDefined>=2);
m_aircraft->ccpmServoYChannel->setVisible(NumServosDefined>=3);
m_aircraft->ccpmServoZChannel->setVisible(NumServosDefined>=4);
//set the visibility of the swashplate angle selection boxes
m_aircraft->ccpmServoWLabel_2->setVisible(NumServosDefined>=1);
m_aircraft->ccpmServoXLabel_2->setVisible(NumServosDefined>=2);
m_aircraft->ccpmServoYLabel_2->setVisible(NumServosDefined>=3);
m_aircraft->ccpmServoZLabel_2->setVisible(NumServosDefined>=4);
m_aircraft->ccpmAngleW->setVisible(NumServosDefined>=1);
m_aircraft->ccpmAngleX->setVisible(NumServosDefined>=2);
m_aircraft->ccpmAngleY->setVisible(NumServosDefined>=3);
m_aircraft->ccpmAngleZ->setVisible(NumServosDefined>=4);
m_aircraft->ccpmServoWLabel->setVisible(NumServosDefined >= 1);
m_aircraft->ccpmServoXLabel->setVisible(NumServosDefined >= 2);
m_aircraft->ccpmServoYLabel->setVisible(NumServosDefined >= 3);
m_aircraft->ccpmServoZLabel->setVisible(NumServosDefined >= 4);
m_aircraft->ccpmServoWChannel->setVisible(NumServosDefined >= 1);
m_aircraft->ccpmServoXChannel->setVisible(NumServosDefined >= 2);
m_aircraft->ccpmServoYChannel->setVisible(NumServosDefined >= 3);
m_aircraft->ccpmServoZChannel->setVisible(NumServosDefined >= 4);
m_aircraft->ccpmAdvancedSettingsTable->resizeColumnsToContents();
for (int i=0;i<6;i++) {
m_aircraft->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_aircraft->ccpmAdvancedSettingsTable->width()-
m_aircraft->ccpmAdvancedSettingsTable->verticalHeader()->width())/6);
//set the visibility of the swashplate angle selection boxes
m_aircraft->ccpmServoWLabel_2->setVisible(NumServosDefined >= 1);
m_aircraft->ccpmServoXLabel_2->setVisible(NumServosDefined >= 2);
m_aircraft->ccpmServoYLabel_2->setVisible(NumServosDefined >= 3);
m_aircraft->ccpmServoZLabel_2->setVisible(NumServosDefined >= 4);
m_aircraft->ccpmAngleW->setVisible(NumServosDefined >= 1);
m_aircraft->ccpmAngleX->setVisible(NumServosDefined >= 2);
m_aircraft->ccpmAngleY->setVisible(NumServosDefined >= 3);
m_aircraft->ccpmAngleZ->setVisible(NumServosDefined >= 4);
QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable;
table->resizeColumnsToContents();
for (int i = 0; i < 6; i++) {
table->setColumnWidth(i, (table->width() - table->verticalHeader()->width()) / 6);
}
//update UI
ccpmSwashplateUpdate();
}
void ConfigCcpmWidget::ccpmSwashplateRedraw()
{
double angle[CCPM_MAX_SWASH_SERVOS],CorrectionAngle,x,y,w,h,radius,CenterX,CenterY;
@ -586,8 +561,9 @@ void ConfigCcpmWidget::UpdateMixer()
{
bool useCCPM;
bool useCyclic;
int i,j,ThisEnable[6];
float CollectiveConstant,PitchConstant,RollConstant,ThisAngle[6];
int ThisEnable[6];
float CollectiveConstant, PitchConstant, RollConstant;
float ThisAngle[6];
QString Channel;
if (throwConfigError(QString("HeliCP")))
@ -598,29 +574,24 @@ void ConfigCcpmWidget::UpdateMixer()
useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState);
useCyclic = config.heli.ccpmLinkRollState;
CollectiveConstant = (float)config.heli.SliderValue0 / 100.00;
CollectiveConstant = (float) config.heli.SliderValue0 / 100.00;
if (useCCPM)
{//cyclic = 1 - collective
PitchConstant = 1-CollectiveConstant;
if (useCCPM) { //cyclic = 1 - collective
PitchConstant = 1 - CollectiveConstant;
RollConstant = PitchConstant;
}
else
{
PitchConstant = (float)config.heli.SliderValue1 / 100.00;;
if (useCyclic)
{
} else {
PitchConstant = (float) config.heli.SliderValue1 / 100.00;
;
if (useCyclic) {
RollConstant = PitchConstant;
}
else
{
RollConstant = (float)config.heli.SliderValue2 / 100.00;;
}
} else {
RollConstant = (float) config.heli.SliderValue2 / 100.00;
;
}
}
if (config.heli.SwashplateType>0)
{//not advanced settings
//get the channel data from the ui
if (config.heli.SwashplateType > 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();
@ -640,78 +611,92 @@ void ConfigCcpmWidget::UpdateMixer()
ThisEnable[4] = m_aircraft->ccpmServoYChannel->isEnabled();
ThisEnable[5] = m_aircraft->ccpmServoZChannel->isEnabled();
ServosText[0]->setPlainText(QString("%1").arg( MixerChannelData[2] ));
ServosText[1]->setPlainText(QString("%1").arg( MixerChannelData[3] ));
ServosText[2]->setPlainText(QString("%1").arg( MixerChannelData[4] ));
ServosText[3]->setPlainText(QString("%1").arg( MixerChannelData[5] ));
ServosText[0]->setPlainText(QString("%1").arg(MixerChannelData[2]));
ServosText[1]->setPlainText(QString("%1").arg(MixerChannelData[3]));
ServosText[2]->setPlainText(QString("%1").arg(MixerChannelData[4]));
ServosText[3]->setPlainText(QString("%1").arg(MixerChannelData[5]));
//go through the user data and update the mixer matrix
for (i=0;i<6;i++)
{
if ((MixerChannelData[i]>0) && ((ThisEnable[i])||(i<2)))
{
m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i] ));
QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable;
for (int i = 0; i < 6; i++) {
if ((MixerChannelData[i] > 0) && ((ThisEnable[i]) || (i < 2))) {
table->item(i, 0)->setText(QString("%1").arg(MixerChannelData[i]));
//Generate the mixer vector
if (i==0)
{//main motor-engine
m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1
m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2
m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll
m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch
if (i == 0) { //main motor-engine
table->item(i, 1)->setText(QString("%1").arg(127)); //ThrottleCurve1
table->item(i, 2)->setText(QString("%1").arg(0)); //ThrottleCurve2
table->item(i, 3)->setText(QString("%1").arg(0)); //Roll
table->item(i, 4)->setText(QString("%1").arg(0)); //Pitch
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0)
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(-127));//Yaw
else
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw
}
if (i==1)
{//tailrotor --or-- counter-clockwise motor
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0)
{
m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw
}
else{
m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
// Yaw
table->item(i, 5)->setText(QString("%1").arg(-127));
} else {
// Yaw
table->item(i, 5)->setText(QString("%1").arg(0));
}
m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2
m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll
m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch
}
if (i == 1) {
// tailrotor --or-- counter-clockwise motor
if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) {
// ThrottleCurve1
table->item(i, 1)->setText(QString("%1").arg(127));
// Yaw
table->item(i, 5)->setText(QString("%1").arg(127));
} else {
// ThrottleCurve1
table->item(i, 1)->setText(QString("%1").arg(0));
// Yaw
table->item(i, 5)->setText(QString("%1").arg(127));
}
//ThrottleCurve2
table->item(i, 2)->setText(QString("%1").arg(0));
// Roll
table->item(i, 3)->setText(QString("%1").arg(0));
// Pitch
table->item(i, 4)->setText(QString("%1").arg(0));
}
if (i>1)
{//Swashplate
m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1
m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2
m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll
m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch
m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw
if (i > 1) {
// Swashplate
//ThrottleCurve1
table->item(i, 1)->setText(QString("%1").arg(0));
//ThrottleCurve2
table->item(i, 2)->setText(QString("%1").arg((int) (127.0 * CollectiveConstant)));
table->item(i, 3)->setText(
QString("%1").arg(
(int) (127.0 * (RollConstant)
* sin((180 + config.heli.CorrectionAngle + ThisAngle[i]) * Pi / 180.00)))); //Roll
table->item(i, 4)->setText(
QString("%1").arg(
(int) (127.0 * (PitchConstant)
* cos((config.heli.CorrectionAngle + ThisAngle[i]) * Pi / 180.00)))); //Pitch
// Yaw
table->item(i, 5)->setText(QString("%1").arg(0));
}
}
else
{
for (j=0;j<6;j++) m_aircraft->ccpmAdvancedSettingsTable->item(i,j)->setText(QString("-"));
} else {
for (int j = 0; j < 6; j++) {
table->item(i, j)->setText(QString("-"));
}
}
}
} else {
// advanced settings
QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable;
for (int i = 0; i < 6; i++) {
Channel = table->item(i, 0)->text();
if (Channel == "-") {
Channel = QString("9");
}
MixerChannelData[i] = Channel.toInt();
}
}
else
{//advanced settings
for (i=0;i<6;i++)
{
Channel =m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->text();
if (Channel == "-") Channel = QString("9");
MixerChannelData[i]= Channel.toInt();
}
}
}
QString ConfigCcpmWidget::updateConfigObjects()
{
QString airframeType = "HeliCP";
@ -719,7 +704,8 @@ QString ConfigCcpmWidget::updateConfigObjects()
bool useCCPM;
bool useCyclic;
if (updatingFromHardware == TRUE) return airframeType;
if (updatingFromHardware == TRUE)
return airframeType;
updatingFromHardware = TRUE;
@ -727,7 +713,7 @@ QString ConfigCcpmWidget::updateConfigObjects()
GUIConfigDataUnion config = GetConfigData();
//swashplate config
config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1;
config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1;
config.heli.FirstServoIndex = m_aircraft->ccpmSingleServo->currentIndex();
//ccpm mixing options
@ -741,20 +727,14 @@ QString ConfigCcpmWidget::updateConfigObjects()
config.heli.CorrectionAngle = m_aircraft->ccpmCorrectionAngle->value();
//update sliders
if (useCCPM)
{
if (useCCPM) {
config.heli.SliderValue0 = m_aircraft->ccpmCollectiveSlider->value();
}
else
{
} else {
config.heli.SliderValue0 = m_aircraft->ccpmCollectiveScale->value();
}
if (useCyclic)
{
if (useCyclic) {
config.heli.SliderValue1 = m_aircraft->ccpmCyclicScale->value();
}
else
{
} else {
config.heli.SliderValue1 = m_aircraft->ccpmPitchScale->value();
}
config.heli.SliderValue2 = m_aircraft->ccpmRollScale->value();
@ -776,7 +756,7 @@ QString ConfigCcpmWidget::updateConfigObjects()
return airframeType;
}
QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI()
QString ConfigCcpmWidget::updateConfigObjectsFromWidgets()
{
QString airframeType = updateConfigObjects();
@ -785,7 +765,7 @@ QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFr
return airframeType;
}
void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFromOptions()
void ConfigCcpmWidget::refreshWidgetsValues(QString frameType)
{
Q_UNUSED(frameType);
@ -829,35 +809,34 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro
getMixer();
}
void ConfigCcpmWidget::SetUIComponentVisibilities()
{
m_aircraft->ccpmRevoMixingBox->setVisible(0);
m_aircraft->ccpmPitchMixingBox->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked() &&
m_aircraft->ccpmLinkCyclic->isChecked());
m_aircraft->ccpmCollectiveScalingBox->setVisible(m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked());
m_aircraft->ccpmPitchMixingBox->setVisible(
!m_aircraft->ccpmCollectivePassthrough->isChecked() && m_aircraft->ccpmLinkCyclic->isChecked());
m_aircraft->ccpmCollectiveScalingBox->setVisible(
m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked());
m_aircraft->ccpmLinkCyclic->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked());
m_aircraft->ccpmCyclicScalingBox->setVisible((m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()) &&
m_aircraft->ccpmLinkRoll->isChecked());
m_aircraft->ccpmCyclicScalingBox->setVisible(
(m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked())
&& m_aircraft->ccpmLinkRoll->isChecked());
if (!m_aircraft->ccpmCollectivePassthrough->checkState() && m_aircraft->ccpmLinkCyclic->isChecked())
{
if (!m_aircraft->ccpmCollectivePassthrough->checkState() && m_aircraft->ccpmLinkCyclic->isChecked()) {
m_aircraft->ccpmPitchScalingBox->setVisible(0);
m_aircraft->ccpmRollScalingBox->setVisible(0);
m_aircraft->ccpmLinkRoll->setVisible(0);
}
else
{
} else {
m_aircraft->ccpmPitchScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked());
m_aircraft->ccpmRollScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked());
m_aircraft->ccpmLinkRoll->setVisible(1);
}
}
/**
Request the current value of the SystemSettings which holds the ccpm type
*/
@ -899,7 +878,6 @@ void ConfigCcpmWidget::getMixer()
ccpmSwashplateUpdate();
}
/**
Sends the config to the board (ccpm type)
*/

View File

@ -57,13 +57,28 @@ class ConfigCcpmWidget: public VehicleConfig
Q_OBJECT
public:
static QStringList getChannelDescriptions();
ConfigCcpmWidget(QWidget *parent = 0);
~ConfigCcpmWidget();
friend class ConfigVehicleTypeWidget;
virtual void setupUI(QString airframeType);
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
public slots:
void getMixer();
void setMixer();
void saveccpmUpdate();
protected:
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
private:
//Ui_ccpmWidget *m_ccpm;
virtual void resetActuators(GUIConfigDataUnion *configData);
Ui_CcpmConfigWidget *m_aircraft;
QGraphicsSvgItem *SwashplateImg;
@ -86,20 +101,16 @@ private:
int MixerChannelData[6];
int ShowDisclaimer(int messageID);
virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget
virtual void enableControls(bool enable) { Q_UNUSED(enable) }; // Not used by this widget
bool updatingFromHardware;
bool updatingToHardware;
virtual void ResetActuators(GUIConfigDataUnion *configData);
static QStringList getChannelDescriptions();
// TODO ?
QString updateConfigObjects();
private slots:
virtual void setupUI(QString airframeType);
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
// TODO ?
virtual bool throwConfigError(QString airframeType);
void ccpmSwashplateUpdate();
@ -120,17 +131,8 @@ private slots:
void enableSwashplateLevellingControl(bool state);
void setSwashplateLevel(int percent);
void SwashLvlSpinBoxChanged(int value);
// TODO ?
virtual void refreshValues() {}; // Not used
public slots:
void getMixer();
void setMixer();
void saveccpmUpdate();
protected:
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
};
#endif // CONFIGccpmWIDGET_H

View File

@ -94,6 +94,11 @@ QStringList ConfigCustomWidget::getChannelDescriptions()
return channelDesc;
}
void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData)
{
}
/**
Helper function to update the UI widget objects
*/

View File

@ -46,30 +46,30 @@ class ConfigCustomWidget: public VehicleConfig
Q_OBJECT
public:
static QStringList getChannelDescriptions();
ConfigCustomWidget(QWidget *parent = 0);
~ConfigCustomWidget();
friend class ConfigVehicleTypeWidget;
private:
Ui_CustomConfigWidget *m_aircraft;
//virtual void ResetActuators(GUIConfigDataUnion *configData);
static QStringList getChannelDescriptions();
// static const QString CHANNELBOXNAME;
private slots:
virtual void setupUI(QString airframeType);
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
virtual bool throwConfigError(int numMotors);
protected:
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
signals:
void configurationChanged();
private:
virtual void resetActuators(GUIConfigDataUnion *configData);
Ui_CustomConfigWidget *m_aircraft;
private slots:
virtual bool throwConfigError(int numMotors);
//signals:
// void configurationChanged();
};

View File

@ -130,7 +130,7 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
}
}
void ConfigFixedWingWidget::ResetActuators(GUIConfigDataUnion* configData)
void ConfigFixedWingWidget::resetActuators(GUIConfigDataUnion *configData)
{
configData->fixedwing.FixedWingPitch1 = 0;
configData->fixedwing.FixedWingPitch2 = 0;
@ -297,7 +297,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
// Now setup the channels:
GUIConfigDataUnion config = GetConfigData();
ResetActuators(&config);
resetActuators(&config);
config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();
@ -369,7 +369,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
}
GUIConfigDataUnion config = GetConfigData();
ResetActuators(&config);
resetActuators(&config);
config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
@ -441,7 +441,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
}
GUIConfigDataUnion config = GetConfigData();
ResetActuators(&config);
resetActuators(&config);
config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();

View File

@ -46,25 +46,26 @@ class ConfigFixedWingWidget: public VehicleConfig
Q_OBJECT
public:
static QStringList getChannelDescriptions();
ConfigFixedWingWidget(QWidget *parent = 0);
~ConfigFixedWingWidget();
friend class ConfigVehicleTypeWidget;
virtual void setupUI(QString airframeType);
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
private:
virtual void resetActuators(GUIConfigDataUnion *configData);
Ui_FixedWingConfigWidget *m_aircraft;
bool setupFrameFixedWing(QString airframeType);
bool setupFrameElevon(QString airframeType);
bool setupFrameVtail(QString airframeType);
virtual void ResetActuators(GUIConfigDataUnion* configData);
static QStringList getChannelDescriptions();
private slots:
virtual void setupUI(QString airframeType);
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
virtual bool throwConfigError(QString airframeType);
protected:

View File

@ -161,7 +161,7 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
}
}
void ConfigGroundVehicleWidget::ResetActuators(GUIConfigDataUnion* configData)
void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData)
{
configData->ground.GroundVehicleSteering1 = 0;
configData->ground.GroundVehicleSteering2 = 0;
@ -330,7 +330,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp
// Now setup the channels:
GUIConfigDataUnion config = GetConfigData();
ResetActuators(&config);
resetActuators(&config);
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
@ -379,14 +379,14 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT
// Now setup the channels:
GUIConfigDataUnion config = GetConfigData();
ResetActuators(&config);
resetActuators(&config);
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
SetConfigData((config));
UAVDataObject* mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
UAVDataObject *mixer = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
resetMotorAndServoMixers(mixer);
@ -423,7 +423,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType)
// Now setup the channels:
GUIConfigDataUnion config = GetConfigData();
ResetActuators(&config);
resetActuators(&config);
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();

View File

@ -46,25 +46,25 @@ class ConfigGroundVehicleWidget: public VehicleConfig
Q_OBJECT
public:
static QStringList getChannelDescriptions();
ConfigGroundVehicleWidget(QWidget *parent = 0);
~ConfigGroundVehicleWidget();
friend class ConfigVehicleTypeWidget;
virtual void setupUI(QString airframeType);
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
private:
virtual void resetActuators(GUIConfigDataUnion *configData);
Ui_GroundConfigWidget *m_aircraft;
bool setupGroundVehicleCar(QString airframeType);
bool setupGroundVehicleDifferential(QString airframeType);
bool setupGroundVehicleMotorcycle(QString airframeType);
virtual void ResetActuators(GUIConfigDataUnion* configData);
static QStringList getChannelDescriptions();
private slots:
virtual void setupUI(QString airframeType);
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
virtual bool throwConfigError(QString airframeType);
protected:

View File

@ -296,7 +296,7 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType)
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
}
void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData)
void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData)
{
configData->multi.VTOLMotorN = 0;
configData->multi.VTOLMotorNE = 0;
@ -893,7 +893,7 @@ void ConfigMultiRotorWidget::setupMotors(QList<QString> motorList)
<< m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
GUIConfigDataUnion configData = GetConfigData();
ResetActuators(&configData);
resetActuators(&configData);
int index;
foreach (QString motor, motorList) {

View File

@ -46,12 +46,24 @@ class ConfigMultiRotorWidget: public VehicleConfig
Q_OBJECT
public:
static QStringList getChannelDescriptions();
static const QString CHANNELBOXNAME;
ConfigMultiRotorWidget(QWidget *parent = 0);
~ConfigMultiRotorWidget();
friend class ConfigVehicleTypeWidget;
virtual void setupUI(QString airframeType);
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
protected:
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
private:
virtual void resetActuators(GUIConfigDataUnion *configData);
Ui_MultiRotorConfigWidget *m_aircraft;
QWidget *uiowner;
@ -66,28 +78,14 @@ private:
float invertMotors;
virtual void ResetActuators(GUIConfigDataUnion *configData);
static QStringList getChannelDescriptions();
static const QString CHANNELBOXNAME;
void setYawMixLevel(int);
void drawAirframe(QString multiRotorType);
private slots:
virtual void setupUI(QString airframeType);
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
virtual bool throwConfigError(int numMotors);
void reverseMultirotorMotor();
protected:
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
signals:
void configurationChanged();
};
#endif // CONFIGMULTIROTORWIDGET_H

View File

@ -35,7 +35,7 @@
VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent)
{
//Generate lists of mixerTypeNames, mixerVectorNames, channelNames
// Generate lists of mixerTypeNames, mixerVectorNames, channelNames
channelNames << "None";
for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
mixerTypes << QString("Mixer%1Type").arg(i+1);
@ -50,7 +50,7 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent)
// This is needed because new style tries to compact things as much as possible in grid
// and on OSX the widget sizes of PushButtons is reported incorrectly:
// https://bugreports.qt-project.org/browse/QTBUG-14591
foreach( QPushButton * btn, findChildren<QPushButton*>() ) {
foreach(QPushButton *btn, findChildren<QPushButton*>()) {
btn->setAttribute(Qt::WA_LayoutUsesWidgetRect);
}
}
@ -107,7 +107,6 @@ void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) {
void VehicleConfig::setupUI(QString frameType)
{
}
QString VehicleConfig::updateConfigObjectsFromWidgets()
@ -119,7 +118,7 @@ void VehicleConfig::refreshWidgetsValues(QString frameType)
{
}
void VehicleConfig::ResetActuators(GUIConfigDataUnion *configData)
void VehicleConfig::resetActuators(GUIConfigDataUnion *configData)
{
}
@ -277,7 +276,7 @@ void VehicleConfig::setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveEle
break;
}
if (field && field->getNumElements() == curve.length()) {
if (field && (field->getNumElements() == (unsigned int) curve.length())) {
for (int i = 0; i < curve.length(); i++) {
field->setValue(curve.at(i), i);
}
@ -338,6 +337,7 @@ double VehicleConfig::getCurveMax(QList<double> *curve)
}
return max;
}
/**
Reset the contents of a field
*/
@ -348,12 +348,11 @@ void VehicleConfig::resetField(UAVObjectField * field)
}
}
/**
* Util function to get a pointer to the object manager
* @return pointer to the UAVObjectManager
*/
UAVObjectManager* VehicleConfig::getUAVObjectManager() {
UAVObjectManager *VehicleConfig::getUAVObjectManager() {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager * objMngr = pm->getObject<UAVObjectManager>();
Q_ASSERT(objMngr);

View File

@ -107,8 +107,6 @@ class VehicleConfig: public ConfigTaskWidget
Q_OBJECT
public:
VehicleConfig(QWidget *parent = 0);
~VehicleConfig();
/* Enumeration options for ThrottleCurves */
typedef enum {
@ -140,6 +138,8 @@ public:
MIXERVECTOR_YAW = 4
} MixerVectorElem;
static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;;
// TODO remove 1st capital
static GUIConfigDataUnion GetConfigData();
static void SetConfigData(GUIConfigDataUnion configData);
@ -148,12 +148,15 @@ public:
static void setComboCurrentIndex(QComboBox *box, int index);
static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable);
// VehicleConfig class
VehicleConfig(QWidget *parent = 0);
~VehicleConfig();
virtual void setupUI(QString airframeType);
virtual QString updateConfigObjectsFromWidgets();
virtual void refreshWidgetsValues(QString frameType);
virtual void ResetActuators(GUIConfigDataUnion *configData);
// TODO move to separate class
double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName);
void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value);
void resetMixerVector(UAVDataObject *mixer, int channel);
@ -168,16 +171,17 @@ public:
double getCurveMin(QList<double> *curve);
double getCurveMax(QList<double> *curve);
protected:
QStringList channelNames;
QStringList mixerTypes;
QStringList mixerVectors;
QStringList mixerTypeDescriptions;
static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;;
private:
static UAVObjectManager *getUAVObjectManager();
virtual void resetActuators(GUIConfigDataUnion *configData);
private slots:
public slots: