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

OP-1134 Populate_new_custom_tab Sub task OP-790 : Added custom labels in output, up to 8 Motors, revMotors or Servos

This commit is contained in:
Laurent Lalanne 2014-08-28 13:40:02 +02:00
parent 4e64710c54
commit eda53adf9e
2 changed files with 191 additions and 3 deletions

View File

@ -45,6 +45,84 @@ QStringList ConfigCustomWidget::getChannelDescriptions()
for (int i = 0; i < (int)VehicleConfig::CHANNEL_NUMELEM; i++) {
channelDesc.append(QString("-"));
}
// get the gui config data
GUIConfigDataUnion configData = getConfigData();
customGUISettingsStruct custom = configData.custom;
if (custom.Motor1 > 0 && custom.Motor1 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Motor1 - 1] = QString("Motor1");
}
if (custom.Motor2 > 0 && custom.Motor2 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Motor2 - 1] = QString("Motor2");
}
if (custom.Motor3 > 0 && custom.Motor3 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Motor3 - 1] = QString("Motor3");
}
if (custom.Motor4 > 0 && custom.Motor4 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Motor4 - 1] = QString("Motor4");
}
if (custom.Motor5 > 0 && custom.Motor5 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Motor5 - 1] = QString("Motor5");
}
if (custom.Motor6 > 0 && custom.Motor6 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Motor6 - 1] = QString("Motor6");
}
if (custom.Motor7 > 0 && custom.Motor7 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Motor7 - 1] = QString("Motor7");
}
if (custom.Motor8 > 0 && custom.Motor8 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Motor8 - 1] = QString("Motor8");
}
if (custom.RevMotor1 > 0 && custom.RevMotor1 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.RevMotor1 - 1] = QString("RevMotor1");
}
if (custom.RevMotor2 > 0 && custom.RevMotor2 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.RevMotor2 - 1] = QString("RevMotor2");
}
if (custom.RevMotor3 > 0 && custom.RevMotor3 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.RevMotor3 - 1] = QString("RevMotor3");
}
if (custom.RevMotor4 > 0 && custom.RevMotor4 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.RevMotor4 - 1] = QString("RevMotor4");
}
if (custom.RevMotor5 > 0 && custom.RevMotor5 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.RevMotor5 - 1] = QString("RevMotor5");
}
if (custom.RevMotor6 > 0 && custom.RevMotor6 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.RevMotor6 - 1] = QString("RevMotor6");
}
if (custom.RevMotor7 > 0 && custom.RevMotor7 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.RevMotor7 - 1] = QString("RevMotor7");
}
if (custom.RevMotor8 > 0 && custom.RevMotor8 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.RevMotor8 - 1] = QString("RevMotor8");
}
if (custom.Servo1 > 0 && custom.Servo1 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Servo1 - 1] = QString("Servo1");
}
if (custom.Servo2 > 0 && custom.Servo2 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Servo2 - 1] = QString("Servo2");
}
if (custom.Servo3 > 0 && custom.Servo3 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Servo3 - 1] = QString("Servo3");
}
if (custom.Servo4 > 0 && custom.Servo4 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Servo4 - 1] = QString("Servo4");
}
if (custom.Servo5 > 0 && custom.Servo5 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Servo5 - 1] = QString("Servo5");
}
if (custom.Servo6 > 0 && custom.Servo6 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Servo6 - 1] = QString("Servo6");
}
if (custom.Servo7 > 0 && custom.Servo7 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Servo7 - 1] = QString("Servo7");
}
if (custom.Servo8 > 0 && custom.Servo8 <= VehicleConfig::CHANNEL_NUMELEM) {
channelDesc[custom.Servo8 - 1] = QString("Servo8");
}
return channelDesc;
}
@ -93,7 +171,30 @@ void ConfigCustomWidget::registerWidgets(ConfigTaskWidget &parent)
void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData)
{
Q_UNUSED(configData);
configData->custom.Motor1 = 0;
configData->custom.Motor2 = 0;
configData->custom.Motor3 = 0;
configData->custom.Motor4 = 0;
configData->custom.Motor5 = 0;
configData->custom.Motor6 = 0;
configData->custom.Motor7 = 0;
configData->custom.Motor8 = 0;
configData->custom.RevMotor1 = 0;
configData->custom.RevMotor2 = 0;
configData->custom.RevMotor3 = 0;
configData->custom.RevMotor4 = 0;
configData->custom.RevMotor5 = 0;
configData->custom.RevMotor6 = 0;
configData->custom.RevMotor7 = 0;
configData->custom.RevMotor8 = 0;
configData->custom.Servo1 = 0;
configData->custom.Servo2 = 0;
configData->custom.Servo3 = 0;
configData->custom.Servo4 = 0;
configData->custom.Servo5 = 0;
configData->custom.Servo6 = 0;
configData->custom.Servo7 = 0;
configData->custom.Servo8 = 0;
}
/**
@ -108,6 +209,8 @@ void ConfigCustomWidget::refreshWidgetsValues(QString frameType)
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
getChannelDescriptions();
QList<double> curveValues;
getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
@ -162,6 +265,7 @@ void ConfigCustomWidget::refreshWidgetsValues(QString frameType)
}
}
/**
Helper function to
*/
@ -174,6 +278,9 @@ QString ConfigCustomWidget::updateConfigObjectsFromWidgets()
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve());
setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve());
GUIConfigDataUnion configData = getConfigData();
resetActuators(&configData);
// Update the table:
for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) {
QComboBox *q = (QComboBox *)m_aircraft->customMixerTable->cellWidget(0, channel);
@ -181,10 +288,61 @@ QString ConfigCustomWidget::updateConfigObjectsFromWidgets()
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED);
} else if (q->currentText() == "Motor") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
if (configData.custom.Motor1 == 0) {
configData.custom.Motor1 = channel + 1;
} else if (configData.custom.Motor2 == 0) {
configData.custom.Motor2 = channel + 1;
} else if (configData.custom.Motor3 == 0) {
configData.custom.Motor3 = channel + 1;
} else if (configData.custom.Motor4 == 0) {
configData.custom.Motor4 = channel + 1;
} else if (configData.custom.Motor5 == 0) {
configData.custom.Motor5 = channel + 1;
} else if (configData.custom.Motor6 == 0) {
configData.custom.Motor6 = channel + 1;
} else if (configData.custom.Motor7 == 0) {
configData.custom.Motor7 = channel + 1;
} else if (configData.custom.Motor8 == 0) {
configData.custom.Motor8 = channel + 1;
}
} else if (q->currentText() == "ReversableMotor") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR);
if (configData.custom.RevMotor1 == 0) {
configData.custom.RevMotor1 = channel + 1;
} else if (configData.custom.RevMotor2 == 0) {
configData.custom.RevMotor2 = channel + 1;
} else if (configData.custom.RevMotor3 == 0) {
configData.custom.RevMotor3 = channel + 1;
} else if (configData.custom.RevMotor4 == 0) {
configData.custom.RevMotor4 = channel + 1;
} else if (configData.custom.RevMotor5 == 0) {
configData.custom.RevMotor5 = channel + 1;
} else if (configData.custom.RevMotor6 == 0) {
configData.custom.RevMotor6 = channel;
} else if (configData.custom.RevMotor7 == 0) {
configData.custom.RevMotor7 = channel;
} else if (configData.custom.RevMotor8 == 0) {
configData.custom.RevMotor8 = channel;
}
} else if (q->currentText() == "Servo") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
if (configData.custom.Servo1 == 0) {
configData.custom.Servo1 = channel + 1;
} else if (configData.custom.Servo2 == 0) {
configData.custom.Servo2 = channel + 1;
} else if (configData.custom.Servo3 == 0) {
configData.custom.Servo3 = channel + 1;
} else if (configData.custom.Servo4 == 0) {
configData.custom.Servo4 = channel + 1;
} else if (configData.custom.Servo5 == 0) {
configData.custom.Servo5 = channel + 1;
} else if (configData.custom.Servo6 == 0) {
configData.custom.Servo6 = channel + 1;
} else if (configData.custom.Servo7 == 0) {
configData.custom.Servo7 = channel + 1;
} else if (configData.custom.Servo8 == 0) {
configData.custom.Servo8 = channel + 1;
}
} else if (q->currentText() == "CameraRoll") {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL);
} else if (q->currentText() == "CameraPitch") {
@ -215,7 +373,7 @@ QString ConfigCustomWidget::updateConfigObjectsFromWidgets()
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW,
m_aircraft->customMixerTable->item(5, channel)->text().toDouble());
}
setConfigData(configData);
return "Custom";
}

