From a78e71c31ae428eebeebc4706c8a1f912b2c451c Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 28 Aug 2014 09:55:55 +0200 Subject: [PATCH 1/9] OP-1134 Populate_new_custom_tab Fixes for files description --- .../plugins/config/cfg_vehicletypes/configcustomwidget.cpp | 4 ++-- .../src/plugins/config/cfg_vehicletypes/configcustomwidget.h | 4 ++-- .../plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp | 4 ++-- .../plugins/config/cfg_vehicletypes/configfixedwingwidget.h | 4 ++-- .../config/cfg_vehicletypes/configgroundvehiclewidget.cpp | 2 +- .../config/cfg_vehicletypes/configgroundvehiclewidget.h | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index 7b2abd7df..a34891388 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -1,13 +1,13 @@ /** ****************************************************************************** * - * @file configmultirotorwidget.cpp + * @file configcustomwidget.cpp * @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup ConfigPlugin Config Plugin * @{ - * @brief ccpm configuration panel + * @brief custom configuration panel *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h index fbef8939e..88392c4e0 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h @@ -1,13 +1,13 @@ /** ****************************************************************************** * - * @file configairframetwidget.h + * @file configcustomwidget.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup ConfigPlugin Config Plugin * @{ - * @brief Airframe configuration panel + * @brief custom configuration panel *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 1a667fa5e..ff9c3e8c3 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -1,13 +1,13 @@ /** ****************************************************************************** * - * @file configfixedwidget.cpp + * @file configfixedwingwidget.cpp * @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup ConfigPlugin Config Plugin * @{ - * @brief ccpm configuration panel + * @brief fixed wing configuration panel *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index f0b786379..c96c534a0 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -1,13 +1,13 @@ /** ****************************************************************************** * - * @file configairframetwidget.h + * @file configfixedwingwidget.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup ConfigPlugin Config Plugin * @{ - * @brief Airframe configuration panel + * @brief fixed wing configuration panel *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 4270fc347..72fc61b33 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -7,7 +7,7 @@ * @{ * @addtogroup ConfigPlugin Config Plugin * @{ - * @brief ccpm configuration panel + * @brief ground vehicle configuration panel *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h index 72d7d0fff..2b9fb9249 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -1,13 +1,13 @@ /** ****************************************************************************** * - * @file configairframetwidget.h + * @file configgroundvehiclewidget.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup ConfigPlugin Config Plugin * @{ - * @brief Airframe configuration panel + * @brief ground vehicle configuration panel *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify From 4e64710c54c9b06c9383d2af04f6e271de9e05ab Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 28 Aug 2014 10:43:21 +0200 Subject: [PATCH 2/9] OP-1134 Populate_new_custom_tab Fix struct size --- .../src/plugins/config/cfg_vehicletypes/vehicleconfig.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index fa85ec133..4a23325bb 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -50,11 +50,10 @@ typedef struct { uint VTOLMotorSSW : 4; uint VTOLMotorWSW : 4; uint VTOLMotorWNW : 4; - uint VTOLMotorNNW : 4; // 32 bits + uint VTOLMotorNNW : 4; // 64 bits uint TRIYaw : 4; - quint32 padding : 28; // 64 bits - quint32 padding1; - quint32 padding2; // 128 bits + quint32 padding : 28; // 96 bits + quint32 padding1; // 128 bits } __attribute__((packed)) multiGUISettingsStruct; typedef struct { From eda53adf9ecac684c23968d6800736c57a090a88 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 28 Aug 2014 13:40:02 +0200 Subject: [PATCH 3/9] OP-1134 Populate_new_custom_tab Sub task OP-790 : Added custom labels in output, up to 8 Motors, revMotors or Servos --- .../cfg_vehicletypes/configcustomwidget.cpp | 162 +++++++++++++++++- .../config/cfg_vehicletypes/vehicleconfig.h | 32 +++- 2 files changed, 191 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index a34891388..f0d97c2f0 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -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(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); + getChannelDescriptions(); + QList 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"; } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 4a23325bb..bc53a0501 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -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; From c00aef04f8b55d3d1ff3f6ab952406bacaf00ac2 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 28 Aug 2014 14:43:52 +0200 Subject: [PATCH 4/9] OP-1134 Populate_new_custom_tab : Always update custom tab from airframe's mixer currently used --- .../config/configvehicletypewidget.cpp | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index b5675cbec..4c9d814e4 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -198,12 +198,27 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) // is not ideal, but there you go. QString frameType = field->getValue().toString(); - int category = frameCategory(frameType); + // Always update custom tab from others airframe settings : debug/learn hardcoded mixers + int category = frameCategory("Custom"); m_aircraft->aircraftType->setCurrentIndex(category); VehicleConfig *vehicleConfig = getVehicleConfigWidget(category); + if (vehicleConfig) { - vehicleConfig->refreshWidgetsValues(frameType); + vehicleConfig->refreshWidgetsValues("Custom"); + } + + // Switch to Airframe currently used + category = frameCategory(frameType); + + if (frameType != "Custom") { + m_aircraft->aircraftType->setCurrentIndex(category); + + VehicleConfig *vehicleConfig = getVehicleConfigWidget(category); + + if (vehicleConfig) { + vehicleConfig->refreshWidgetsValues(frameType); + } } updateFeedForwardUI(); @@ -252,7 +267,8 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); - // TODO call refreshWidgetsValues() to reflect actual saved values ? + // call refreshWidgetsValues() to reflect actual saved values ? + callrefreshWidgetsValues(); updateFeedForwardUI(); } From b8913209dc1738b3927c5cfcb2ee446acd104ee4 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 28 Aug 2014 14:47:37 +0200 Subject: [PATCH 5/9] OP-1134_Populate_new_custom_tab : Typo, bad cleannup --- .../openpilotgcs/src/plugins/config/configvehicletypewidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 4c9d814e4..24e1f3172 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -268,7 +268,7 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); // call refreshWidgetsValues() to reflect actual saved values ? - callrefreshWidgetsValues(); + refreshWidgetsValues(); updateFeedForwardUI(); } From 465f6dc701899fa6b2629cba7857f5da3e15978b Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 28 Aug 2014 15:59:32 +0200 Subject: [PATCH 6/9] OP-1134 Populate_new_custom_tab Protect current mixer table : Changes on Custom tab can't be saved until frameType is set to Custom. --- .../cfg_vehicletypes/configcustomwidget.cpp | 202 +++++++++--------- 1 file changed, 106 insertions(+), 96 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index f0d97c2f0..9821ed2c9 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -271,109 +271,119 @@ void ConfigCustomWidget::refreshWidgetsValues(QString frameType) */ QString ConfigCustomWidget::updateConfigObjectsFromWidgets() { - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - Q_ASSERT(mixer); + Q_ASSERT(system); - setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve()); - setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve()); + QPointer field = system->getField(QString("AirframeType")); - GUIConfigDataUnion configData = getConfigData(); - resetActuators(&configData); + // Do not allow changes until AirframeType == Custom + // If user want to save custom mixer : first set AirframeType to 'Custom' without changes and next modify. + if (field->getValue().toString() == "Custom") { + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - // Update the table: - for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) { - QComboBox *q = (QComboBox *)m_aircraft->customMixerTable->cellWidget(0, channel); - if (q->currentText() == "Disabled") { - 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; + Q_ASSERT(mixer); + + 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); + if (q->currentText() == "Disabled") { + 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") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH); + } else if (q->currentText() == "CameraYaw") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW); + } else if (q->currentText() == "Accessory0") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0); + } else if (q->currentText() == "Accessory1") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1); + } else if (q->currentText() == "Accessory2") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2); + } else if (q->currentText() == "Accessory3") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3); + } else if (q->currentText() == "Accessory4") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4); + } else if (q->currentText() == "Accessory5") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5); } - } 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") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH); - } else if (q->currentText() == "CameraYaw") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW); - } else if (q->currentText() == "Accessory0") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0); - } else if (q->currentText() == "Accessory1") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1); - } else if (q->currentText() == "Accessory2") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2); - } else if (q->currentText() == "Accessory3") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3); - } else if (q->currentText() == "Accessory4") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4); - } else if (q->currentText() == "Accessory5") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, + m_aircraft->customMixerTable->item(1, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, + m_aircraft->customMixerTable->item(2, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, + m_aircraft->customMixerTable->item(3, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, + m_aircraft->customMixerTable->item(4, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, + m_aircraft->customMixerTable->item(5, channel)->text().toDouble()); } - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, - m_aircraft->customMixerTable->item(1, channel)->text().toDouble()); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, - m_aircraft->customMixerTable->item(2, channel)->text().toDouble()); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, - m_aircraft->customMixerTable->item(3, channel)->text().toDouble()); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, - m_aircraft->customMixerTable->item(4, channel)->text().toDouble()); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, - m_aircraft->customMixerTable->item(5, channel)->text().toDouble()); + setConfigData(configData); } - setConfigData(configData); return "Custom"; } From 944e6882c5e63c0e028cc1ef978f177ebb8410ea Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 28 Aug 2014 20:18:54 +0200 Subject: [PATCH 7/9] OP-1134 Populate_new_custom_tab : Removed question mark --- .../openpilotgcs/src/plugins/config/configvehicletypewidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 24e1f3172..6bb6f6b98 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -267,7 +267,7 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); - // call refreshWidgetsValues() to reflect actual saved values ? + // call refreshWidgetsValues() to reflect actual saved values refreshWidgetsValues(); updateFeedForwardUI(); } From 485600ab5dc74bc580503496c21d9e312ab24465 Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 28 Aug 2014 20:25:22 +0200 Subject: [PATCH 8/9] OP-1134 Populate_new_custom_tab : Fix comment --- .../src/plugins/config/cfg_vehicletypes/vehicleconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index bc53a0501..26e4963bd 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -131,7 +131,7 @@ typedef struct { typedef union { - uint UAVObject[5]; // 32 bits * 4 + uint UAVObject[5]; // 32 bits * 5 heliGUISettingsStruct heli; // 128 bits fixedGUISettingsStruct fixedwing; multiGUISettingsStruct multi; From d5c8e9a51ee0d1090d177e38eb40f8d93b52a2ae Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Thu, 28 Aug 2014 22:30:30 +0200 Subject: [PATCH 9/9] OP-1134 Populate_new_custom_tab Lock Custom mixer table until frameType is saved on board, next edit. --- .../src/plugins/config/airframe_custom.ui | 6 ++++++ .../config/cfg_vehicletypes/configcustomwidget.cpp | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/config/airframe_custom.ui b/ground/openpilotgcs/src/plugins/config/airframe_custom.ui index 189356db1..b9fe945fd 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_custom.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_custom.ui @@ -138,6 +138,12 @@ 12 + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::NoSelection + 50 diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index 9821ed2c9..93a9e9da6 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -130,6 +130,7 @@ ConfigCustomWidget::ConfigCustomWidget(QWidget *parent) : VehicleConfig(parent), m_aircraft(new Ui_CustomConfigWidget()) { m_aircraft->setupUi(this); + m_aircraft->customMixerTable->setEditTriggers(QAbstractItemView::NoEditTriggers); // Put combo boxes in line one of the custom mixer table: UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); @@ -206,6 +207,18 @@ void ConfigCustomWidget::refreshWidgetsValues(QString frameType) setupUI(frameType); + UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); + Q_ASSERT(system); + QPointer field = system->getField(QString("AirframeType")); + + // Do not allow table edit until AirframeType == Custom + // First save set AirframeType to 'Custom' and next modify. + if (field->getValue().toString() != "Custom") { + m_aircraft->customMixerTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + } else { + m_aircraft->customMixerTable->setEditTriggers(QAbstractItemView::AllEditTriggers); + } + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer);