Commit b0e79c0b authored by DonLakeFlyer's avatar DonLakeFlyer

parent eb5e3954
...@@ -41,10 +41,10 @@ Item { ...@@ -41,10 +41,10 @@ Item {
readonly property string boardRotationText: qsTr("If the orientation is in the direction of flight, select ROTATION_NONE.") readonly property string boardRotationText: qsTr("If the orientation is in the direction of flight, select ROTATION_NONE.")
readonly property string compassRotationText: qsTr("If the orientation is in the direction of flight, select ROTATION_NONE.") readonly property string compassRotationText: qsTr("If the orientation is in the direction of flight, select ROTATION_NONE.")
readonly property string compassHelp: qsTr("For Compass calibration you will need to rotate your vehicle through a number of positions.\n\nClick Ok to start calibration.") readonly property string compassHelp: qsTr("For Compass calibration you will need to rotate your vehicle through a number of positions.")
readonly property string gyroHelp: qsTr("For Gyroscope calibration you will need to place your vehicle on a surface and leave it still.\n\nClick Ok to start calibration.") readonly property string gyroHelp: qsTr("For Gyroscope calibration you will need to place your vehicle on a surface and leave it still.")
readonly property string accelHelp: qsTr("For Accelerometer calibration you will need to place your vehicle on all six sides on a perfectly level surface and hold it still in each orientation for a few seconds.\n\nClick Ok to start calibration.") readonly property string accelHelp: qsTr("For Accelerometer calibration you will need to place your vehicle on all six sides on a perfectly level surface and hold it still in each orientation for a few seconds.")
readonly property string levelHelp: qsTr("To level the horizon you need to place the vehicle in its level flight position and press OK.") readonly property string levelHelp: qsTr("To level the horizon you need to place the vehicle in its level flight position and leave still.")
readonly property string airspeedHelp: qsTr("For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor. Do not touch the sensor or obstruct any holes during the calibration.") readonly property string airspeedHelp: qsTr("For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor. Do not touch the sensor or obstruct any holes during the calibration.")
readonly property string statusTextAreaDefaultText: qsTr("Start the individual calibration steps by clicking one of the buttons to the left.") readonly property string statusTextAreaDefaultText: qsTr("Start the individual calibration steps by clicking one of the buttons to the left.")
...@@ -55,7 +55,6 @@ Item { ...@@ -55,7 +55,6 @@ Item {
// Used to pass help text to the preCalibrationDialog dialog // Used to pass help text to the preCalibrationDialog dialog
property string preCalibrationDialogHelp property string preCalibrationDialogHelp
readonly property int rotationColumnWidth: ScreenTools.defaultFontPixelWidth * 30
readonly property var rotations: [ readonly property var rotations: [
"ROTATION_NONE", "ROTATION_NONE",
"ROTATION_YAW_45", "ROTATION_YAW_45",
...@@ -113,6 +112,72 @@ Item { ...@@ -113,6 +112,72 @@ Item {
property bool _sensorsHaveFixedOrientation: QGroundControl.corePlugin.options.sensorsHaveFixedOrientation property bool _sensorsHaveFixedOrientation: QGroundControl.corePlugin.options.sensorsHaveFixedOrientation
property bool _wifiReliableForCalibration: QGroundControl.corePlugin.options.wifiReliableForCalibration property bool _wifiReliableForCalibration: QGroundControl.corePlugin.options.wifiReliableForCalibration
property int _buttonWidth: ScreenTools.defaultFontPixelWidth * 15 property int _buttonWidth: ScreenTools.defaultFontPixelWidth * 15
property string _calMagIdParamFormat: "CAL_MAG#_ID"
property string _calMagRotParamFormat: "CAL_MAG#_ROT"
property bool _allMagsDisabled: controller.parameterExists(-1, "SYS_HAS_MAG") ? controller.getParameterFact(-1, "SYS_HAS_MAG").value === 0 : false
property bool _boardOrientationChangeAllowed: !_sensorsHaveFixedOrientation && setOrientationsDialogShowBoardOrientation
property bool _compassOrientationChangeAllowed: !_sensorsHaveFixedOrientation
property int _arbitrarilyLargeMaxMagIndex: 50
function currentMagParamCount() {
if (_allMagsDisabled) {
return 0
} else {
for (var index=0; index<_arbitrarilyLargeMaxMagIndex; index++) {
var magIdParam = _calMagIdParamFormat.replace("#", index)
if (!controller.parameterExists(-1, magIdParam)) {
return index
}
}
console.warn("SensorSetup.qml:currentMagParamCount internal error")
return -1
}
}
function currentExternalMagCount() {
if (_allMagsDisabled) {
return 0
} else {
var externalMagCount = 0
for (var index=0; index<_arbitrarilyLargeMaxMagIndex; index++) {
var magIdParam = _calMagIdParamFormat.replace("#", index)
if (controller.parameterExists(-1, magIdParam)) {
var calMagIdFact = controller.getParameterFact(-1, magIdParam)
var calMagRotFact = controller.getParameterFact(-1, _calMagRotParamFormat.replace("#", index))
if (calMagIdFact.value > 0 && calMagRotFact.value >= 0) {
externalMagCount++
}
} else {
return externalMagCount
}
}
console.warn("SensorSetup.qml:currentExternalMagCount internal error")
return 0
}
}
function orientationsButtonVisible() {
if (_sensorsHaveFixedOrientation || !showSetOrientations) {
return false
} else if (_boardOrientationChangeAllowed) {
return true
} else if (_compassOrientationChangeAllowed && !_allMagsDisabled) {
for (var index=0; index<_arbitrarilyLargeMaxMagIndex; index++) {
var magIdParam = _calMagIdParamFormat.replace("#", index)
if (controller.parameterExists(-1, magIdParam)) {
var calMagIdFact = controller.parameterExists(-1, magIdParam)
var calMagRotFact = controller.parameterExists(-1, _calMagRotParamFormat.replace("#", index))
if (calMagIdFact.value > 0 && calMagRotFact.value >= 0) {
// Only external compasses can set orientation
return true
}
}
}
return false
} else {
return false
}
}
SensorsComponentController { SensorsComponentController {
id: controller id: controller
...@@ -130,7 +195,9 @@ Item { ...@@ -130,7 +195,9 @@ Item {
onResetStatusTextArea: statusLog.text = statusTextAreaDefaultText onResetStatusTextArea: statusLog.text = statusTextAreaDefaultText
onMagCalComplete: { onMagCalComplete: {
setOrientationsButton.visible = orientationsButtonVisible()
setOrientationsDialogShowBoardOrientation = false setOrientationsDialogShowBoardOrientation = false
setOrientationsDialogShowReboot = true
mainWindow.showComponentDialog(setOrientationsDialogComponent, qsTr("Compass Calibration Complete"), mainWindow.showDialogDefaultWidth, StandardButton.Ok) mainWindow.showComponentDialog(setOrientationsDialogComponent, qsTr("Compass Calibration Complete"), mainWindow.showDialogDefaultWidth, StandardButton.Ok)
} }
...@@ -191,43 +258,49 @@ Item { ...@@ -191,43 +258,49 @@ Item {
anchors.fill: parent anchors.fill: parent
spacing: ScreenTools.defaultFontPixelHeight spacing: ScreenTools.defaultFontPixelHeight
Column { QGCLabel {
width: parent.width width: parent.width
spacing: 5 wrapMode: Text.WordWrap
visible: !_sensorsHaveFixedOrientation text: preCalibrationDialogHelp
}
QGCLabel { QGCLabel {
id: boardRotationHelp id: boardRotationHelp
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
visible: (preCalibrationDialogType != "airspeed") && (preCalibrationDialogType != "gyro") visible: !_sensorsHaveFixedOrientation && (preCalibrationDialogType == "accel" || preCalibrationDialogType == "compass")
text: qsTr("Set autopilot orientation before calibrating.") text: qsTr("Set autopilot orientation before calibrating.")
} }
Column { Column {
width: parent.width
visible: boardRotationHelp.visible visible: boardRotationHelp.visible
QGCLabel { text: qsTr("Autopilot Orientation") }
QGCLabel { text: qsTr("Autopilot Orientation:") }
FactComboBox { FactComboBox {
id: boardRotationCombo sizeToContents: true
width: rotationColumnWidth;
model: rotations model: rotations
fact: sens_board_rot fact: sens_board_rot
} }
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("ROTATION_NONE indicates component points in direction of flight.")
} }
} }
QGCLabel { QGCLabel {
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: preCalibrationDialogHelp text: qsTr("Click Ok to start calibration.")
} }
} }
} }
} }
property bool setOrientationsDialogShowBoardOrientation: true property bool setOrientationsDialogShowBoardOrientation: true
property bool setOrientationsDialogShowReboot: true
Component { Component {
id: setOrientationsDialogComponent id: setOrientationsDialogComponent
...@@ -251,13 +324,13 @@ Item { ...@@ -251,13 +324,13 @@ Item {
QGCLabel { QGCLabel {
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: _sensorsHaveFixedOrientation ? text: qsTr("Reboot the vehicle prior to flight.")
qsTr("Make sure to reboot the vehicle prior to flight.") : visible: setOrientationsDialogShowReboot
qsTr("Set your compass orientations below and the make sure to reboot the vehicle prior to flight.")
} }
QGCButton { QGCButton {
text: qsTr("Reboot Vehicle") text: qsTr("Reboot Vehicle")
visible: setOrientationsDialogShowReboot
onClicked: { onClicked: {
controller.vehicle.rebootVehicle() controller.vehicle.rebootVehicle()
hideDialog() hideDialog()
...@@ -267,104 +340,46 @@ Item { ...@@ -267,104 +340,46 @@ Item {
QGCLabel { QGCLabel {
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: boardRotationText text: qsTr("Adjust orientations as needed.\n\nROTATION_NONE indicates component points in direction of flight.")
visible: !_sensorsHaveFixedOrientation visible: _boardOrientationChangeAllowed || (_compassOrientationChangeAllowed && currentExternalMagCount() !== 0)
}
Column { Component.onCompleted: console.log(_boardOrientationChangeAllowed, _compassOrientationChangeAllowed, currentExternalMagCount())
visible: setOrientationsDialogShowBoardOrientation
QGCLabel {
text: qsTr("Autopilot Orientation:")
} }
FactComboBox {
id: boardRotationCombo
width: rotationColumnWidth;
model: rotations
fact: sens_board_rot
}
}
// Compass 0 rotation
Column { Column {
visible: !_sensorsHaveFixedOrientation visible: _boardOrientationChangeAllowed
Component {
id: compass0ComponentLabel2
QGCLabel { QGCLabel {
text: qsTr("External Compass Orientation:") text: qsTr("Autopilot Orientation")
}
} }
Component {
id: compass0ComponentCombo2
FactComboBox { FactComboBox {
id: compass0RotationCombo sizeToContents: true
width: rotationColumnWidth
model: rotations model: rotations
fact: cal_mag0_rot fact: sens_board_rot
}
}
Loader { sourceComponent: showCompass0Rot ? compass0ComponentLabel2 : null }
Loader { sourceComponent: showCompass0Rot ? compass0ComponentCombo2 : null }
}
// Compass 1 rotation
Column {
visible: !_sensorsHaveFixedOrientation
Component {
id: compass1ComponentLabel2
QGCLabel {
text: qsTr("External Compass 1 Orientation:")
}
}
Component {
id: compass1ComponentCombo2
FactComboBox {
id: compass1RotationCombo
width: rotationColumnWidth
model: rotations
fact: cal_mag1_rot
} }
} }
Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel2 : null } Repeater {
Loader { sourceComponent: showCompass1Rot ? compass1ComponentCombo2 : null } model: _compassOrientationChangeAllowed ? currentMagParamCount() : 0
}
// Compass 2 rotation
Column { Column {
visible: !_sensorsHaveFixedOrientation // id > = signals compass available, rot < 0 signals internal compass
spacing: ScreenTools.defaultFontPixelWidth visible: calMagIdFact.value > 0 && calMagRotFact.value >= 0
Component { property Fact calMagIdFact: controller.getParameterFact(-1, _calMagIdParamFormat.replace("#", index))
id: compass2ComponentLabel2 property Fact calMagRotFact: controller.getParameterFact(-1, _calMagRotParamFormat.replace("#", index))
QGCLabel { QGCLabel {
text: qsTr("Compass 2 Orientation") text: qsTr("Mag %1 Orientation").arg(index)
}
} }
Component {
id: compass2ComponentCombo2
FactComboBox { FactComboBox {
id: compass1RotationCombo sizeToContents: true
width: rotationColumnWidth
model: rotations model: rotations
fact: cal_mag2_rot fact: parent.calMagRotFact
} }
} }
Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel2 : null }
Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo2 : null }
} }
} // Column } // Column
} // QGCFlickable } // QGCFlickable
...@@ -383,12 +398,11 @@ Item { ...@@ -383,12 +398,11 @@ Item {
spacing: ScreenTools.defaultFontPixelHeight / 2 spacing: ScreenTools.defaultFontPixelHeight / 2
IndicatorButton { IndicatorButton {
property bool _hasMag: controller.parameterExists(-1, "SYS_HAS_MAG") ? controller.getParameterFact(-1, "SYS_HAS_MAG").value !== 0 : true
id: compassButton id: compassButton
width: _buttonWidth width: _buttonWidth
text: qsTr("Compass") text: qsTr("Compass")
indicatorGreen: cal_mag0_id.value !== 0 indicatorGreen: cal_mag0_id.value !== 0
visible: _hasMag && QGroundControl.corePlugin.options.showSensorCalibrationCompass && showSensorCalibrationCompass visible: !_allMagsDisabled && QGroundControl.corePlugin.options.showSensorCalibrationCompass && showSensorCalibrationCompass
onClicked: { onClicked: {
preCalibrationDialogType = "compass" preCalibrationDialogType = "compass"
...@@ -478,11 +492,12 @@ Item { ...@@ -478,11 +492,12 @@ Item {
QGCButton { QGCButton {
id: setOrientationsButton id: setOrientationsButton
width: _buttonWidth width: _buttonWidth
text: qsTr("Set Orientations") text: qsTr("Orientations")
visible: !_sensorsHaveFixedOrientation && showSetOrientations visible: orientationsButtonVisible()
onClicked: { onClicked: {
setOrientationsDialogShowBoardOrientation = true setOrientationsDialogShowBoardOrientation = true
setOrientationsDialogShowReboot = false
mainWindow.showComponentDialog(setOrientationsDialogComponent, qsTr("Set Orientations"), mainWindow.showDialogDefaultWidth, StandardButton.Ok) mainWindow.showComponentDialog(setOrientationsDialogComponent, qsTr("Set Orientations"), mainWindow.showDialogDefaultWidth, StandardButton.Ok)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment