Commit cfd7f998 authored by Don Gagne's avatar Don Gagne

Merge pull request #3223 from DonLakeFlyer/RCChannelMonitor

New RCChannelMonitorControl
parents 4776d22d 7bb04324
...@@ -295,6 +295,7 @@ HEADERS += \ ...@@ -295,6 +295,7 @@ HEADERS += \
src/QmlControls/CoordinateVector.h \ src/QmlControls/CoordinateVector.h \
src/QmlControls/MavlinkQmlSingleton.h \ src/QmlControls/MavlinkQmlSingleton.h \
src/QmlControls/ParameterEditorController.h \ src/QmlControls/ParameterEditorController.h \
src/QmlControls/RCChannelMonitorController.h \
src/QmlControls/ScreenToolsController.h \ src/QmlControls/ScreenToolsController.h \
src/QmlControls/QGCQGeoCoordinate.h \ src/QmlControls/QGCQGeoCoordinate.h \
src/QmlControls/QGroundControlQmlGlobal.h \ src/QmlControls/QGroundControlQmlGlobal.h \
...@@ -438,6 +439,7 @@ SOURCES += \ ...@@ -438,6 +439,7 @@ SOURCES += \
src/QmlControls/AppMessages.cc \ src/QmlControls/AppMessages.cc \
src/QmlControls/CoordinateVector.cc \ src/QmlControls/CoordinateVector.cc \
src/QmlControls/ParameterEditorController.cc \ src/QmlControls/ParameterEditorController.cc \
src/QmlControls/RCChannelMonitorController.cc \
src/QmlControls/ScreenToolsController.cc \ src/QmlControls/ScreenToolsController.cc \
src/QmlControls/QGCQGeoCoordinate.cc \ src/QmlControls/QGCQGeoCoordinate.cc \
src/QmlControls/QGroundControlQmlGlobal.cc \ src/QmlControls/QGroundControlQmlGlobal.cc \
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
<file alias="QGroundControl/Controls/ModeSwitchDisplay.qml">src/QmlControls/ModeSwitchDisplay.qml</file> <file alias="QGroundControl/Controls/ModeSwitchDisplay.qml">src/QmlControls/ModeSwitchDisplay.qml</file>
<file alias="QGroundControl/Controls/ParameterEditor.qml">src/QmlControls/ParameterEditor.qml</file> <file alias="QGroundControl/Controls/ParameterEditor.qml">src/QmlControls/ParameterEditor.qml</file>
<file alias="QGroundControl/Controls/ParameterEditorDialog.qml">src/QmlControls/ParameterEditorDialog.qml</file> <file alias="QGroundControl/Controls/ParameterEditorDialog.qml">src/QmlControls/ParameterEditorDialog.qml</file>
<file alias="QGroundControl/Controls/RCChannelMonitor.qml">src/QmlControls/RCChannelMonitor.qml</file>
<file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file> <file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file>
<file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file> <file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file>
<file alias="QGroundControl/Controls/QGCColoredImage.qml">src/QmlControls/QGCColoredImage.qml</file> <file alias="QGroundControl/Controls/QGCColoredImage.qml">src/QmlControls/QGCColoredImage.qml</file>
......
...@@ -532,53 +532,9 @@ QGCView { ...@@ -532,53 +532,9 @@ QGCView {
source: controller.imageHelp source: controller.imageHelp
} }
// Channel monitor RCChannelMonitor {
Column {
width: parent.width width: parent.width
spacing: 5 }
QGCLabel { text: qsTr("Channel Monitor") }
Connections {
target: controller
onChannelRCValueChanged: {
if (channelMonitorRepeater.itemAt(channel)) {
channelMonitorRepeater.itemAt(channel).loader.item.rcValue = rcValue
}
}
}
Repeater {
id: channelMonitorRepeater
model: controller.channelCount
width: parent.width
Row {
spacing: 5
// Need this to get to loader from Connections above
property Item loader: theLoader
QGCLabel {
id: channelLabel
text: modelData + 1
}
Loader {
id: theLoader
anchors.verticalCenter: channelLabel.verticalCenter
height: qgcView.defaultTextHeight
width: 200
sourceComponent: channelMonitorDisplayComponent
property real defaultTextWidth: qgcView.defaultTextWidth
property bool mapped: true
readonly property bool reversed: false
}
}
}
} // Column - Channel Monitor
} // Column - Right Column } // Column - Right Column
} // QGCFlickable } // QGCFlickable
} // QGCViewPanel } // QGCViewPanel
......
...@@ -53,11 +53,11 @@ Item { ...@@ -53,11 +53,11 @@ Item {
QGCFlickable { QGCFlickable {
anchors.fill: parent anchors.fill: parent
clip: true clip: true
contentWidth: contentColumn.width contentWidth: column2.x + column2.width
contentHeight: contentColumn.height contentHeight: Math.max(column1.height, column2.height)
Column { Column {
id: contentColumn id: column1
spacing: _margins spacing: _margins
Row { Row {
...@@ -131,7 +131,8 @@ Item { ...@@ -131,7 +131,8 @@ Item {
} // Column - Flight mode settings } // Column - Flight mode settings
Column { Column {
spacing: _margins id: column2
spacing: _margins
QGCLabel { QGCLabel {
text: qsTr("Switch Settings") text: qsTr("Switch Settings")
...@@ -139,6 +140,7 @@ Item { ...@@ -139,6 +140,7 @@ Item {
} }
Rectangle { Rectangle {
id: switchSettingsRect
width: switchSettingsColumn.width + (_margins * 2) width: switchSettingsColumn.width + (_margins * 2)
height: switchSettingsColumn.height + ScreenTools.defaultFontPixelHeight height: switchSettingsColumn.height + ScreenTools.defaultFontPixelHeight
color: qgcPal.windowShade color: qgcPal.windowShade
...@@ -174,6 +176,10 @@ Item { ...@@ -174,6 +176,10 @@ Item {
} // Repeater } // Repeater
} // Column } // Column
} // Rectangle } // Rectangle
RCChannelMonitor {
width: switchSettingsRect.width
}
} // Column - Switch settings } // Column - Switch settings
} // Row - Settings } // Row - Settings
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#include "ESP8266ComponentController.h" #include "ESP8266ComponentController.h"
#include "ScreenToolsController.h" #include "ScreenToolsController.h"
#include "QGCMobileFileDialogController.h" #include "QGCMobileFileDialogController.h"
#include "RCChannelMonitorController.h"
#include "AutoPilotPlugin.h" #include "AutoPilotPlugin.h"
#include "VehicleComponent.h" #include "VehicleComponent.h"
#include "FirmwarePluginManager.h" #include "FirmwarePluginManager.h"
...@@ -457,6 +458,7 @@ void QGCApplication::_initCommon(void) ...@@ -457,6 +458,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<FlightDisplayViewController> ("QGroundControl.Controllers", 1, 0, "FlightDisplayViewController"); qmlRegisterType<FlightDisplayViewController> ("QGroundControl.Controllers", 1, 0, "FlightDisplayViewController");
qmlRegisterType<ValuesWidgetController> ("QGroundControl.Controllers", 1, 0, "ValuesWidgetController"); qmlRegisterType<ValuesWidgetController> ("QGroundControl.Controllers", 1, 0, "ValuesWidgetController");
qmlRegisterType<QGCMobileFileDialogController> ("QGroundControl.Controllers", 1, 0, "QGCMobileFileDialogController"); qmlRegisterType<QGCMobileFileDialogController> ("QGroundControl.Controllers", 1, 0, "QGCMobileFileDialogController");
qmlRegisterType<RCChannelMonitorController> ("QGroundControl.Controllers", 1, 0, "RCChannelMonitorController");
#ifndef __mobile__ #ifndef __mobile__
qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController"); qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
......
...@@ -15,6 +15,7 @@ MissionItemStatus 1.0 MissionItemStatus.qml ...@@ -15,6 +15,7 @@ MissionItemStatus 1.0 MissionItemStatus.qml
ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml
ParameterEditor 1.0 ParameterEditor.qml ParameterEditor 1.0 ParameterEditor.qml
ParameterEditorDialog 1.0 ParameterEditorDialog.qml ParameterEditorDialog 1.0 ParameterEditorDialog.qml
RCChannelMonitor 1.0 RCChannelMonitor.qml
QGCButton 1.0 QGCButton.qml QGCButton 1.0 QGCButton.qml
QGCCheckBox 1.0 QGCCheckBox.qml QGCCheckBox 1.0 QGCCheckBox.qml
QGCColoredImage 1.0 QGCColoredImage.qml QGCColoredImage 1.0 QGCColoredImage.qml
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
import QtQuick 2.5
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QGroundControl 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0
FactPanel {
id: _root
height: monitorColumn.height
QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled }
RCChannelMonitorController {
id: controller
factPanel: _root
}
// Live channel monitor control component
Component {
id: channelMonitorDisplayComponent
Item {
property int rcValue: 1500
property int __lastRcValue: 1500
readonly property int __rcValueMaxJitter: 2
property color __barColor: qgcPal.windowShade
// Bar
Rectangle {
id: bar
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: parent.height / 2
color: __barColor
}
// Center point
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
width: ScreenTools.defaultTextWidth / 2
height: parent.height
color: qgcPal.window
}
// Indicator
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: parent.height * 0.75
height: width
x: ((Math.abs((rcValue - 1000) - (reversed ? 1000 : 0)) / 1000) * parent.width) - (width / 2)
radius: width / 2
color: qgcPal.text
visible: mapped
}
QGCLabel {
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: "Not Mapped"
visible: !mapped
}
ColorAnimation {
id: barAnimation
target: bar
property: "color"
from: "yellow"
to: __barColor
duration: 1500
}
}
} // Component - channelMonitorDisplayComponent
Column {
id: monitorColumn
width: parent.width
spacing: 5
QGCLabel { text: "Channel Monitor" }
Connections {
target: controller
onChannelRCValueChanged: {
if (channelMonitorRepeater.itemAt(channel)) {
channelMonitorRepeater.itemAt(channel).loader.item.rcValue = rcValue
}
}
}
Repeater {
id: channelMonitorRepeater
model: controller.channelCount
width: parent.width
Row {
spacing: 5
// Need this to get to loader from Connections above
property Item loader: theLoader
QGCLabel {
id: channelLabel
text: modelData + 1
}
Loader {
id: theLoader
anchors.verticalCenter: channelLabel.verticalCenter
height: qgcView.defaultTextHeight
width: 200
sourceComponent: channelMonitorDisplayComponent
property bool mapped: true
readonly property bool reversed: false
}
}
}
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "RCChannelMonitorController.h"
RCChannelMonitorController::RCChannelMonitorController(void)
: _chanCount(0)
{
connect(_vehicle, &Vehicle::rcChannelsChanged, this, &RCChannelMonitorController::_rcChannelsChanged);
}
void RCChannelMonitorController::_rcChannelsChanged(int channelCount, int pwmValues[Vehicle::cMaxRcChannels])
{
int maxChannel = std::min(channelCount, _chanMax());
for (int channel=0; channel<maxChannel; channel++) {
int channelValue = pwmValues[channel];
if (_chanCount != channelCount) {
_chanCount = channelCount;
emit channelCountChanged(_chanCount);
}
if (channelValue != -1) {
emit channelRCValueChanged(channel, channelValue);
}
}
}
int RCChannelMonitorController::_chanMax(void) const
{
return _vehicle->firmwareType() == MAV_AUTOPILOT_PX4 ? _chanMaxPX4 : _chanMaxAPM;
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef RCChannelMonitorController_H
#define RCChannelMonitorController_H
#include <QTimer>
#include "FactPanelController.h"
#include "UASInterface.h"
#include "QGCLoggingCategory.h"
#include "AutoPilotPlugin.h"
class RCChannelMonitorController : public FactPanelController
{
Q_OBJECT
public:
RCChannelMonitorController(void);
Q_PROPERTY(int channelCount READ channelCount NOTIFY channelCountChanged)
int channelCount(void) { return _chanCount; }
signals:
void channelCountChanged(int channelCount);
void channelRCValueChanged(int channel, int rcValue);
private slots:
void _rcChannelsChanged(int channelCount, int pwmValues[Vehicle::cMaxRcChannels]);
private:
int _chanMax(void) const;
int _chanCount;
static const int _chanMaxPX4 = 18; ///< Maximum number of supported rc channels, PX4 Firmware
static const int _chanMaxAPM = 14; ///< Maximum number of supported rc channels, APM firmware
};
#endif // RCChannelMonitorController_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment