QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RCChannelMonitor.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4import QtQuick.Layouts
5
6import QGroundControl
7import QGroundControl.Controls
8import QGroundControl.FactControls
9
10Item {
11 id: _root
12 height: monitorColumn.height
13
14 property bool twoColumn: false
15
16 readonly property int _pwmMin: 800
17 readonly property int _pwmMax: 2200
18 readonly property int _pwmRange: _pwmMax - _pwmMin
19
20 RCChannelMonitorController {
21 id: controller
22 }
23
24 // Live channel monitor control component
25 Component {
26 id: channelMonitorDisplayComponent
27
28 Item {
29 height: ScreenTools.defaultFontPixelHeight
30
31 property int rcValue: 1500
32
33 property int __lastRcValue: 1500
34 readonly property int __rcValueMaxJitter: 2
35 property color __barColor: qgcPal.windowShade
36
37 // Bar
38 Rectangle {
39 id: bar
40 anchors.verticalCenter: parent.verticalCenter
41 width: parent.width
42 height: parent.height / 2
43 color: __barColor
44 }
45
46 // Center point
47 Rectangle {
48 anchors.horizontalCenter: parent.horizontalCenter
49 width: ScreenTools.defaultFontPixelWidth / 2
50 height: parent.height
51 color: qgcPal.window
52 }
53
54 // Indicator
55 Rectangle {
56 anchors.verticalCenter: parent.verticalCenter
57 width: parent.height * 0.75
58 height: width
59 x: (((reversed ? _pwmMax - rcValue : rcValue - _pwmMin) / _pwmRange) * parent.width) - (width / 2)
60 radius: width / 2
61 color: qgcPal.text
62 visible: mapped
63 }
64
65 QGCLabel {
66 anchors.fill: parent
67 horizontalAlignment: Text.AlignHCenter
68 verticalAlignment: Text.AlignVCenter
69 text: qsTr("Not Mapped")
70 visible: !mapped
71 }
72
73 ColorAnimation {
74 id: barAnimation
75 target: bar
76 property: "color"
77 from: "yellow"
78 to: __barColor
79 duration: 1500
80 }
81 }
82 } // Component - channelMonitorDisplayComponent
83
84 GridLayout {
85 id: monitorColumn
86 width: parent.width
87 columns: twoColumn ? 2 : 1
88
89 QGCLabel {
90 Layout.columnSpan: parent.columns
91 text: qsTr("Channel Monitor")
92 }
93
94 Connections {
95 target: controller
96
97 function onChannelValueChanged(channel, rcValue) {
98 if (channelMonitorRepeater.itemAt(channel)) {
99 channelMonitorRepeater.itemAt(channel).loader.item.rcValue = rcValue
100 }
101 }
102 }
103
104 Repeater {
105 id: channelMonitorRepeater
106 model: controller.channelCount
107
108 RowLayout {
109 // Need this to get to loader from Connections above
110 property Item loader: theLoader
111
112 QGCLabel {
113 id: channelLabel
114 text: modelData + 1
115 }
116
117 Loader {
118 id: theLoader
119 Layout.fillWidth: true
120 //height: ScreenTools.defaultFontPixelHeight
121 //width: parent.width - anchors.leftMargin - ScreenTools.defaultFontPixelWidth
122 sourceComponent: channelMonitorDisplayComponent
123
124 property bool mapped: true
125 readonly property bool reversed: false
126 }
127 }
128 }
129 }
130}