QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RemoteControlChannelMonitor.qml
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 *
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
7 *
8 ****************************************************************************/
9
10
11import QtQuick
12import QtQuick.Controls
13import QtQuick.Dialogs
14import QtQuick.Layouts
15
16import QGroundControl
17import QGroundControl.Controls
18import QGroundControl.FactControls
19
20/// Generic version of Channel Monitor which should work with both RC Transmitters and Joysticks
21/// Used to display raw channel values
22GridLayout {
23 required property int channelCount
24 required property int channelValueMin
25 required property int channelValueMax
26
27 property bool twoColumn: false
28
29 /// Should be called by consumers whenever a raw channel value changes
30 function rawChannelValueChanged(channel, channelValue) {
31 if (channelMonitorRepeater.itemAt(channel)) {
32 let channelValueDisplayItem = channelMonitorRepeater.itemAt(channel)._channelValueDisplayLoader.item
33 let filteredChannelValue = Math.min(Math.max(channelValue, channelValueMin), channelValueMax)
34 channelValueDisplayItem.channelValue = filteredChannelValue
35 }
36 }
37
38 id: control
39 columns: control.twoColumn ? 2 : 1
40 columnSpacing: ScreenTools.defaultFontPixelWidth / 2
41 rowSpacing: 0
42
43 QGCPalette { id: qgcPal; colorGroupEnabled: control.enabled }
44
45 QGCLabel {
46 Layout.columnSpan: parent.columns
47 text: qsTr("Raw Channel Monitor")
48 }
49
50 Repeater {
51 id: channelMonitorRepeater
52 model: channelCount
53
54 RowLayout {
55 Layout.fillWidth: true
56 spacing: ScreenTools.defaultFontPixelWidth / 2
57
58 property var _channelValueDisplayLoader: channelValueDisplayLoader
59
60 QGCLabel {
61 text: index + 1
62 }
63
64 Loader {
65 id: channelValueDisplayLoader
66 Layout.fillWidth: true
67 sourceComponent: RemoteControlChannelValueDisplay {
68 mode: RemoteControlChannelValueDisplay.RawValue
69 channelValueMin: control.channelValueMin
70 channelValueMax: control.channelValueMax
71 }
72 }
73 }
74 }
75}