From 309fbf58f9c2884629764d723f87bfaa6608bc59 Mon Sep 17 00:00:00 2001 From: Michael Carpenter Date: Tue, 4 Jun 2013 12:29:45 -0400 Subject: [PATCH] Addition of new RadioChannel displays for radio calibration --- qgroundcontrol.pro | 2 + src/ui/QGCVehicleConfig.ui | 1714 ++++++++++---------- src/ui/designer/QGCRadioChannelDisplay.cpp | 87 + src/ui/designer/QGCRadioChannelDisplay.h | 35 + 4 files changed, 979 insertions(+), 859 deletions(-) create mode 100644 src/ui/designer/QGCRadioChannelDisplay.cpp create mode 100644 src/ui/designer/QGCRadioChannelDisplay.h diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 72df1adf6f..e023da0e8e 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -384,6 +384,7 @@ HEADERS += src/MG.h \ src/ui/uas/UASQuickViewItemSelect.h \ src/ui/uas/UASQuickViewTextItem.h \ src/ui/uas/UASActionsWidget.h \ + src/ui/designer/QGCRadioChannelDisplay.h \ src/ui/QGCTabbedInfoView.h \ src/ui/UASRawStatusView.h @@ -557,6 +558,7 @@ SOURCES += src/main.cc \ src/ui/uas/UASQuickViewTextItem.cc \ src/ui/uas/UASQuickViewItemSelect.cc \ src/ui/uas/UASActionsWidget.cpp \ + src/ui/designer/QGCRadioChannelDisplay.cpp \ src/ui/QGCTabbedInfoView.cpp \ src/ui/UASRawStatusView.cpp diff --git a/src/ui/QGCVehicleConfig.ui b/src/ui/QGCVehicleConfig.ui index 51603e4af8..7bef1a28b5 100644 --- a/src/ui/QGCVehicleConfig.ui +++ b/src/ui/QGCVehicleConfig.ui @@ -123,614 +123,671 @@ Config - - - 0 - - - - + + + + + 0 + + + + + 9 + 9 + 68 + 16 + + RC Calibration - - - - - - - false - - - false - - + + + + 270 + 410 + 51 + 211 + + + + + + + + + false + + + false + + + + Select transmitter model + + + + + + + + true + + + + Mode 1 + + + + + Mode 2 + + + + + Mode 3 + + + + + Mode 4 + + + + + + + + + + - Select transmitter model + 0000 - - - - - - - true - - + + Qt::AlignCenter + + + + + - Mode 1 + Invert - - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - Mode 2 + Yaw / Rudder - - + + + + - Mode 3 + 0000 - - + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - Mode 4 + Invert - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0000 - - - Qt::AlignCenter - - - - - - - Invert - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Yaw / Rudder - - - - - - - 0000 - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Invert - - - - - - - Invert - - - - - - - 1 - - - 8 - - - - - - - 0000 - - - Qt::AlignCenter - - - - - - - 0000 - - - Qt::AlignCenter - - - - - - - Pitch / Elevator - - - - - - - 0000 - - - Qt::AlignCenter - - - - - - - Aux 2 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 0000 - - - Qt::AlignCenter - - - - - - - Invert - - - - - - - 1 - - - 8 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Throttle - - - - - - - Invert - - - - - - - 1 - - - 8 - - - - - - - 1 - - - 8 - - - - - - - Mode Switch - - - - - - - 0000 - - - Qt::AlignCenter - - - - - - - 1 - - - 8 - - - - - - - 1 - - - 8 - - - - - - - Aux 1 - - - - - - - 1 - - - 8 - - - - - - - 0000 - - - Qt::AlignCenter - - - - - - - Aux 3 - - - - - - - Invert - - - - - - - 1 - - - 8 - - - - - - - Invert - - - - - - - Invert - - - - - - - Roll / Ailerons - - - - - - - - - - - - - - 200 - 200 - - - - - - - :/files/images/rc_stick.svg - - - true - - - Qt::AlignCenter - - - - - - - 0 - - - 100 - - - 0 - - - Qt::Horizontal - - - - - - - 0 - - - 100 - - - 0 - - - Qt::Vertical - - - - - + + + + + + Invert + + + + + + + 1 + + + 8 + + + + + + + 0000 + + + Qt::AlignCenter + + + + + + + 0000 + + + Qt::AlignCenter + + + + + + + Pitch / Elevator + + + + + + + 0000 + + + Qt::AlignCenter + + + + + + + Aux 2 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0000 + + + Qt::AlignCenter + + + + + + + Invert + + + + + + + 1 + + + 8 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Throttle + + + + + + + Invert + + + + + + + 1 + + + 8 + + + + + + + 1 + + + 8 + + + + + + + Mode Switch + + + + + + + 0000 + + + Qt::AlignCenter + + + + + + + 1 + + + 8 + + + + + + + 1 + + + 8 + + + + + + + Aux 1 + + + + + + + 1 + + + 8 + + + + + + + 0000 + + + Qt::AlignCenter + + + + + + + Aux 3 + + + + + + + Invert + + + + + + + 1 + + + 8 + + + + + + + Invert + + + + + + + Invert + + + + + + + Roll / Ailerons + + + + + + + + + + + + + + 200 + 200 + + + + + + + :/files/images/rc_stick.svg + + + true + + + Qt::AlignCenter + + + + + + + 0 + + + 100 + + + 0 + + + Qt::Horizontal + + + + + + + 0 + + + 100 + + + 0 + + + Qt::Vertical + + + + + + + + + + + + 1 + 1 + + + + + 200 + 200 + + + + + 10 + 10 + + + + + 100 + 100 + + + + + + + :/files/images/rc_stick.svg + + + true + + + Qt::AlignCenter + + + + + + + 0 + + + 100 + + + 0 + + + Qt::Horizontal + + + + + + + 0 + + + 100 + + + 0 + + + Qt::Vertical + + + + + + + + + + + + + 0 + + + 100 + + + Qt::Vertical + + + + + + + 0 + + + 100 + + + Qt::Vertical + + + + + + + 0 + + + 100 + + + Qt::Vertical + + + + + + + 0 + + + 100 + + + Qt::Vertical + + + + + + + + + + + Start Calibration + + + + + + + Set Trim + + + + + + + + + + + + - - - - - - 1 - 1 - - - - - 200 - 200 - - - - - 10 - 10 - - - - - 100 - 100 - - - - - - - :/files/images/rc_stick.svg - - - true - - - Qt::AlignCenter - - - - - - - 0 - - - 100 - - - 0 - - - Qt::Horizontal - - - - - - - 0 - - - 100 - - - 0 - - - Qt::Vertical - - - - + + + Sensor Calibration + + - + - - - - - 0 - - - 100 - - - Qt::Vertical - - - - - - - 0 - - - 100 - - - Qt::Vertical - - - - - - - 0 - - - 100 - - - Qt::Vertical - - - - - - - 0 - - - 100 - - - Qt::Vertical - - - - + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> + + - + - - - Start Calibration - - - - - - - Set Trim + + + true + + + + 0 + 0 + 20 + 20 + + + + + + + + @@ -738,310 +795,241 @@ Config - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Sensor Calibration - - - - - + + + - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html> + + + General Config - + - - - true + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Load Platform Defaults - - - - 0 - 0 - 98 - 28 - - - - - - - - - - - - - - - - - - General Config - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Load Platform Defaults - - - - - - - - - - Configuration - - - - 0 - - - - - true + + + + + Configuration + + + + 0 - - - - 0 - 0 - 98 - 28 - - - - - 0 + + + + true - - - - - - - - - - - - - - Configuration - - - - 0 - - - - - true + + + + 0 + 0 + 16 + 16 + + + + + 0 + + + + + + + + + + + + + + + Configuration + + + + 0 - - - - 0 - 0 - 98 - 28 - - - - - 0 + + + + true - - - - - - - - - + + + + 0 + 0 + 16 + 16 + + + + + 0 + + + + + + + + + + + + - - - - - - - - - Advanced Config - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - + + + - + - Load Platform Defaults + Advanced Config - - - - - - - Configuration - - - - 0 - - - - - true - - - - - 0 - 0 - 98 - 28 - - - - - 0 - - - - - - - - - - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Load Platform Defaults + + + + - - - Configuration - - - - 0 - - - - - true + + + + + Configuration + + + + 0 - - - - 0 - 0 - 98 - 28 - - - - - 0 + + + + true - - - - - - - - - + + + + 0 + 0 + 16 + 16 + + + + + 0 + + + + + + + + + + + + + + + Configuration + + + + 0 + + + + + true + + + + + 0 + 0 + 16 + 16 + + + + + 0 + + + + + + + + + + + + - - - - - - - + + + @@ -1287,6 +1275,14 @@ p, li { white-space: pre-wrap; } + + + QGCRadioChannelDisplay + QWidget +
ui/designer/QGCRadioChannelDisplay.h
+ 1 +
+
diff --git a/src/ui/designer/QGCRadioChannelDisplay.cpp b/src/ui/designer/QGCRadioChannelDisplay.cpp new file mode 100644 index 0000000000..155ba73995 --- /dev/null +++ b/src/ui/designer/QGCRadioChannelDisplay.cpp @@ -0,0 +1,87 @@ +#include "QGCRadioChannelDisplay.h" +#include +QGCRadioChannelDisplay::QGCRadioChannelDisplay(QWidget *parent) : QWidget(parent) +{ + m_showMinMax = true; + m_min = 500; + m_max = 1600; + m_value = 1500; + m_orientation = Qt::Vertical; + m_name = "Yaw"; +} + +void QGCRadioChannelDisplay::setOrientation(Qt::Orientation orient) +{ + m_orientation = orient; + update(); +} +void QGCRadioChannelDisplay::paintEvent(QPaintEvent *event) +{ + //Values range from 0-3000. + //1500 is the middle, static servo value. + QPainter painter(this); + + if (m_orientation == Qt::Vertical) + { + painter.drawRect(0,0,width()-1,(height()-1) - (painter.fontMetrics().height() * 2)); + painter.setBrush(Qt::SolidPattern); + painter.setPen(QColor::fromRgb(50,255,50)); + int newval = (height()-2) * ((float)m_value / 3000.0); + painter.drawRect(1,newval,width()-3,((height()-2) - newval) - (painter.fontMetrics().height() * 2)); + } + else + { + painter.drawRect(0,0,width()-1,(height()-1) - (painter.fontMetrics().height() * 2)); + painter.setBrush(Qt::SolidPattern); + painter.setPen(QColor::fromRgb(50,255,50)); + painter.drawRect(1,1,(width()-1) * ((float)m_value / 3000.0),(height()-3) - (painter.fontMetrics().height() * 2)); + painter.setPen(QColor::fromRgb(255,255,255)); + QString valstr = QString::number(m_value); + painter.drawText((width()/2.0) - (painter.fontMetrics().width(m_name)/2.0),((height()-3) - (painter.fontMetrics().height()*1)),m_name); + painter.drawText((width()/2.0) - (painter.fontMetrics().width(valstr)/2.0),((height()-3) - (painter.fontMetrics().height() * 0)),valstr); + if (m_showMinMax) + { + painter.setBrush(Qt::NoBrush); + painter.setPen(QColor::fromRgb(255,0,0)); + painter.drawRect(width() * ((float)m_min / 3000.0),2,((width()-1) * ((float)m_max / 3000.0)) - (width() * ((float)m_min / 3000.0)),(height()-5) - (painter.fontMetrics().height() * 2)); + + QString minstr = QString::number(m_min); + painter.drawText((width() * ((float)m_min / 3000.0)) - (painter.fontMetrics().width("min")/2.0),((height()-3) - (painter.fontMetrics().height()*1)),"min"); + painter.drawText((width() * ((float)m_min / 3000.0)) - (painter.fontMetrics().width(minstr)/2.0),((height()-3) - (painter.fontMetrics().height() * 0)),minstr); + + QString maxstr = QString::number(m_max); + painter.drawText((width() * ((float)m_max / 3000.0)) - (painter.fontMetrics().width("max")/2.0),((height()-3) - (painter.fontMetrics().height()*1)),"max"); + painter.drawText((width() * ((float)m_max / 3000.0)) - (painter.fontMetrics().width(maxstr)/2.0),((height()-3) - (painter.fontMetrics().height() * 0)),maxstr); + } + } +} + +void QGCRadioChannelDisplay::setValue(int value) +{ + m_value = value; + update(); +} + +void QGCRadioChannelDisplay::showMinMax() +{ + m_showMinMax = true; + update(); +} + +void QGCRadioChannelDisplay::hideMinMax() +{ + m_showMinMax = false; + update(); +} + +void QGCRadioChannelDisplay::setMin(int value) +{ + m_min = value; + update(); +} + +void QGCRadioChannelDisplay::setMax(int value) +{ + m_max = value; + update(); +} diff --git a/src/ui/designer/QGCRadioChannelDisplay.h b/src/ui/designer/QGCRadioChannelDisplay.h new file mode 100644 index 0000000000..b28fc44d2b --- /dev/null +++ b/src/ui/designer/QGCRadioChannelDisplay.h @@ -0,0 +1,35 @@ +#ifndef QGCRADIOCHANNELDISPLAY_H +#define QGCRADIOCHANNELDISPLAY_H + +#include + +class QGCRadioChannelDisplay : public QWidget +{ + Q_OBJECT +public: + explicit QGCRadioChannelDisplay(QWidget *parent = 0); + void setOrientation(Qt::Orientation orient); + void setValue(int value); + void showMinMax(); + void hideMinMax(); + void setMin(int value); + void setMax(int value); + int value() { return m_value; } + int min() { return m_min; } + int max() { return m_max; } +protected: + void paintEvent(QPaintEvent *event); +private: + Qt::Orientation m_orientation; + int m_value; + int m_min; + int m_max; + bool m_showMinMax; + QString m_name; +signals: + +public slots: + +}; + +#endif // QGCRADIOCHANNELDISPLAY_H -- GitLab