diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index e5338ebe11a7578c39d5ce471b37a4e4c3faa4a2..335ffafdd78aba9a62af8c05e56108bd4627f995 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 f41031c792a6c53abe6abfd324d6affb4302a47f..72c5470f0aaaa92c97ab5b6e69d1199fd169256a 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 5587de26967ffe0db895573360df42c3030044d7..2e73596484b7e889c33a442f26b978ddda24919e 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 2316d6ed93d97058a215ae5197540867e0c9f030..5b1db7c17c60aa643b40aa47f4d011e1e5f73676 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 b16bfb2078d00f657282ed640d0e11898ce1ce30..c4f5e814702ab97729465300d01b3a93e3c64938 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 {