Commit 28ce0811 authored by Gus Grubba's avatar Gus Grubba

Custom gimbal control

parent 37050a59
...@@ -37,8 +37,9 @@ Item { ...@@ -37,8 +37,9 @@ Item {
readonly property string _commLostStr: qsTr("NO CAMERA") readonly property string _commLostStr: qsTr("NO CAMERA")
property real _spacers: ScreenTools.defaultFontPixelHeight property real _spacers: ScreenTools.defaultFontPixelHeight
property real _labelFieldWidth: ScreenTools.defaultFontPixelWidth * 28 property real _labelFieldWidth: ScreenTools.defaultFontPixelWidth * 28
property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30 property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 30
property real _editFieldHeight: ScreenTools.defaultFontPixelHeight * 2
property var _dynamicCameras: activeVehicle ? activeVehicle.dynamicCameras : null property var _dynamicCameras: activeVehicle ? activeVehicle.dynamicCameras : null
property bool _isCamera: _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false property bool _isCamera: _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
...@@ -364,6 +365,7 @@ Item { ...@@ -364,6 +365,7 @@ Item {
QGCComboBox { QGCComboBox {
model: _isCamera ? _dynamicCameras.cameraLabels : [] model: _isCamera ? _dynamicCameras.cameraLabels : []
width: _editFieldWidth width: _editFieldWidth
height: _editFieldHeight
onActivated: _dynamicCameras.currentCamera = index onActivated: _dynamicCameras.currentCamera = index
currentIndex: _dynamicCameras ? _dynamicCameras.currentCamera : 0 currentIndex: _dynamicCameras ? _dynamicCameras.currentCamera : 0
} }
...@@ -388,6 +390,7 @@ Item { ...@@ -388,6 +390,7 @@ Item {
QGCComboBox { QGCComboBox {
model: _camera ? _camera.streamLabels : [] model: _camera ? _camera.streamLabels : []
width: _editFieldWidth width: _editFieldWidth
height: _editFieldHeight
onActivated: _camera.currentStream = index onActivated: _camera.currentStream = index
currentIndex: _camera ? _camera.currentStream : 0 currentIndex: _camera ? _camera.currentStream : 0
} }
...@@ -412,6 +415,7 @@ Item { ...@@ -412,6 +415,7 @@ Item {
} }
QGCComboBox { QGCComboBox {
width: _editFieldWidth width: _editFieldWidth
height: _editFieldHeight
model: parent.thermalModes model: parent.thermalModes
currentIndex: _camera ? _camera.thermalMode : 0 currentIndex: _camera ? _camera.thermalMode : 0
onActivated: _camera.thermalMode = index onActivated: _camera.thermalMode = index
...@@ -436,6 +440,7 @@ Item { ...@@ -436,6 +440,7 @@ Item {
} }
Slider { Slider {
width: _editFieldWidth width: _editFieldWidth
height: _editFieldHeight
to: 100 to: 100
from: 0 from: 0
value: _camera ? _camera.thermalOpacity : 0 value: _camera ? _camera.thermalOpacity : 0
...@@ -476,7 +481,8 @@ Item { ...@@ -476,7 +481,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
FactComboBox { FactComboBox {
width: parent._isCombo ? _editFieldWidth : 0 width: parent._isCombo ? _editFieldWidth : 0
height: parent._isCombo ? _editFieldHeight : 0
fact: parent.parent._fact fact: parent.parent._fact
indexModel: false indexModel: false
visible: parent._isCombo visible: parent._isCombo
...@@ -484,14 +490,16 @@ Item { ...@@ -484,14 +490,16 @@ Item {
} }
QGCButton { QGCButton {
visible: parent._isEdit visible: parent._isEdit
width: parent._isEdit ? _editFieldWidth : 0 width: parent._isEdit ? _editFieldWidth : 0
height: parent._isEdit ? _editFieldHeight : 0
text: parent.parent._fact.valueString text: parent.parent._fact.valueString
onClicked: { onClicked: {
showEditFact(parent.parent._fact) showEditFact(parent.parent._fact)
} }
} }
QGCSlider { QGCSlider {
width: parent._isSlider ? _editFieldWidth : 0 width: parent._isSlider ? _editFieldWidth : 0
height: parent._isSlider ? _editFieldHeight : 0
maximumValue: parent.parent._fact.max maximumValue: parent.parent._fact.max
minimumValue: parent.parent._fact.min minimumValue: parent.parent._fact.min
stepSize: parent.parent._fact.increment stepSize: parent.parent._fact.increment
...@@ -506,7 +514,8 @@ Item { ...@@ -506,7 +514,8 @@ Item {
} }
} }
CustomOnOffSwitch { CustomOnOffSwitch {
width: parent._isBool ? _editFieldWidth : 0 width: parent._isBool ? _editFieldWidth : 0
height: parent._isBool ? _editFieldHeight : 0
checked: parent.parent._fact ? parent.parent._fact.value : false checked: parent.parent._fact ? parent.parent._fact.value : false
onClicked: parent.parent._fact.value = checked ? 1 : 0 onClicked: parent.parent._fact.value = checked ? 1 : 0
visible: parent._isBool visible: parent._isBool
...@@ -535,6 +544,7 @@ Item { ...@@ -535,6 +544,7 @@ Item {
} }
QGCComboBox { QGCComboBox {
width: _editFieldWidth width: _editFieldWidth
height: _editFieldHeight
model: parent.photoModes model: parent.photoModes
currentIndex: _camera ? _camera.photoMode : 0 currentIndex: _camera ? _camera.photoMode : 0
onActivated: _camera.photoMode = index onActivated: _camera.photoMode = index
...@@ -559,6 +569,7 @@ Item { ...@@ -559,6 +569,7 @@ Item {
} }
QGCSlider { QGCSlider {
width: _editFieldWidth width: _editFieldWidth
height: _editFieldHeight
maximumValue: 60 maximumValue: 60
minimumValue: _camera ? (_camera.isE90 ? 3 : 5) : 5 minimumValue: _camera ? (_camera.isE90 ? 3 : 5) : 5
stepSize: 1 stepSize: 1
...@@ -579,6 +590,31 @@ Item { ...@@ -579,6 +590,31 @@ Item {
visible: _cameraPhotoMode && _camera.photoMode === QGCCameraControl.PHOTO_CAPTURE_TIMELAPSE && !_noSdCard visible: _cameraPhotoMode && _camera.photoMode === QGCCameraControl.PHOTO_CAPTURE_TIMELAPSE && !_noSdCard
} }
//------------------------------------------- //-------------------------------------------
//-- Gimbal Control
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: _camera && !_camera.isThermal
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: qsTr("Show Gimbal Control")
width: _labelFieldWidth
anchors.verticalCenter: parent.verticalCenter
}
CustomOnOffSwitch {
checked: CustomQuickInterface.showGimbalControl
width: _editFieldWidth
height: _editFieldHeight
anchors.verticalCenter: parent.verticalCenter
onClicked: CustomQuickInterface.showGimbalControl = checked
}
}
Rectangle {
color: qgcPal.button
height: 1
width: cameraSettingsCol.width
visible: _camera && !_camera.isThermal
}
//-------------------------------------------
//-- Screen Grid //-- Screen Grid
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
...@@ -592,6 +628,7 @@ Item { ...@@ -592,6 +628,7 @@ Item {
CustomOnOffSwitch { CustomOnOffSwitch {
checked: QGroundControl.settingsManager.videoSettings.gridLines.rawValue checked: QGroundControl.settingsManager.videoSettings.gridLines.rawValue
width: _editFieldWidth width: _editFieldWidth
height: _editFieldHeight
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
onClicked: QGroundControl.settingsManager.videoSettings.gridLines.rawValue = checked onClicked: QGroundControl.settingsManager.videoSettings.gridLines.rawValue = checked
} }
...@@ -615,6 +652,7 @@ Item { ...@@ -615,6 +652,7 @@ Item {
} }
FactComboBox { FactComboBox {
width: _editFieldWidth width: _editFieldWidth
height: _editFieldHeight
fact: QGroundControl.settingsManager.videoSettings.videoFit fact: QGroundControl.settingsManager.videoSettings.videoFit
indexModel: false indexModel: false
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
...@@ -640,6 +678,7 @@ Item { ...@@ -640,6 +678,7 @@ Item {
text: qsTr("Reset") text: qsTr("Reset")
onClicked: resetPrompt.open() onClicked: resetPrompt.open()
width: _editFieldWidth width: _editFieldWidth
height: _editFieldHeight
enabled: !_recordingVideo enabled: !_recordingVideo
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
MessageDialog { MessageDialog {
......
...@@ -60,7 +60,7 @@ Item { ...@@ -60,7 +60,7 @@ Item {
property real _distance: 0.0 property real _distance: 0.0
property string _messageTitle: "" property string _messageTitle: ""
property string _messageText: "" property string _messageText: ""
property bool _showAttitude: false property bool _showAttitude: true
function secondsToHHMMSS(timeS) { function secondsToHHMMSS(timeS) {
var sec_num = parseInt(timeS, 10); var sec_num = parseInt(timeS, 10);
...@@ -508,6 +508,42 @@ Item { ...@@ -508,6 +508,42 @@ Item {
} }
} }
//-- Gimbal Control
Item {
id: gimbalControl
visible: camControlLoader.visible && CustomQuickInterface.showGimbalControl
anchors.top: camControlLoader.bottom
anchors.topMargin: height * -0.5
anchors.right: camControlLoader.left
anchors.rightMargin: ScreenTools.defaultFontPixelWidth * 2
height: parent.width * 0.125
width: height
property real curPitch: 0
property real curYaw: 0
Timer {
interval: 100 //-- 10Hz
running: gimbalControl.visible && activeVehicle
repeat: true
onTriggered: {
if (activeVehicle) {
var p = Math.round(stick.yAxis * -90)
var y = Math.round(stick.xAxis * 180)
if(p !== gimbalControl.curPitch || y !== gimbalControl.curYaw) {
gimbalControl.curPitch = p
gimbalControl.curYaw = y
activeVehicle.gimbalControlValue(p, y)
}
}
}
}
JoystickThumbPad {
id: stick
anchors.fill: parent
lightColors: true
yAxisThrottleCentered: true
springYToCenter: false
}
}
//-- Connection Lost While Armed //-- Connection Lost While Armed
Popup { Popup {
id: connectionLostArmed id: connectionLostArmed
......
...@@ -21,8 +21,10 @@ ...@@ -21,8 +21,10 @@
#include "CustomPlugin.h" #include "CustomPlugin.h"
#include "CustomQuickInterface.h" #include "CustomQuickInterface.h"
#include <QDirIterator> #include <QSettings>
#include <QtAlgorithms>
static const char* kGroupName = "CustomSettings";
static const char* kShowGimbalCtl = "ShowGimbalCtl";
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
CustomQuickInterface::CustomQuickInterface(QObject* parent) CustomQuickInterface::CustomQuickInterface(QObject* parent)
...@@ -41,4 +43,20 @@ CustomQuickInterface::~CustomQuickInterface() ...@@ -41,4 +43,20 @@ CustomQuickInterface::~CustomQuickInterface()
void void
CustomQuickInterface::init() CustomQuickInterface::init()
{ {
QSettings settings;
settings.beginGroup(kGroupName);
_showGimbalControl = settings.value(kShowGimbalCtl, true).toBool();
}
//-----------------------------------------------------------------------------
void
CustomQuickInterface::setShowGimbalControl(bool set)
{
if(_showGimbalControl != set) {
_showGimbalControl = set;
QSettings settings;
settings.beginGroup(kGroupName);
settings.setValue(kShowGimbalCtl,set);
emit showGimbalControlChanged();
}
} }
...@@ -28,5 +28,13 @@ class CustomQuickInterface : public QObject ...@@ -28,5 +28,13 @@ class CustomQuickInterface : public QObject
public: public:
CustomQuickInterface(QObject* parent = nullptr); CustomQuickInterface(QObject* parent = nullptr);
~CustomQuickInterface(); ~CustomQuickInterface();
void init (); Q_PROPERTY(bool showGimbalControl READ showGimbalControl WRITE setShowGimbalControl NOTIFY showGimbalControlChanged)
bool showGimbalControl () { return _showGimbalControl; }
void setShowGimbalControl (bool set);
void init ();
signals:
void showGimbalControlChanged ();
private:
bool _showGimbalControl = true;
}; };
...@@ -172,12 +172,14 @@ VideoManager::hasThermal() ...@@ -172,12 +172,14 @@ VideoManager::hasThermal()
bool bool
VideoManager::autoStreamConfigured() VideoManager::autoStreamConfigured()
{ {
#if defined(QGC_GST_STREAMING)
if(_activeVehicle && _activeVehicle->dynamicCameras()) { if(_activeVehicle && _activeVehicle->dynamicCameras()) {
QGCVideoStreamInfo* pInfo = _activeVehicle->dynamicCameras()->currentStreamInstance(); QGCVideoStreamInfo* pInfo = _activeVehicle->dynamicCameras()->currentStreamInstance();
if(pInfo) { if(pInfo) {
return !pInfo->uri().isEmpty(); return !pInfo->uri().isEmpty();
} }
} }
#endif
return false; return false;
} }
......
...@@ -14,6 +14,7 @@ Item { ...@@ -14,6 +14,7 @@ Item {
property bool yAxisThrottleCentered: false ///< false: center yAxis in throttle for reverser and forward property bool yAxisThrottleCentered: false ///< false: center yAxis in throttle for reverser and forward
property real xPositionDelta: 0 ///< Amount to move the control on x axis property real xPositionDelta: 0 ///< Amount to move the control on x axis
property real yPositionDelta: 0 ///< Amount to move the control on y axis property real yPositionDelta: 0 ///< Amount to move the control on y axis
property bool springYToCenter:true ///< true: Spring Y to center on release
property real _centerXY: width / 2 property real _centerXY: width / 2
property bool _processTouchPoints: false property bool _processTouchPoints: false
...@@ -72,7 +73,6 @@ Item { ...@@ -72,7 +73,6 @@ Item {
} else { } else {
yPositionDelta = touchPoints[0].y - _centerXY yPositionDelta = touchPoints[0].y - _centerXY
} }
// We need to wait until we move the control to the right position before we process touch points // We need to wait until we move the control to the right position before we process touch points
_processTouchPoints = true _processTouchPoints = true
} }
...@@ -199,8 +199,10 @@ Item { ...@@ -199,8 +199,10 @@ Item {
minimumTouchPoints: 1 minimumTouchPoints: 1
maximumTouchPoints: 1 maximumTouchPoints: 1
touchPoints: [ TouchPoint { id: touchPoint } ] touchPoints: [ TouchPoint { id: touchPoint } ]
onPressed: _joyRoot.thumbDown(touchPoints)
onPressed: _joyRoot.thumbDown(touchPoints) onReleased: {
onReleased: _joyRoot.reCenter() if(springYToCenter)
_joyRoot.reCenter()
}
} }
} }
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