View File

@ -101,12 +101,42 @@ typedef struct {
quint32 padding3; // 128 bits
} __attribute__((packed)) groundGUISettingsStruct;
typedef struct {
uint Motor1 : 4;
uint Motor2 : 4;
uint Motor3 : 4;
uint Motor4 : 4;
uint Motor5 : 4;
uint Motor6 : 4;
uint Motor7 : 4;
uint Motor8 : 4; // 32 bits
uint Servo1 : 4;
uint Servo2 : 4;
uint Servo3 : 4;
uint Servo4 : 4;
uint Servo5 : 4;
uint Servo6 : 4;
uint Servo7 : 4;
uint Servo8 : 4; // 64 bits
uint RevMotor1 : 4;
uint RevMotor2 : 4;
uint RevMotor3 : 4;
uint RevMotor4 : 4;
uint RevMotor5 : 4;
uint RevMotor6 : 4;
uint RevMotor7 : 4;
uint RevMotor8 : 4; // 96 bits
quint32 padding; // 128 bits
} __attribute__((packed)) customGUISettingsStruct;
typedef union {
uint UAVObject[4]; // 32 bits * 4
uint UAVObject[5]; // 32 bits * 4
heliGUISettingsStruct heli; // 128 bits
fixedGUISettingsStruct fixedwing;
multiGUISettingsStruct multi;
groundGUISettingsStruct ground;
customGUISettingsStruct custom;
} GUIConfigDataUnion;
class ConfigTaskWidget;