Browse Source

Joystick UI WIP

QGC4.4
Gus Grubba 6 years ago
parent
commit
c5b75b70da
  1. 1
      qgcresources.qrc
  2. 47
      resources/calibration/joystick/joystick.svg
  3. 80
      src/VehicleSetup/JoystickConfig.qml

1
qgcresources.qrc

@ -56,6 +56,7 @@
<file alias="px4.png">resources/firmware/px4.png</file> <file alias="px4.png">resources/firmware/px4.png</file>
</qresource> </qresource>
<qresource prefix="/res/calibration"> <qresource prefix="/res/calibration">
<file alias="joystick.svg">resources/calibration/joystick/joystick.svg</file>
<file alias="accel_back.png">resources/calibration/accel_back.png</file> <file alias="accel_back.png">resources/calibration/accel_back.png</file>
<file alias="accel_down.png">resources/calibration/accel_down.png</file> <file alias="accel_down.png">resources/calibration/accel_down.png</file>
<file alias="accel_front.png">resources/calibration/accel_front.png</file> <file alias="accel_front.png">resources/calibration/accel_front.png</file>

47
resources/calibration/joystick/joystick.svg

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 288 144" style="enable-background:new 0 0 288 144;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#000000;stroke-width:4;stroke-miterlimit:10;}
.st1{fill:none;stroke:#000000;stroke-width:3;stroke-miterlimit:10;}
.st2{fill:none;stroke:#000000;stroke-miterlimit:10;}
.st3{fill:none;stroke:#000000;stroke-width:2;stroke-miterlimit:10;}
</style>
<circle class="st0" cx="72" cy="86.4" r="36"/>
<circle class="st0" cx="216" cy="86.4" r="36"/>
<circle class="st1" cx="72" cy="28.8" r="10.8"/>
<circle class="st1" cx="216" cy="28.8" r="10.8"/>
<g>
<line class="st2" x1="57.343" y1="28.8" x2="53.059" y2="28.8"/>
<line class="st2" x1="86.657" y1="28.8" x2="90.941" y2="28.8"/>
<line class="st2" x1="86.158" y1="25.006" x2="90.295" y2="23.898"/>
<line class="st2" x1="84.693" y1="21.471" x2="88.403" y2="19.33"/>
<line class="st2" x1="82.364" y1="18.436" x2="85.393" y2="15.407"/>
<line class="st2" x1="79.329" y1="16.107" x2="81.47" y2="12.397"/>
<line class="st2" x1="75.794" y1="14.642" x2="76.902" y2="10.505"/>
<line class="st2" x1="72" y1="14.143" x2="72" y2="9.859"/>
<line class="st2" x1="68.206" y1="14.642" x2="67.098" y2="10.505"/>
<line class="st2" x1="64.671" y1="16.107" x2="62.53" y2="12.397"/>
<line class="st2" x1="61.636" y1="18.436" x2="58.607" y2="15.407"/>
<line class="st2" x1="59.307" y1="21.471" x2="55.597" y2="19.33"/>
<line class="st2" x1="57.842" y1="25.006" x2="53.705" y2="23.898"/>
</g>
<g>
<line class="st2" x1="201.343" y1="28.8" x2="197.059" y2="28.8"/>
<line class="st2" x1="230.657" y1="28.8" x2="234.941" y2="28.8"/>
<line class="st2" x1="230.158" y1="25.006" x2="234.295" y2="23.898"/>
<line class="st2" x1="228.693" y1="21.471" x2="232.403" y2="19.33"/>
<line class="st2" x1="226.364" y1="18.436" x2="229.393" y2="15.407"/>
<line class="st2" x1="223.329" y1="16.107" x2="225.47" y2="12.397"/>
<line class="st2" x1="219.794" y1="14.642" x2="220.902" y2="10.505"/>
<line class="st2" x1="216" y1="14.143" x2="216" y2="9.859"/>
<line class="st2" x1="212.206" y1="14.642" x2="211.098" y2="10.505"/>
<line class="st2" x1="208.671" y1="16.107" x2="206.53" y2="12.397"/>
<line class="st2" x1="205.636" y1="18.436" x2="202.607" y2="15.407"/>
<line class="st2" x1="203.307" y1="21.471" x2="199.597" y2="19.33"/>
<line class="st2" x1="201.842" y1="25.006" x2="197.705" y2="23.898"/>
</g>
<path class="st3" d="M274.39,142.253H13.61c-6.6,0-12-5.4-12-12V13.747c0-6.6,5.4-12,12-12h260.78c6.6,0,12,5.4,12,12v116.505
C286.39,136.853,280.99,142.253,274.39,142.253z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

80
src/VehicleSetup/JoystickConfig.qml

@ -28,6 +28,7 @@ SetupPage {
pageDescription: qsTr("Joystick Setup is used to configure a calibrate joysticks.") pageDescription: qsTr("Joystick Setup is used to configure a calibrate joysticks.")
readonly property real _maxButtons: 64 readonly property real _maxButtons: 64
readonly property real _attitudeLabelWidth: ScreenTools.defaultFontPixelWidth * 12
Connections { Connections {
target: joystickManager target: joystickManager
@ -157,7 +158,7 @@ SetupPage {
anchors.rightMargin: ScreenTools.defaultFontPixelWidth anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left anchors.left: parent.left
anchors.right: rightColumn.left anchors.right: rightColumn.left
spacing: 10 spacing: ScreenTools.defaultFontPixelHeight
// Attitude Controls // Attitude Controls
Column { Column {
@ -172,7 +173,7 @@ SetupPage {
QGCLabel { QGCLabel {
id: rollLabel id: rollLabel
width: ScreenTools.defaultFontPixelWidth * 10 width: _attitudeLabelWidth
text: activeVehicle.sub ? qsTr("Lateral") : qsTr("Roll") text: activeVehicle.sub ? qsTr("Lateral") : qsTr("Roll")
} }
@ -199,7 +200,7 @@ SetupPage {
QGCLabel { QGCLabel {
id: pitchLabel id: pitchLabel
width: ScreenTools.defaultFontPixelWidth * 10 width: _attitudeLabelWidth
text: activeVehicle.sub ? qsTr("Forward") : qsTr("Pitch") text: activeVehicle.sub ? qsTr("Forward") : qsTr("Pitch")
} }
@ -226,7 +227,7 @@ SetupPage {
QGCLabel { QGCLabel {
id: yawLabel id: yawLabel
width: ScreenTools.defaultFontPixelWidth * 10 width: _attitudeLabelWidth
text: qsTr("Yaw") text: qsTr("Yaw")
} }
@ -253,7 +254,7 @@ SetupPage {
QGCLabel { QGCLabel {
id: throttleLabel id: throttleLabel
width: ScreenTools.defaultFontPixelWidth * 10 width: _attitudeLabelWidth
text: qsTr("Throttle") text: qsTr("Throttle")
} }
@ -280,7 +281,7 @@ SetupPage {
QGCLabel { QGCLabel {
id: gimbalPitchLabel id: gimbalPitchLabel
width: ScreenTools.defaultFontPixelWidth * 10 width: _attitudeLabelWidth
text: qsTr("Gimbal Pitch") text: qsTr("Gimbal Pitch")
} }
@ -307,7 +308,7 @@ SetupPage {
QGCLabel { QGCLabel {
id: gimbalYawLabel id: gimbalYawLabel
width: ScreenTools.defaultFontPixelWidth * 10 width: _attitudeLabelWidth
text: qsTr("Gimbal Yaw") text: qsTr("Gimbal Yaw")
} }
@ -334,26 +335,24 @@ SetupPage {
Row { Row {
spacing: 10 spacing: 10
visible: _activeJoystick.requiresCalibration visible: _activeJoystick.requiresCalibration
anchors.horizontalCenter: parent.horizontalCenter
QGCButton { QGCButton {
id: skipButton id: skipButton
text: qsTr("Skip") text: qsTr("Skip")
onClicked: controller.skipButtonClicked() onClicked: controller.skipButtonClicked()
} }
QGCButton { QGCButton {
id: cancelButton id: cancelButton
text: qsTr("Cancel") text: qsTr("Cancel")
onClicked: controller.cancelButtonClicked() onClicked: controller.cancelButtonClicked()
} }
QGCButton { QGCButton {
id: nextButton id: nextButton
primary: true primary: true
text: qsTr("Calibrate") text: qsTr("Calibrate")
onClicked: controller.nextButtonClicked() onClicked: controller.nextButtonClicked()
} }
} // Row - Buttons }
// Status Text // Status Text
QGCLabel { QGCLabel {
@ -412,19 +411,13 @@ SetupPage {
} }
} }
Row {
width: parent.width
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel { QGCLabel {
id: activeJoystickLabel
anchors.baseline: joystickCombo.baseline
text: qsTr("Active joystick:") text: qsTr("Active joystick:")
} }
QGCComboBox { QGCComboBox {
id: joystickCombo id: joystickCombo
width: parent.width - activeJoystickLabel.width - parent.spacing width: parent.width * 0.9
model: joystickManager.joystickNames model: joystickManager.joystickNames
onActivated: joystickManager.activeJoystickName = textAt(index) onActivated: joystickManager.activeJoystickName = textAt(index)
@ -448,7 +441,6 @@ SetupPage {
} }
} }
} }
}
Column { Column {
spacing: ScreenTools.defaultFontPixelHeight / 3 spacing: ScreenTools.defaultFontPixelHeight / 3
@ -494,7 +486,7 @@ SetupPage {
} }
Column { Column {
spacing: ScreenTools.defaultFontPixelHeight / 3 spacing: ScreenTools.defaultFontPixelHeight
QGCLabel { QGCLabel {
id: expoSliderLabel id: expoSliderLabel
@ -502,15 +494,15 @@ SetupPage {
} }
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCSlider { QGCSlider {
id: expoSlider id: expoSlider
width: ScreenTools.defaultFontPixelWidth * 14
minimumValue: 0 minimumValue: 0
maximumValue: 0.75 maximumValue: 0.75
Component.onCompleted: value = -_activeJoystick.exponential
Component.onCompleted: value=-_activeJoystick.exponential onValueChanged: _activeJoystick.exponential = -value
onValueChanged: _activeJoystick.exponential=-value
} }
QGCLabel { QGCLabel {
id: expoSliderIndicator id: expoSliderIndicator
text: expoSlider.value.toFixed(2) text: expoSlider.value.toFixed(2)
@ -761,53 +753,58 @@ SetupPage {
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
width: Math.min(joystickPage.ScreenTools.defaultFontPixelWidth * 35, availableWidth * 0.4) width: Math.min(joystickPage.ScreenTools.defaultFontPixelWidth * 35, availableWidth * 0.4)
spacing: ScreenTools.defaultFontPixelHeight / 2 spacing: ScreenTools.defaultFontPixelHeight
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { QGCLabel {
text: "TX Mode:" text: "TX Mode:"
anchors.verticalCenter: parent.verticalCenter
} }
QGCRadioButton { QGCRadioButton {
text: "1" text: "1"
checked: controller.transmitterMode == 1 checked: controller.transmitterMode == 1
enabled: !controller.calibrating enabled: !controller.calibrating
onClicked: controller.transmitterMode = 1 onClicked: controller.transmitterMode = 1
anchors.verticalCenter: parent.verticalCenter
} }
QGCRadioButton { QGCRadioButton {
text: "2" text: "2"
checked: controller.transmitterMode == 2 checked: controller.transmitterMode == 2
enabled: !controller.calibrating enabled: !controller.calibrating
onClicked: controller.transmitterMode = 2 onClicked: controller.transmitterMode = 2
anchors.verticalCenter: parent.verticalCenter
} }
QGCRadioButton { QGCRadioButton {
text: "3" text: "3"
checked: controller.transmitterMode == 3 checked: controller.transmitterMode == 3
enabled: !controller.calibrating enabled: !controller.calibrating
onClicked: controller.transmitterMode = 3 onClicked: controller.transmitterMode = 3
anchors.verticalCenter: parent.verticalCenter
} }
QGCRadioButton { QGCRadioButton {
text: "4" text: "4"
checked: controller.transmitterMode == 4 checked: controller.transmitterMode == 4
enabled: !controller.calibrating enabled: !controller.calibrating
onClicked: controller.transmitterMode = 4 onClicked: controller.transmitterMode = 4
anchors.verticalCenter: parent.verticalCenter
} }
} }
Image { QGCColoredImage {
width: parent.width width: parent.width * 0.9
height: width * 0.5
sourceSize.height: height
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
smooth: true smooth: true
source: controller.imageHelp source: "/res/calibration/joystick.svg"
anchors.horizontalCenter: parent.horizontalCenter
} }
// Axis monitor // Axis monitor
@ -815,7 +812,10 @@ SetupPage {
width: parent.width width: parent.width
spacing: 5 spacing: 5
QGCLabel { text: qsTr("Axis Monitor") } QGCLabel {
text: qsTr("Axis Monitor")
anchors.horizontalCenter: parent.horizontalCenter
}
Connections { Connections {
target: controller target: controller
@ -840,6 +840,7 @@ SetupPage {
Row { Row {
spacing: 5 spacing: 5
anchors.horizontalCenter: parent.horizontalCenter
// Need this to get to loader from Connections above // Need this to get to loader from Connections above
property Item loader: theLoader property Item loader: theLoader
@ -860,7 +861,6 @@ SetupPage {
property bool mapped: true property bool mapped: true
readonly property bool reversed: false readonly property bool reversed: false
MouseArea { MouseArea {
id: deadbandMouseArea id: deadbandMouseArea
anchors.fill: parent.item anchors.fill: parent.item
@ -897,7 +897,10 @@ SetupPage {
width: parent.width width: parent.width
spacing: ScreenTools.defaultFontPixelHeight spacing: ScreenTools.defaultFontPixelHeight
QGCLabel { text: qsTr("Button Monitor") } QGCLabel {
text: qsTr("Button Monitor")
anchors.horizontalCenter: parent.horizontalCenter
}
Connections { Connections {
target: _activeJoystick target: _activeJoystick
@ -910,19 +913,20 @@ SetupPage {
} }
Flow { Flow {
width: parent.width width: parent.width * 0.9
spacing: -1 spacing: -1
anchors.horizontalCenter: parent.horizontalCenter
Repeater { Repeater {
id: buttonMonitorRepeater id: buttonMonitorRepeater
model: _activeJoystick ? _activeJoystick.totalButtonCount : 0 model: _activeJoystick ? _activeJoystick.totalButtonCount : 0
Rectangle { Rectangle {
width: ScreenTools.defaultFontPixelHeight * 1.2 width: ScreenTools.defaultFontPixelHeight * 1.5
height: width height: width
border.width: 1 border.width: 1
border.color: qgcPal.text border.color: qgcPal.text
color: pressed ? qgcPal.buttonHighlight : qgcPal.button color: pressed ? qgcPal.buttonHighlight : qgcPal.windowShade
property bool pressed property bool pressed

Loading…
Cancel
Save