From 5cbe79b75ed6fa51f54fa0ca5b1c8a00427c2696 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Sat, 26 May 2018 09:11:56 -0700 Subject: [PATCH] Allow both PX4 and APM specific optical flow flashing --- src/VehicleSetup/FirmwareUpgrade.qml | 46 +++++++++++++++---- src/VehicleSetup/FirmwareUpgradeController.cc | 4 +- src/VehicleSetup/FirmwareUpgradeController.h | 3 +- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/VehicleSetup/FirmwareUpgrade.qml b/src/VehicleSetup/FirmwareUpgrade.qml index 4633168aa..cb0ee3009 100644 --- a/src/VehicleSetup/FirmwareUpgrade.qml +++ b/src/VehicleSetup/FirmwareUpgrade.qml @@ -170,16 +170,20 @@ SetupPage { if (_singleFirmwareMode) { controller.flashSingleFirmwareMode(controller.selectedFirmwareType) } else { - var stack = apmFlightStack.checked ? FirmwareUpgradeController.AutoPilotStackAPM : FirmwareUpgradeController.AutoPilotStackPX4 - if (px4Flow) { - stack = FirmwareUpgradeController.PX4Flow - } - + var stack var firmwareType = firmwareVersionCombo.model.get(firmwareVersionCombo.currentIndex).firmwareType var vehicleType = FirmwareUpgradeController.DefaultVehicleFirmware - if (apmFlightStack.checked) { - vehicleType = controller.vehicleTypeFromVersionIndex(vehicleTypeSelectionCombo.currentIndex) + + if (px4Flow) { + stack = px4FlowTypeSelectionCombo.model.get(px4FlowTypeSelectionCombo.currentIndex).stackType + vehicleType = FirmwareUpgradeController.DefaultVehicleFirmware + } else { + stack = apmFlightStack.checked ? FirmwareUpgradeController.AutoPilotStackAPM : FirmwareUpgradeController.AutoPilotStackPX4 + if (apmFlightStack.checked) { + vehicleType = controller.vehicleTypeFromVersionIndex(vehicleTypeSelectionCombo.currentIndex) + } } + controller.flash(stack, firmwareType, vehicleType) } } @@ -214,6 +218,19 @@ SetupPage { } } + ListModel { + id: px4FlowFirmwareList + + ListElement { + text: qsTr("PX4 Pro") + stackType: FirmwareUpgradeController.PX4FlowPX4 + } + ListElement { + text: qsTr("ArduPilot") + stackType: FirmwareUpgradeController.PX4FlowAPM + } + } + ListModel { id: px4FlowTypeList @@ -249,7 +266,7 @@ SetupPage { wrapMode: Text.WordWrap text: _singleFirmwareMode ? _singleFirmwareLabel : (px4Flow ? _px4FlowLabel : _pixhawkLabel) - readonly property string _px4FlowLabel: qsTr("Detected PX4 Flow board. You can select from the following firmware:") + readonly property string _px4FlowLabel: qsTr("Detected PX4 Flow board. The firmware you use on the PX4 Flow must match the AutoPilot firmware type you are using on the vehicle:") readonly property string _pixhawkLabel: qsTr("Detected Pixhawk board. You can select from the following flight stacks:") readonly property string _singleFirmwareLabel: qsTr("Press Ok to upgrade your vehicle.") } @@ -301,10 +318,19 @@ SetupPage { id: vehicleTypeSelectionCombo anchors.left: parent.left anchors.right: parent.right - visible: apmFlightStack.checked + visible: !px4Flow && apmFlightStack.checked model: controller.apmAvailableVersions } + QGCComboBox { + id: px4FlowTypeSelectionCombo + anchors.left: parent.left + anchors.right: parent.right + visible: px4Flow + model: px4FlowFirmwareList + currentIndex: _defaultFirmwareIsPX4 ? 0 : 1 + } + Row { width: parent.width spacing: ScreenTools.defaultFontPixelWidth / 2 @@ -349,7 +375,7 @@ SetupPage { anchors.left: parent.left anchors.right: parent.right visible: showFirmwareTypeSelection - model: _singleFirmwareMode ? singleFirmwareModeTypeList: (px4Flow ? px4FlowTypeList : firmwareTypeList) + model: _singleFirmwareMode ? singleFirmwareModeTypeList : (px4Flow ? px4FlowTypeList : firmwareTypeList) currentIndex: controller.selectedFirmwareType onActivated: { diff --git a/src/VehicleSetup/FirmwareUpgradeController.cc b/src/VehicleSetup/FirmwareUpgradeController.cc index 2e42ac11b..4f60f2459 100644 --- a/src/VehicleSetup/FirmwareUpgradeController.cc +++ b/src/VehicleSetup/FirmwareUpgradeController.cc @@ -99,6 +99,7 @@ void FirmwareUpgradeController::flash(AutoPilotStackType_t stackType, FirmwareType_t firmwareType, FirmwareVehicleType_t vehicleType) { + qCDebug(FirmwareUpgradeLog) << "_flash stackType:firmwareType:vehicleType" << stackType << firmwareType << vehicleType; FirmwareIdentifier firmwareId = FirmwareIdentifier(stackType, firmwareType, vehicleType); if (_bootloaderFound) { _getFirmwareFile(firmwareId); @@ -351,7 +352,8 @@ void FirmwareUpgradeController::_initFirmwareHash() /////////////////////////////// px4flow firmwares /////////////////////////////////////// FirmwareToUrlElement_t rgPX4FLowFirmwareArray[] = { - { PX4Flow, StableFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Flow/master/px4flow.px4" }, + { PX4FlowPX4, StableFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Flow/master/px4flow.px4" }, + { PX4FlowAPM, StableFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Flow/master/px4flowAPM.px4" }, }; /////////////////////////////// 3dr radio firmwares /////////////////////////////////////// diff --git a/src/VehicleSetup/FirmwareUpgradeController.h b/src/VehicleSetup/FirmwareUpgradeController.h index 4c48cf2ac..2193636e1 100644 --- a/src/VehicleSetup/FirmwareUpgradeController.h +++ b/src/VehicleSetup/FirmwareUpgradeController.h @@ -40,7 +40,8 @@ public: typedef enum { AutoPilotStackPX4, AutoPilotStackAPM, - PX4Flow, + PX4FlowPX4, + PX4FlowAPM, ThreeDRRadio, SingleFirmwareMode } AutoPilotStackType_t; -- 2.22.0