From ebf348135c553495fc3c32aa5951627bc4574a96 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Sat, 27 May 2017 10:34:03 -0700 Subject: [PATCH] Keep track of firmware type during flash/connect --- src/Settings/App.SettingsGroup.json | 6 ++++++ src/Settings/AppSettings.cc | 10 ++++++++++ src/Settings/AppSettings.h | 4 ++++ src/Vehicle/MultiVehicleManager.cc | 2 ++ src/VehicleSetup/FirmwareUpgrade.qml | 25 ++++++++++++++++++++++--- 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index e5338eb..335ffaf 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -136,5 +136,11 @@ "longDescription": "Your personal access token for Esri maps", "type": "string", "defaultValue": "" +}, +{ + "name": "DefaultFirmwareType", + "shortDescription": "Default firmware type for flashing", + "type": "uint32", + "defaultValue": 12 } ] diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index f41031c..72c5470 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -33,6 +33,7 @@ const char* AppSettings::savePathName = "SavePat const char* AppSettings::autoLoadMissionsName = "AutoLoadMissions"; const char* AppSettings::mapboxTokenName = "MapboxToken"; const char* AppSettings::esriTokenName = "EsriToken"; +const char* AppSettings::defaultFirmwareTypeName = "DefaultFirmwareType"; const char* AppSettings::parameterFileExtension = "params"; const char* AppSettings::planFileExtension = "plan"; @@ -67,6 +68,7 @@ AppSettings::AppSettings(QObject* parent) , _autoLoadMissionsFact(NULL) , _mapboxTokenFact(NULL) , _esriTokenFact(NULL) + , _defaultFirmwareTypeFact(NULL) { QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "AppSettings", "Reference only"); @@ -343,3 +345,11 @@ MAV_TYPE AppSettings::offlineEditingVehicleTypeFromVehicleType(MAV_TYPE vehicleT } } +Fact* AppSettings::defaultFirmwareType(void) +{ + if (!_defaultFirmwareTypeFact) { + _defaultFirmwareTypeFact = _createSettingsFact(defaultFirmwareTypeName); + } + + return _defaultFirmwareTypeFact; +} diff --git a/src/Settings/AppSettings.h b/src/Settings/AppSettings.h index 5587de2..2e73596 100644 --- a/src/Settings/AppSettings.h +++ b/src/Settings/AppSettings.h @@ -37,6 +37,7 @@ public: Q_PROPERTY(Fact* autoLoadMissions READ autoLoadMissions CONSTANT) Q_PROPERTY(Fact* mapboxToken READ mapboxToken CONSTANT) Q_PROPERTY(Fact* esriToken READ esriToken CONSTANT) + Q_PROPERTY(Fact* defaultFirmwareType READ defaultFirmwareType CONSTANT) Q_PROPERTY(QString missionSavePath READ missionSavePath NOTIFY savePathsChanged) Q_PROPERTY(QString parameterSavePath READ parameterSavePath NOTIFY savePathsChanged) @@ -67,6 +68,7 @@ public: Fact* autoLoadMissions (void); Fact* mapboxToken (void); Fact* esriToken (void); + Fact* defaultFirmwareType (void); QString missionSavePath (void); QString parameterSavePath (void); @@ -95,6 +97,7 @@ public: static const char* autoLoadMissionsName; static const char* mapboxTokenName; static const char* esriTokenName; + static const char* defaultFirmwareTypeName; // Application wide file extensions static const char* parameterFileExtension; @@ -137,6 +140,7 @@ private: SettingsFact* _autoLoadMissionsFact; SettingsFact* _mapboxTokenFact; SettingsFact* _esriTokenFact; + SettingsFact* _defaultFirmwareTypeFact; }; #endif diff --git a/src/Vehicle/MultiVehicleManager.cc b/src/Vehicle/MultiVehicleManager.cc index 2316d6e..5b1db7c 100644 --- a/src/Vehicle/MultiVehicleManager.cc +++ b/src/Vehicle/MultiVehicleManager.cc @@ -124,6 +124,8 @@ void MultiVehicleManager::_vehicleHeartbeatInfo(LinkInterface* link, int vehicle // Send QGC heartbeat ASAP, this allows PX4 to start accepting commands _sendGCSHeartbeat(); + qgcApp()->toolbox()->settingsManager()->appSettings()->defaultFirmwareType()->setRawValue(vehicleFirmwareType); + emit vehicleAdded(vehicle); if (_vehicles.count() > 1) { diff --git a/src/VehicleSetup/FirmwareUpgrade.qml b/src/VehicleSetup/FirmwareUpgrade.qml index b16bfb2..c4f5e81 100644 --- a/src/VehicleSetup/FirmwareUpgrade.qml +++ b/src/VehicleSetup/FirmwareUpgrade.qml @@ -40,6 +40,12 @@ QGCView { readonly property string qgcUnplugText1: qsTr("All %1 connections to vehicles must be ").arg(QGroundControl.appName) + highlightPrefix + " disconnected " + highlightSuffix + "prior to firmware upgrade." readonly property string qgcUnplugText2: highlightPrefix + "Please unplug your Pixhawk and/or Radio from USB." + highlightSuffix + readonly property int _defaultFimwareTypePX4: 12 + readonly property int _defaultFimwareTypeAPM: 3 + + property var _defaultFirmwareFact: QGroundControl.settingsManager.appSettings.defaultFirmwareType + property bool _defaultFirmwareIsPX4: _defaultFirmwareFact.rawValue == _defaultFimwareTypePX4 + property string firmwareWarningMessage property bool controllerCompleted: false property bool initialBoardSearch: true @@ -247,14 +253,24 @@ QGCView { firmwareVersionCombo.currentIndex = 0 } + Component.onCompleted: { + if (_defaultFirmwareIsPX4) { + px4FlightStack.checked = true + } else { + apmFlightStack.checked = true + } + } + QGCRadioButton { id: px4FlightStack - checked: true exclusiveGroup: firmwareGroup text: qsTr("PX4 Flight Stack ") visible: !_singleFirmwareMode && !px4Flow - onClicked: parent.firmwareVersionChanged(firmwareTypeList) + onClicked: { + _defaultFirmwareFact.rawValue = _defaultFimwareTypePX4 + parent.firmwareVersionChanged(firmwareTypeList) + } } QGCRadioButton { @@ -263,7 +279,10 @@ QGCView { text: qsTr("ArduPilot Flight Stack") visible: !_singleFirmwareMode && !px4Flow - onClicked: parent.firmwareVersionChanged(firmwareTypeList) + onClicked: { + _defaultFirmwareFact.rawValue = _defaultFimwareTypeAPM + parent.firmwareVersionChanged(firmwareTypeList) + } } QGCComboBox {