QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AxisMonitor.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3
4import QGroundControl
5import QGroundControl.Controls
6
7Item {
8 property int axisValue: 0
9 property int deadbandValue: 0
10 property bool narrowIndicator: false
11 property color deadbandColor: "#8c161a"
12 property bool mapped: false
13 property bool reversed: false
14
15 property color __barColor: qgcPal.windowShade
16
17 // Bar
18 Rectangle {
19 id: bar
20 anchors.verticalCenter: parent.verticalCenter
21 width: parent.width
22 height: parent.height / 2
23 color: __barColor
24 }
25
26 // Deadband
27 Rectangle {
28 id: deadbandBar
29 anchors.verticalCenter: parent.verticalCenter
30 x: _deadbandPosition
31 width: _deadbandWidth
32 height: parent.height / 2
33 color: deadbandColor
34 visible: controller.deadbandToggle
35
36 property real _percentDeadband: ((2 * deadbandValue) / (32768.0 * 2))
37 property real _deadbandWidth: parent.width * _percentDeadband
38 property real _deadbandPosition: (parent.width - _deadbandWidth) / 2
39 }
40
41 // Center point
42 Rectangle {
43 anchors.horizontalCenter: parent.horizontalCenter
44 width: ScreenTools.defaultFontPixelWidth / 2
45 height: parent.height
46 color: qgcPal.window
47 }
48
49 // Indicator
50 Rectangle {
51 anchors.verticalCenter: parent.verticalCenter
52 width: parent.narrowIndicator ? height/6 : height
53 height: parent.height * 0.75
54 x: (reversed ? (parent.width - _indicatorPosition) : _indicatorPosition) - (width / 2)
55 radius: width / 2
56 color: qgcPal.text
57 visible: mapped
58
59 property real _percentAxisValue: ((axisValue + 32768.0) / (32768.0 * 2))
60 property real _indicatorPosition: parent.width * _percentAxisValue
61 }
62
63 QGCLabel {
64 anchors.fill: parent
65 horizontalAlignment: Text.AlignHCenter
66 verticalAlignment: Text.AlignVCenter
67 text: qsTr("Not Mapped")
68 visible: !mapped
69 }
70
71 ColorAnimation {
72 id: barAnimation
73 target: bar
74 property: "color"
75 from: "yellow"
76 to: __barColor
77 duration: 1500
78 }
79
80 // Axis value debugger
81 /*
82 QGCLabel {
83 anchors.fill: parent
84 text: axisValue
85 }
86 */
87
88}