Skip to content

Commit

Permalink
Allow both PX4 and APM specific optical flow flashing
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLakeFlyer committed May 26, 2018
1 parent 77b6dc5 commit 5cbe79b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
46 changes: 36 additions & 10 deletions src/VehicleSetup/FirmwareUpgrade.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.")
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: {
Expand Down
4 changes: 3 additions & 1 deletion src/VehicleSetup/FirmwareUpgradeController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ///////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion src/VehicleSetup/FirmwareUpgradeController.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class FirmwareUpgradeController : public QObject
typedef enum {
AutoPilotStackPX4,
AutoPilotStackAPM,
PX4Flow,
PX4FlowPX4,
PX4FlowAPM,
ThreeDRRadio,
SingleFirmwareMode
} AutoPilotStackType_t;
Expand Down

0 comments on commit 5cbe79b

Please sign in to comment.