@ -27,20 +27,17 @@ QGCView {
@@ -27,20 +27,17 @@ QGCView {
/ / H e l p t e x t w h i c h i s s h o w n b o t h i n t h e s t a t u s t e x t a r e a p r i o r t o p r e s s i n g a c a l b u t t o n a n d i n t h e
/ / p r e - c a l i b r a t i o n d i a l o g .
readonly property string orientationHelp: "If the orientation is in the direction of flight, select None."
readonly property string boardRotationText: "If the autopilot is mounted in flight direction, leave the default value (None)"
readonly property string orientationHelpSet : "If the orientation is in the direction of flight, select None."
readonly property string orientationHelpCal: "Before calibrating make sure orientation settings are correct. " + orientationHelpSet
readonly property string compassRotationText: "If the compass or GPS module is mounted in flight direction, leave the default value (None)"
readonly property string compassHelp: "For Compass calibration you will need to rotate your vehicle through a number of positions. Most users prefer to do this wirelessly with the telemetry link. "
readonly property string compassHelp: "For Compass calibration you will need to rotate your vehicle through a number of positions."
readonly property string gyroHelp: "For Gyroscope calibration you will need to place your vehicle on a surface and leave it still."
readonly property string accelHelp: "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: "To level the horizon you need to place the vehicle in its level flight position and press OK."
readonly property string airspeedHelp: "For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor."
readonly property string statusTextAreaDefaultText: "Start the individual calibration steps by clicking one of the buttons above."
/ / U s e d t o p a s s w h a t t y p e o f c a l i b r a t i o n i s b e i n g p e r f o r m e d t o t h e p r e C a l i b r a t i o n D i a l o g
property string preCalibrationDialogType
readonly property string statusTextAreaDefaultText: "Start the individual calibration steps by clicking one of the buttons to the left."
/ / U s e d t o p a s s h e l p t e x t t o t h e p r e C a l i b r a t i o n D i a l o g d i a l o g
property string preCalibrationDialogHelp
@ -100,6 +97,14 @@ QGCView {
@@ -100,6 +97,14 @@ QGCView {
property bool showCompass2Rot: compass2Id . value > 0 && compass2External && compass2Use
property bool showCompass3Rot: compass3Id . value > 0 && compass3External && compass3Use
readonly property int _calTypeCompass : 1 / / / < C a l i b r a t e c o m p a s s
readonly property int _calTypeAccel : 2 / / / < C a l i b r a t e a c c e l
readonly property int _calTypeSet : 3 / / / < S e t o r i e n t a t i o n s o n l y
property bool _orientationsDialogShowCompass : true
property string _orientationDialogHelp : orientationHelpSet
property int _orientationDialogCalType
function validCompassOffsets ( compassParamPrefix ) {
var ofsX = controller . getParameterFact ( - 1 , compassParamPrefix + "X" )
var ofsY = controller . getParameterFact ( - 1 , compassParamPrefix + "Y" )
@ -107,6 +112,34 @@ QGCView {
@@ -107,6 +112,34 @@ QGCView {
return Math . sqrt ( ofsX . value ^ 2 + ofsY . value ^ 2 + ofsZ . value ^ 2 ) < 600
}
function showOrientationsDialog ( calType ) {
var dialogTitle
var buttons = StandardButton . Ok
_orientationDialogCalType = calType
switch ( calType ) {
case _calTypeCompass :
_orientationsDialogShowCompass = true
_orientationDialogHelp = orientationHelpCal
dialogTitle = qsTr ( "Calibrate Compass" )
buttons |= StandardButton . Cancel
break
case _calTypeAccel :
_orientationsDialogShowCompass = false
_orientationDialogHelp = orientationHelpCal
dialogTitle = qsTr ( "Calibrate Accelerometer" )
buttons |= StandardButton . Cancel
break
case _calTypeSet :
_orientationsDialogShowCompass = true
_orientationDialogHelp = orientationHelpSet
dialogTitle = qsTr ( "SetOrientations" )
break
}
showDialog ( orientationsDialogComponent , dialogTitle , qgcView . showDialogDefaultWidth , buttons )
}
APMSensorsComponentController {
id: controller
factPanel: panel
@ -116,6 +149,7 @@ QGCView {
@@ -116,6 +149,7 @@ QGCView {
accelButton: accelButton
nextButton: nextButton
cancelButton: cancelButton
setOrientationsButton: setOrientationsButton
orientationCalAreaHelpText: orientationCalAreaHelpText
onResetStatusTextArea: statusLog . text = statusTextAreaDefaultText
@ -129,7 +163,7 @@ QGCView {
@@ -129,7 +163,7 @@ QGCView {
}
onCalibrationComplete: {
if ( preCalibrationDialogType == "accel" ) {
if ( _orientationDialogCalType == _calTypeAccel ) {
_postCalibrationDialogText = qsTr ( "Accelerometer calibration complete." )
_postCalibrationDialogParams = [ "INS_ACCSCAL_X" , "INS_ACCSCAL_Y" , "INS_ACCSCAL_Z" ,
"INS_ACC2SCAL_X" , "INS_ACC2SCAL_Y" , "INS_ACC2SCAL_Z" ,
@ -137,7 +171,7 @@ QGCView {
@@ -137,7 +171,7 @@ QGCView {
"INS_GYROFFS_X" , "INS_GYROFFS_Y" , "INS_GYROFFS_Z" ,
"INS_GYR2OFFS_X" , "INS_GYR2OFFS_Y" , "INS_GYR2OFFS_Z" ,
"INS_GYR3OFFS_X" , "INS_GYR3OFFS_Y" , "INS_GYR3OFFS_Z" ]
} else if ( preCalibrationDialogType == "compass" ) {
} else if ( _orientationDialogCalType == _calTypeCompass ) {
_postCalibrationDialogText = qsTr ( "Compass calibration complete. " )
_postCalibrationDialogParams = [ ] ;
if ( compass1Id . value > 0 ) {
@ -180,42 +214,6 @@ QGCView {
@@ -180,42 +214,6 @@ QGCView {
QGCPalette { id: qgcPal ; colorGroupEnabled: panel . enabled }
Component {
id: preCalibrationDialogComponent
QGCViewDialog {
id: preCalibrationDialog
function accept ( ) {
if ( preCalibrationDialogType == "accel" ) {
controller . calibrateAccel ( )
} else if ( preCalibrationDialogType == "compass" ) {
controller . calibrateCompass ( )
}
preCalibrationDialog . hideDialog ( )
}
QGCLabel {
id: label
anchors.left: parent . left
anchors.right: parent . right
wrapMode: Text . WordWrap
text: qsTr ( "Before calibrating make sure orientation settings are correct." )
}
Loader {
id: rotationsLoader
anchors.topMargin: ScreenTools . defaultFontPixelHeight
anchors.top: label . bottom
anchors.left: parent . left
anchors.right: parent . right
sourceComponent: rotationCombosComponent
property bool showCompassRotations: preCalibrationDialogType == "accel" ? false : true
}
}
}
Component {
id: postCalibrationDialogComponent
QGCViewDialog {
@ -260,121 +258,146 @@ QGCView {
@@ -260,121 +258,146 @@ QGCView {
}
Component {
id: rotationCombos Component
id: orientationsDialog Component
Column {
QGCLabel {
font.pointSize: sideBarH1PointSize
text: qsTr ( "Set Orientations" )
}
QGCViewDialog {
id: orientationsDialog
Item {
width: 1
height: ScreenTools . defaultFontPixelHeight
function accept ( ) {
if ( _orientationDialogCalType == _calTypeAccel ) {
controller . calibrateAccel ( )
} else if ( _orientationDialogCalType == _calTypeCompass ) {
controller . calibrateCompass ( )
}
orientationsDialog . hideDialog ( )
}
QGCLabel {
width: parent . width
wrapMode: Text . WordWrap
text: orientationHelp
}
QGCFlickable {
anchors.fill: parent
contentHeight: columnLayout . height
clip: true
Item {
width: 1
height: ScreenTools . defaultFontPixelHeight
}
Column {
id: columnLayout
anchors.margins: ScreenTools . defaultFontPixelWidth
anchors.left: parent . left
anchors.right: parent . right
anchors.top: parent . top
spacing: ScreenTools . defaultFontPixelHeight
/ / B o a r d r o t a t i o n
QGCLabel {
text: qsTr ( "Autopilot Orientation" )
}
QGCLabel {
width: parent . width
wrapMode: Text . WordWrap
text: _orientationDialogHelp
}
FactComboBox {
id: boardRotationCombo
width: parent . width
fact: boardRot
indexModel: false
}
Column {
QGCLabel {
text: qsTr ( "Autopilot Orientation:" )
}
Item {
width: 1
height: ScreenTools . defaultFontPixelHeight
}
FactComboBox {
width: rotationColumnWidth
indexModel: false
fact: boardRot
}
}
/ / C o m p a s s 1 r o t a t i o n
QGCLabel {
text: qsTr ( "Compass 1 Orientation" )
visible: showCompassRotations && showCompass1Rot
}
Column {
visible: _orientationsDialogShowCompass
FactComboBox {
width: parent . width
fact: compass1Rot
indexModel: false
visible: showCompassRotations && showCompass1Rot
}
Component {
id: compass1ComponentLabel
Item {
width: 1
height: ScreenTools . defaultFontPixelHeight
}
QGCLabel {
text: qsTr ( "Compass 1 Orientation:" )
}
}
/ / C o m p a s s 2 r o t a t i o n
QGCLabel {
text: qsTr ( "Compass 2 Orientation" )
visible: showCompassRotations && showCompass2Rot
}
Component {
id: compass1ComponentCombo
FactComboBox {
width: parent . w idth
fact: compass2Rot
indexModel: false
visible: showCompassRotations && showCompass2Rot
}
FactComboBox {
width: rotationColumnWidth
indexModel: false
fact: compass1Rot
}
}
Item {
width: 1
height: ScreenTools . defaultFontPixelHeight
}
Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel : null }
Loader { sourceComponent: showCompass1Rot ? compass1ComponentCombo : null }
}
/ / C o m p a s s 3 r o t a t i o n
QGCLabel {
text: qsTr ( "Compass 3 Orientation" )
visible: showCompassRotations && showCompass3Rot
}
Column {
visible: _orientationsDialogShowCompass
FactComboBox {
width: parent . width
fact: compass3Rot
indexModel: false
visible: showCompassRotations && showCompass3Rot
}
} / / C o l u m n
} / / C o m p o n e n t - R o t a t i o n c o m b o s
Component {
id: compass2ComponentLabel
QGCLabel {
text: qsTr ( "Compass 2 Orientation:" )
}
}
Component {
id: compass2ComponentCombo
FactComboBox {
width: rotationColumnWidth
indexModel: false
fact: compass2Rot
}
}
Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel : null }
Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo : null }
}
Column {
visible: _orientationsDialogShowCompass
Component {
id: compass3ComponentLabel
QGCLabel {
text: qsTr ( "Compass 3 Orientation" )
}
}
Component {
id: compass3ComponentCombo
FactComboBox {
width: rotationColumnWidth
indexModel: false
fact: compass3Rot
}
}
Loader { sourceComponent: showCompass3Rot ? compass3ComponentLabel : null }
Loader { sourceComponent: showCompass3Rot ? compass3ComponentCombo : null }
}
} / / C o l u m n
} / / Q G C F l i c k a b l e
} / / Q G C V i e w D i a l o g
} / / C o m p o n e n t - o r i e n t a t i o n s D i a l o g C o m p o n e n t
QGCViewPanel {
id: panel
anchors.fill: parent
Row {
id: buttonsRow
spacing: ScreenTools . defaultFontPixelWidth
Column {
id: buttonColumn
spacing: ScreenTools . defaultFontPixelHeight / 2
readonly property int buttonWidth: ScreenTools . defaultFontPixelWidth * 15
QGCLabel { text: qsTr ( "Calibrate:" ) ; anchors.baseline: compassButton . baseline }
IndicatorButton {
id: accelButton
width: parent . buttonWidth
text: qsTr ( "Accelerometer" )
indicatorGreen: ! accelCalNeeded
onClicked: {
preCalibrationDialogType = "accel"
preCalibrationDialogHelp = accelHelp
showDialog ( preCalibrationDialogComponent , qsTr ( "Calibrate Accelerometer" ) , qgcView . showDialogDefaultWidth , StandardButton . Cancel | StandardButton . Ok )
}
onClicked: showOrientationsDialog ( _calTypeAccel )
}
IndicatorButton {
@ -387,15 +410,14 @@ QGCView {
@@ -387,15 +410,14 @@ QGCView {
if ( controller . accelSetupNeeded ) {
showMessage ( qsTr ( "Calibrate Compass" ) , qsTr ( "Accelerometer must be calibrated prior to Compass." ) , StandardButton . Ok )
} else {
preCalibrationDialogType = "compass"
preCalibrationDialogHelp = compassHelp
showDialog ( preCalibrationDialogComponent , qsTr ( "Calibrate Compass" ) , qgcView . showDialogDefaultWidth , StandardButton . Cancel | StandardButton . Ok )
showOrientationsDialog ( _calTypeCompass )
}
}
}
QGCButton {
id: nextButton
width: parent . buttonWidth
text: qsTr ( "Next" )
enabled: false
onClicked: controller . nextClicked ( )
@ -403,136 +425,137 @@ QGCView {
@@ -403,136 +425,137 @@ QGCView {
QGCButton {
id: cancelButton
width: parent . buttonWidth
text: qsTr ( "Cancel" )
enabled: false
onClicked: controller . cancelCalibration ( )
}
} / / R o w - C a l b u t t o n s
ProgressBar {
id: progressBar
anchors.topMargin: ScreenTools . defaultFontPixelHeight
anchors.top: buttonsRow . bottom
anchors.left: parent . left
anchors.right: centerPanel . right
}
Item {
id: centerPanel
anchors.topMargin: ScreenTools . defaultFontPixelHeight
anchors.rightMargin: ScreenTools . defaultFontPixelHeight
anchors.top: progressBar . bottom
anchors.bottom: parent . bottom
anchors.left: parent . left
anchors.right: rotationsLoader . left
TextArea {
id: statusTextArea
anchors.fill: parent
readOnly: true
frameVisible: false
text: statusTextAreaDefaultText
QGCButton {
id: setOrientationsButton
width: parent . buttonWidth
text: qsTr ( "Set Orientations" )
onClicked: showOrientationsDialog ( _calTypeSet )
}
} / / C o l u m n - B u t t o n s
style: TextAreaStyle {
textColor: qgcPal . text
backgroundColor: qgcPal . windowShade
}
Column {
anchors.leftMargin: ScreenTools . defaultFontPixelWidth / 2
anchors.left: buttonColumn . right
anchors.right: parent . right
anchors.top: parent . top
anchors.bottom: parent . bottom
ProgressBar {
id: progressBar
anchors.left: parent . left
anchors.right: parent . right
}
Rectangle {
id: orientationCalArea
anchors.fill: parent
visible: controller . showOrientationCalArea
color: qgcPal . windowShade
Item { height: ScreenTools . defaultFontPixelHeight ; width: 10 } / / s p a c e r
QGCLabel {
id: orientationCalAreaHelpText
anchors.margins: ScreenTools . defaultFontPixelWidth
anchors.top: orientationCalArea . top
anchors.left: orientationCalArea . left
width: parent . width
wrapMode: Text . WordWrap
font.pointSize: ScreenTools . mediumFontPointSize
Item {
id: centerPanel
width: parent . width
height: parent . height - y
TextArea {
id: statusTextArea
anchors.fill: parent
readOnly: true
frameVisible: false
text: statusTextAreaDefaultText
style: TextAreaStyle {
textColor: qgcPal . text
backgroundColor: qgcPal . windowShade
}
}
Flow {
anchors.topMargin: ScreenTools . defaultFontPixelWidth
anchors.top: orientationCalAreaHelpText . bottom
anchors.bottom: parent . bottom
anchors.left: parent . left
anchors.right: parent . right
spacing: ScreenTools . defaultFontPixelWidth
property real indicatorWidth: ( width / 3 ) - ( spacing * 2 )
property real indicatorHeight: ( height / 2 ) - spacing
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalDownSideVisible
calValid: controller . orientationCalDownSideDone
calInProgress: controller . orientationCalDownSideInProgress
calInProgressText: controller . orientationCalDownSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalDownSideRotate ? "qrc:///qmlimages/VehicleDownRotate.png" : "qrc:///qmlimages/VehicleDown.png"
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalUpsideDownSideVisible
calValid: controller . orientationCalUpsideDownSideDone
calInProgress: controller . orientationCalUpsideDownSideInProgress
calInProgressText: controller . orientationCalUpsideDownSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalUpsideDownSideRotate ? "qrc:///qmlimages/VehicleUpsideDownRotate.png" : "qrc:///qmlimages/VehicleUpsideDown.png"
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalNoseDownSideVisible
calValid: controller . orientationCalNoseDownSideDone
calInProgress: controller . orientationCalNoseDownSideInProgress
calInProgressText: controller . orientationCalNoseDownSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalNoseDownSideRotate ? "qrc:///qmlimages/VehicleNoseDownRotate.png" : "qrc:///qmlimages/VehicleNoseDown.png"
Rectangle {
id: orientationCalArea
anchors.fill: parent
visible: controller . showOrientationCalArea
color: qgcPal . windowShade
QGCLabel {
id: orientationCalAreaHelpText
anchors.margins: ScreenTools . defaultFontPixelWidth
anchors.top: orientationCalArea . top
anchors.left: orientationCalArea . left
width: parent . width
wrapMode: Text . WordWrap
font.pointSize: ScreenTools . mediumFontPointSize
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalTailDownSideVisible
calValid: controller . orientationCalTailDownSideDone
calInProgress: controller . orientationCalTailDownSideInProgress
calInProgressText: controller . orientationCalTailDownSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalTailDownSideRotate ? "qrc:///qmlimages/VehicleTailDownRotate.png" : "qrc:///qmlimages/VehicleTailDown.png"
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalLeftSideVisible
calValid: controller . orientationCalLeftSideDone
calInProgress: controller . orientationCalLeftSideInProgress
calInProgressText: controller . orientationCalLeftSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalLeftSideRotate ? "qrc:///qmlimages/VehicleLeftRotate.png" : "qrc:///qmlimages/VehicleLeft.png"
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalRightSideVisible
calValid: controller . orientationCalRightSideDone
calInProgress: controller . orientationCalRightSideInProgress
calInProgressText: controller . orientationCalRightSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalRightSideRotate ? "qrc:///qmlimages/VehicleRightRotate.png" : "qrc:///qmlimages/VehicleRight.png"
Flow {
anchors.topMargin: ScreenTools . defaultFontPixelWidth
anchors.top: orientationCalAreaHelpText . bottom
anchors.bottom: parent . bottom
anchors.left: parent . left
anchors.right: parent . right
spacing: ScreenTools . defaultFontPixelWidth
property real indicatorWidth: ( width / 3 ) - ( spacing * 2 )
property real indicatorHeight: ( height / 2 ) - spacing
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalDownSideVisible
calValid: controller . orientationCalDownSideDone
calInProgress: controller . orientationCalDownSideInProgress
calInProgressText: controller . orientationCalDownSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalDownSideRotate ? "qrc:///qmlimages/VehicleDownRotate.png" : "qrc:///qmlimages/VehicleDown.png"
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalUpsideDownSideVisible
calValid: controller . orientationCalUpsideDownSideDone
calInProgress: controller . orientationCalUpsideDownSideInProgress
calInProgressText: controller . orientationCalUpsideDownSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalUpsideDownSideRotate ? "qrc:///qmlimages/VehicleUpsideDownRotate.png" : "qrc:///qmlimages/VehicleUpsideDown.png"
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalNoseDownSideVisible
calValid: controller . orientationCalNoseDownSideDone
calInProgress: controller . orientationCalNoseDownSideInProgress
calInProgressText: controller . orientationCalNoseDownSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalNoseDownSideRotate ? "qrc:///qmlimages/VehicleNoseDownRotate.png" : "qrc:///qmlimages/VehicleNoseDown.png"
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalTailDownSideVisible
calValid: controller . orientationCalTailDownSideDone
calInProgress: controller . orientationCalTailDownSideInProgress
calInProgressText: controller . orientationCalTailDownSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalTailDownSideRotate ? "qrc:///qmlimages/VehicleTailDownRotate.png" : "qrc:///qmlimages/VehicleTailDown.png"
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalLeftSideVisible
calValid: controller . orientationCalLeftSideDone
calInProgress: controller . orientationCalLeftSideInProgress
calInProgressText: controller . orientationCalLeftSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalLeftSideRotate ? "qrc:///qmlimages/VehicleLeftRotate.png" : "qrc:///qmlimages/VehicleLeft.png"
}
VehicleRotationCal {
width: parent . indicatorWidth
height: parent . indicatorHeight
visible: controller . orientationCalRightSideVisible
calValid: controller . orientationCalRightSideDone
calInProgress: controller . orientationCalRightSideInProgress
calInProgressText: controller . orientationCalRightSideRotate ? qsTr ( "Rotate" ) : qsTr ( "Hold Still" )
imageSource: controller . orientationCalRightSideRotate ? "qrc:///qmlimages/VehicleRightRotate.png" : "qrc:///qmlimages/VehicleRight.png"
}
}
}
}
} / / I t e m - C a l d i s p l a y a r e a
Loader {
id: rotationsLoader
anchors.top: centerPanel . top
anchors.bottom: parent . bottom
anchors.right: parent . right
width: rotationColumnWidth
sourceComponent: rotationCombosComponent
property bool showCompassRotations: true
}
} / / I t e m - C a l d i s p l a y a r e a
} / / C o l u m n - c a l d i s p l a y
} / / Q G C V i e w P a n e l
} / / Q G C V i e w