16 changed files with 1067 additions and 1136 deletions
@ -0,0 +1,90 @@ |
|||||||
|
import QtQuick 2.11 |
||||||
|
import QtQuick.Controls 2.4 |
||||||
|
|
||||||
|
import QGroundControl 1.0 |
||||||
|
import QGroundControl.Palette 1.0 |
||||||
|
import QGroundControl.Controls 1.0 |
||||||
|
import QGroundControl.ScreenTools 1.0 |
||||||
|
|
||||||
|
Item { |
||||||
|
property int axisValue: 0 |
||||||
|
property int deadbandValue: 0 |
||||||
|
property bool narrowIndicator: false |
||||||
|
property color deadbandColor: "#8c161a" |
||||||
|
property bool mapped: false |
||||||
|
property bool reversed: false |
||||||
|
|
||||||
|
property color __barColor: qgcPal.windowShade |
||||||
|
|
||||||
|
// Bar |
||||||
|
Rectangle { |
||||||
|
id: bar |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
width: parent.width |
||||||
|
height: parent.height / 2 |
||||||
|
color: __barColor |
||||||
|
} |
||||||
|
|
||||||
|
// Deadband |
||||||
|
Rectangle { |
||||||
|
id: deadbandBar |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
x: _deadbandPosition |
||||||
|
width: _deadbandWidth |
||||||
|
height: parent.height / 2 |
||||||
|
color: deadbandColor |
||||||
|
visible: controller.deadbandToggle |
||||||
|
|
||||||
|
property real _percentDeadband: ((2 * deadbandValue) / (32768.0 * 2)) |
||||||
|
property real _deadbandWidth: parent.width * _percentDeadband |
||||||
|
property real _deadbandPosition: (parent.width - _deadbandWidth) / 2 |
||||||
|
} |
||||||
|
|
||||||
|
// Center point |
||||||
|
Rectangle { |
||||||
|
anchors.horizontalCenter: parent.horizontalCenter |
||||||
|
width: ScreenTools.defaultFontPixelWidth / 2 |
||||||
|
height: parent.height |
||||||
|
color: qgcPal.window |
||||||
|
} |
||||||
|
|
||||||
|
// Indicator |
||||||
|
Rectangle { |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
width: parent.narrowIndicator ? height/6 : height |
||||||
|
height: parent.height * 0.75 |
||||||
|
x: (reversed ? (parent.width - _indicatorPosition) : _indicatorPosition) - (width / 2) |
||||||
|
radius: width / 2 |
||||||
|
color: qgcPal.text |
||||||
|
visible: mapped |
||||||
|
|
||||||
|
property real _percentAxisValue: ((axisValue + 32768.0) / (32768.0 * 2)) |
||||||
|
property real _indicatorPosition: parent.width * _percentAxisValue |
||||||
|
} |
||||||
|
|
||||||
|
QGCLabel { |
||||||
|
anchors.fill: parent |
||||||
|
horizontalAlignment: Text.AlignHCenter |
||||||
|
verticalAlignment: Text.AlignVCenter |
||||||
|
text: qsTr("Not Mapped") |
||||||
|
visible: !mapped |
||||||
|
} |
||||||
|
|
||||||
|
ColorAnimation { |
||||||
|
id: barAnimation |
||||||
|
target: bar |
||||||
|
property: "color" |
||||||
|
from: "yellow" |
||||||
|
to: __barColor |
||||||
|
duration: 1500 |
||||||
|
} |
||||||
|
|
||||||
|
// Axis value debugger |
||||||
|
/* |
||||||
|
QGCLabel { |
||||||
|
anchors.fill: parent |
||||||
|
text: axisValue |
||||||
|
} |
||||||
|
*/ |
||||||
|
|
||||||
|
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,186 @@ |
|||||||
|
/**************************************************************************** |
||||||
|
* |
||||||
|
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> |
||||||
|
* |
||||||
|
* QGroundControl is licensed according to the terms in the file |
||||||
|
* COPYING.md in the root of the source code directory. |
||||||
|
* |
||||||
|
****************************************************************************/ |
||||||
|
|
||||||
|
import QtQuick 2.11 |
||||||
|
import QtQuick.Controls 2.4 |
||||||
|
import QtQuick.Dialogs 1.3 |
||||||
|
import QtQuick.Layouts 1.11 |
||||||
|
|
||||||
|
import QGroundControl 1.0 |
||||||
|
import QGroundControl.Palette 1.0 |
||||||
|
import QGroundControl.Controls 1.0 |
||||||
|
import QGroundControl.ScreenTools 1.0 |
||||||
|
import QGroundControl.Controllers 1.0 |
||||||
|
import QGroundControl.FactSystem 1.0 |
||||||
|
import QGroundControl.FactControls 1.0 |
||||||
|
|
||||||
|
Item { |
||||||
|
width: grid.width + (ScreenTools.defaultFontPixelWidth * 2) |
||||||
|
height: grid.height + (ScreenTools.defaultFontPixelHeight * 2) |
||||||
|
//--------------------------------------------------------------------- |
||||||
|
GridLayout { |
||||||
|
id: grid |
||||||
|
columns: 2 |
||||||
|
columnSpacing: ScreenTools.defaultFontPixelWidth |
||||||
|
rowSpacing: ScreenTools.defaultFontPixelHeight |
||||||
|
anchors.centerIn: parent |
||||||
|
//------------------------------------------------------------- |
||||||
|
//------------------------------------------------------------- |
||||||
|
QGCRadioButton { |
||||||
|
text: qsTr("Full down stick is zero throttle") |
||||||
|
checked: _activeJoystick ? _activeJoystick.throttleMode === 1 : false |
||||||
|
onClicked: _activeJoystick.throttleMode = 1 |
||||||
|
Layout.columnSpan: 2 |
||||||
|
} |
||||||
|
QGCRadioButton { |
||||||
|
text: qsTr("Center stick is zero throttle") |
||||||
|
checked: _activeJoystick ? _activeJoystick.throttleMode === 0 : false |
||||||
|
onClicked: _activeJoystick.throttleMode = 0 |
||||||
|
Layout.columnSpan: 2 |
||||||
|
} |
||||||
|
//------------------------------------------------------------- |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("Spring loaded throttle smoothing") |
||||||
|
visible: _activeJoystick ? _activeJoystick.throttleMode === 0 : false |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 36 |
||||||
|
} |
||||||
|
QGCCheckBox { |
||||||
|
checked: _activeJoystick ? _activeJoystick.accumulator : false |
||||||
|
visible: _activeJoystick ? _activeJoystick.throttleMode === 0 : false |
||||||
|
onClicked: _activeJoystick.accumulator = checked |
||||||
|
} |
||||||
|
//------------------------------------------------------------- |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("Allow negative Thrust") |
||||||
|
visible: activeVehicle.supportsNegativeThrust |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
} |
||||||
|
QGCCheckBox { |
||||||
|
visible: activeVehicle.supportsNegativeThrust |
||||||
|
enabled: _activeJoystick.negativeThrust = activeVehicle.supportsNegativeThrust |
||||||
|
checked: _activeJoystick ? _activeJoystick.negativeThrust : false |
||||||
|
onClicked: _activeJoystick.negativeThrust = checked |
||||||
|
} |
||||||
|
//--------------------------------------------------------------------- |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("Exponential:") |
||||||
|
} |
||||||
|
Row { |
||||||
|
spacing: ScreenTools.defaultFontPixelWidth |
||||||
|
QGCSlider { |
||||||
|
id: expoSlider |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 20 |
||||||
|
minimumValue: 0 |
||||||
|
maximumValue: 0.75 |
||||||
|
Component.onCompleted: value = -_activeJoystick.exponential |
||||||
|
onValueChanged: _activeJoystick.exponential = -value |
||||||
|
} |
||||||
|
QGCLabel { |
||||||
|
id: expoSliderIndicator |
||||||
|
text: expoSlider.value.toFixed(2) |
||||||
|
} |
||||||
|
} |
||||||
|
//----------------------------------------------------------------- |
||||||
|
//-- Enable Advanced Mode |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("Enable further advanced settings (careful!)") |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 36 |
||||||
|
} |
||||||
|
QGCCheckBox { |
||||||
|
id: advancedSettings |
||||||
|
checked: activeVehicle.joystickMode !== 0 |
||||||
|
onClicked: { |
||||||
|
if (!checked) { |
||||||
|
activeVehicle.joystickMode = 0 |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
//----------------------------------------------------------------- |
||||||
|
//-- Mode |
||||||
|
QGCLabel { |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
text: qsTr("Joystick mode:") |
||||||
|
visible: advancedSettings.checked |
||||||
|
} |
||||||
|
QGCComboBox { |
||||||
|
enabled: advancedSettings.checked |
||||||
|
currentIndex: activeVehicle.joystickMode |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 20 |
||||||
|
model: activeVehicle.joystickModes |
||||||
|
onActivated: activeVehicle.joystickMode = index |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
visible: advancedSettings.checked |
||||||
|
} |
||||||
|
//----------------------------------------------------------------- |
||||||
|
//-- Message Frequency |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("Message frequency (Hz):") |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
visible: advancedSettings.checked |
||||||
|
} |
||||||
|
QGCTextField { |
||||||
|
text: _activeJoystick.frequency |
||||||
|
enabled: advancedSettings.checked |
||||||
|
validator: DoubleValidator { bottom: 0.25; top: 100.0; } |
||||||
|
inputMethodHints: Qt.ImhFormattedNumbersOnly |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
onEditingFinished: { |
||||||
|
_activeJoystick.frequency = parseFloat(text) |
||||||
|
} |
||||||
|
visible: advancedSettings.checked |
||||||
|
} |
||||||
|
//----------------------------------------------------------------- |
||||||
|
//-- Enable circle correction |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("Enable circle correction") |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
visible: advancedSettings.checked |
||||||
|
} |
||||||
|
QGCCheckBox { |
||||||
|
checked: activeVehicle.joystickMode !== 0 |
||||||
|
enabled: advancedSettings.checked |
||||||
|
Component.onCompleted: { |
||||||
|
checked = _activeJoystick.circleCorrection |
||||||
|
} |
||||||
|
onClicked: { |
||||||
|
_activeJoystick.circleCorrection = checked |
||||||
|
} |
||||||
|
visible: advancedSettings.checked |
||||||
|
} |
||||||
|
//----------------------------------------------------------------- |
||||||
|
//-- Deadband |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("Deadbands") |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
visible: advancedSettings.checked |
||||||
|
} |
||||||
|
QGCCheckBox { |
||||||
|
enabled: advancedSettings.checked |
||||||
|
checked: controller.deadbandToggle |
||||||
|
onClicked: controller.deadbandToggle = checked |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
visible: advancedSettings.checked |
||||||
|
} |
||||||
|
QGCLabel{ |
||||||
|
Layout.fillWidth: true |
||||||
|
Layout.columnSpan: 2 |
||||||
|
font.pointSize: ScreenTools.smallFontPointSize |
||||||
|
wrapMode: Text.WordWrap |
||||||
|
visible: advancedSettings.checked |
||||||
|
text: qsTr("Deadband can be set during the first ") + |
||||||
|
qsTr("step of calibration by gently wiggling each axis. ") + |
||||||
|
qsTr("Deadband can also be adjusted by clicking and ") + |
||||||
|
qsTr("dragging vertically on the corresponding axis monitor.") |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
@ -0,0 +1,146 @@ |
|||||||
|
/**************************************************************************** |
||||||
|
* |
||||||
|
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> |
||||||
|
* |
||||||
|
* QGroundControl is licensed according to the terms in the file |
||||||
|
* COPYING.md in the root of the source code directory. |
||||||
|
* |
||||||
|
****************************************************************************/ |
||||||
|
|
||||||
|
import QtQuick 2.11 |
||||||
|
import QtQuick.Controls 2.4 |
||||||
|
import QtQuick.Dialogs 1.3 |
||||||
|
import QtQuick.Layouts 1.11 |
||||||
|
|
||||||
|
import QGroundControl 1.0 |
||||||
|
import QGroundControl.Palette 1.0 |
||||||
|
import QGroundControl.Controls 1.0 |
||||||
|
import QGroundControl.ScreenTools 1.0 |
||||||
|
import QGroundControl.Controllers 1.0 |
||||||
|
import QGroundControl.FactSystem 1.0 |
||||||
|
import QGroundControl.FactControls 1.0 |
||||||
|
|
||||||
|
Item { |
||||||
|
width: availableWidth |
||||||
|
height: (activeVehicle.supportsJSButton ? buttonCol.height : buttonFlow.height) + (ScreenTools.defaultFontPixelHeight * 2) |
||||||
|
Connections { |
||||||
|
target: _activeJoystick |
||||||
|
onRawButtonPressedChanged: { |
||||||
|
if (buttonActionRepeater.itemAt(index)) { |
||||||
|
buttonActionRepeater.itemAt(index).pressed = pressed |
||||||
|
} |
||||||
|
if (jsButtonActionRepeater.itemAt(index)) { |
||||||
|
jsButtonActionRepeater.itemAt(index).pressed = pressed |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
Flow { |
||||||
|
id: buttonFlow |
||||||
|
width: parent.width |
||||||
|
spacing: ScreenTools.defaultFontPixelWidth |
||||||
|
visible: !activeVehicle.supportsJSButton |
||||||
|
anchors.centerIn: parent |
||||||
|
Repeater { |
||||||
|
id: buttonActionRepeater |
||||||
|
model: _activeJoystick ? Math.min(_activeJoystick.totalButtonCount, _maxButtons) : [] |
||||||
|
Row { |
||||||
|
spacing: ScreenTools.defaultFontPixelWidth |
||||||
|
property bool pressed |
||||||
|
QGCCheckBox { |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
checked: _activeJoystick ? _activeJoystick.buttonActions[modelData] !== "" : false |
||||||
|
onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "") |
||||||
|
} |
||||||
|
Rectangle { |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
width: ScreenTools.defaultFontPixelHeight * 1.5 |
||||||
|
height: width |
||||||
|
border.width: 1 |
||||||
|
border.color: qgcPal.text |
||||||
|
color: pressed ? qgcPal.buttonHighlight : qgcPal.button |
||||||
|
QGCLabel { |
||||||
|
anchors.fill: parent |
||||||
|
color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText |
||||||
|
horizontalAlignment: Text.AlignHCenter |
||||||
|
verticalAlignment: Text.AlignVCenter |
||||||
|
text: modelData |
||||||
|
} |
||||||
|
} |
||||||
|
QGCComboBox { |
||||||
|
id: buttonActionCombo |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 20 |
||||||
|
model: _activeJoystick ? _activeJoystick.actions : 0 |
||||||
|
onActivated: _activeJoystick.setButtonAction(modelData, textAt(index)) |
||||||
|
Component.onCompleted: currentIndex = find(_activeJoystick.buttonActions[modelData]) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
Column { |
||||||
|
id: buttonCol |
||||||
|
width: parent.width |
||||||
|
visible: activeVehicle.supportsJSButton |
||||||
|
spacing: ScreenTools.defaultFontPixelHeight / 3 |
||||||
|
Row { |
||||||
|
spacing: ScreenTools.defaultFontPixelWidth |
||||||
|
QGCLabel { |
||||||
|
horizontalAlignment: Text.AlignHCenter |
||||||
|
width: ScreenTools.defaultFontPixelHeight * 1.5 |
||||||
|
text: qsTr("#") |
||||||
|
} |
||||||
|
QGCLabel { |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 15 |
||||||
|
text: qsTr("Function: ") |
||||||
|
} |
||||||
|
QGCLabel { |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 15 |
||||||
|
text: qsTr("Shift Function: ") |
||||||
|
} |
||||||
|
} |
||||||
|
Repeater { |
||||||
|
id: jsButtonActionRepeater |
||||||
|
model: _activeJoystick ? Math.min(_activeJoystick.totalButtonCount, _maxButtons) : 0 |
||||||
|
|
||||||
|
Row { |
||||||
|
spacing: ScreenTools.defaultFontPixelWidth |
||||||
|
visible: activeVehicle.supportsJSButton |
||||||
|
|
||||||
|
property bool pressed |
||||||
|
|
||||||
|
Rectangle { |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
width: ScreenTools.defaultFontPixelHeight * 1.5 |
||||||
|
height: width |
||||||
|
border.width: 1 |
||||||
|
border.color: qgcPal.text |
||||||
|
color: pressed ? qgcPal.buttonHighlight : qgcPal.button |
||||||
|
|
||||||
|
|
||||||
|
QGCLabel { |
||||||
|
anchors.fill: parent |
||||||
|
color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText |
||||||
|
horizontalAlignment: Text.AlignHCenter |
||||||
|
verticalAlignment: Text.AlignVCenter |
||||||
|
text: modelData |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
FactComboBox { |
||||||
|
id: mainJSButtonActionCombo |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 15 |
||||||
|
fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null; |
||||||
|
indexModel: false |
||||||
|
} |
||||||
|
|
||||||
|
FactComboBox { |
||||||
|
id: shiftJSButtonActionCombo |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 15 |
||||||
|
fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null; |
||||||
|
indexModel: false |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
@ -0,0 +1,241 @@ |
|||||||
|
/**************************************************************************** |
||||||
|
* |
||||||
|
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> |
||||||
|
* |
||||||
|
* QGroundControl is licensed according to the terms in the file |
||||||
|
* COPYING.md in the root of the source code directory. |
||||||
|
* |
||||||
|
****************************************************************************/ |
||||||
|
|
||||||
|
import QtQuick 2.11 |
||||||
|
import QtQuick.Controls 2.4 |
||||||
|
import QtQuick.Dialogs 1.3 |
||||||
|
import QtQuick.Layouts 1.11 |
||||||
|
|
||||||
|
import QGroundControl 1.0 |
||||||
|
import QGroundControl.Palette 1.0 |
||||||
|
import QGroundControl.Controls 1.0 |
||||||
|
import QGroundControl.ScreenTools 1.0 |
||||||
|
import QGroundControl.Controllers 1.0 |
||||||
|
import QGroundControl.FactSystem 1.0 |
||||||
|
import QGroundControl.FactControls 1.0 |
||||||
|
|
||||||
|
Item { |
||||||
|
height: calCol.height + ScreenTools.defaultFontPixelHeight * 2 |
||||||
|
width: calCol.width + ScreenTools.defaultFontPixelWidth * 2 |
||||||
|
Column { |
||||||
|
id: calCol |
||||||
|
spacing: ScreenTools.defaultFontPixelHeight |
||||||
|
anchors.centerIn: parent |
||||||
|
Row { |
||||||
|
spacing: ScreenTools.defaultFontPixelWidth * 4 |
||||||
|
anchors.horizontalCenter: parent.horizontalCenter |
||||||
|
//----------------------------------------------------------------- |
||||||
|
// Calibration |
||||||
|
Column { |
||||||
|
spacing: ScreenTools.defaultFontPixelHeight |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
Rectangle { |
||||||
|
width: Math.round(ScreenTools.defaultFontPixelWidth * 45) |
||||||
|
height: Math.round(width * 0.5) |
||||||
|
radius: ScreenTools.defaultFontPixelWidth * 2 |
||||||
|
color: qgcPal.window |
||||||
|
border.color: qgcPal.text |
||||||
|
border.width: ScreenTools.defaultFontPixelWidth * 0.25 |
||||||
|
anchors.horizontalCenter: parent.horizontalCenter |
||||||
|
property bool hasStickPositions: controller.stickPositions.length === 4 |
||||||
|
//--------------------------------------------------------- |
||||||
|
//-- Left Stick |
||||||
|
Rectangle { |
||||||
|
width: parent.width * 0.25 |
||||||
|
height: width |
||||||
|
radius: width * 0.5 |
||||||
|
color: qgcPal.window |
||||||
|
border.color: qgcPal.text |
||||||
|
border.width: ScreenTools.defaultFontPixelWidth * 0.125 |
||||||
|
x: (parent.width * 0.25) - (width * 0.5) |
||||||
|
y: (parent.height * 0.5) - (height * 0.5) |
||||||
|
} |
||||||
|
Rectangle { |
||||||
|
color: qgcPal.colorGreen |
||||||
|
width: parent.width * 0.035 |
||||||
|
height: width |
||||||
|
radius: width * 0.5 |
||||||
|
visible: parent.hasStickPositions |
||||||
|
x: (parent.width * controller.stickPositions[0]) - (width * 0.5) |
||||||
|
y: (parent.height * controller.stickPositions[1]) - (height * 0.5) |
||||||
|
} |
||||||
|
//--------------------------------------------------------- |
||||||
|
//-- Right Stick |
||||||
|
Rectangle { |
||||||
|
width: parent.width * 0.25 |
||||||
|
height: width |
||||||
|
radius: width * 0.5 |
||||||
|
color: qgcPal.window |
||||||
|
border.color: qgcPal.text |
||||||
|
border.width: ScreenTools.defaultFontPixelWidth * 0.125 |
||||||
|
x: (parent.width * 0.75) - (width * 0.5) |
||||||
|
y: (parent.height * 0.5) - (height * 0.5) |
||||||
|
} |
||||||
|
Rectangle { |
||||||
|
color: qgcPal.colorGreen |
||||||
|
width: parent.width * 0.035 |
||||||
|
height: width |
||||||
|
radius: width * 0.5 |
||||||
|
visible: parent.hasStickPositions |
||||||
|
x: (parent.width * controller.stickPositions[2]) - (width * 0.5) |
||||||
|
y: (parent.height * controller.stickPositions[3]) - (height * 0.5) |
||||||
|
} |
||||||
|
//--------------------------------------------------------- |
||||||
|
//-- Gimbal Pitch |
||||||
|
Rectangle { |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 0.125 |
||||||
|
height: parent.height * 0.2 |
||||||
|
color: qgcPal.text |
||||||
|
visible: controller.hasGimbal |
||||||
|
x: (parent.width * 0.5) - (width * 0.5) |
||||||
|
y: (parent.height * 0.5) - (height * 0.5) |
||||||
|
} |
||||||
|
Rectangle { |
||||||
|
color: qgcPal.colorGreen |
||||||
|
width: parent.width * 0.035 |
||||||
|
height: width |
||||||
|
radius: width * 0.5 |
||||||
|
visible: controller.hasGimbal |
||||||
|
x: (parent.width * controller.gimbalPositions[0]) - (width * 0.5) |
||||||
|
y: (parent.height * controller.gimbalPositions[1]) - (height * 0.5) |
||||||
|
} |
||||||
|
//--------------------------------------------------------- |
||||||
|
//-- Gimbal Yaw |
||||||
|
Rectangle { |
||||||
|
width: parent.width * 0.2 |
||||||
|
height: ScreenTools.defaultFontPixelWidth * 0.125 |
||||||
|
color: qgcPal.text |
||||||
|
visible: controller.hasGimbal |
||||||
|
x: (parent.width * 0.5) - (width * 0.5) |
||||||
|
y: (parent.height * 0.3) - (height * 0.5) |
||||||
|
} |
||||||
|
Rectangle { |
||||||
|
color: qgcPal.colorGreen |
||||||
|
width: parent.width * 0.035 |
||||||
|
height: width |
||||||
|
radius: width * 0.5 |
||||||
|
visible: controller.hasGimbal |
||||||
|
x: (parent.width * controller.gimbalPositions[2]) - (width * 0.5) |
||||||
|
y: (parent.height * controller.gimbalPositions[3]) - (height * 0.5) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
//--------------------------------------------------------------------- |
||||||
|
// Monitor |
||||||
|
Column { |
||||||
|
spacing: ScreenTools.defaultFontPixelHeight * 0.5 |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("Axis Monitor") |
||||||
|
anchors.horizontalCenter: parent.horizontalCenter |
||||||
|
} |
||||||
|
Connections { |
||||||
|
target: controller |
||||||
|
onAxisValueChanged: { |
||||||
|
if (axisMonitorRepeater.itemAt(axis)) { |
||||||
|
axisMonitorRepeater.itemAt(axis).axis.axisValue = value |
||||||
|
} |
||||||
|
} |
||||||
|
onAxisDeadbandChanged: { |
||||||
|
if (axisMonitorRepeater.itemAt(axis)) { |
||||||
|
axisMonitorRepeater.itemAt(axis).axis.deadbandValue = value |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
Repeater { |
||||||
|
id: axisMonitorRepeater |
||||||
|
model: _activeJoystick ? _activeJoystick.axisCount : 0 |
||||||
|
width: parent.width |
||||||
|
Row { |
||||||
|
spacing: 5 |
||||||
|
anchors.horizontalCenter: parent.horizontalCenter |
||||||
|
// Need this to get to loader from Connections above |
||||||
|
property Item axis: theAxis |
||||||
|
QGCLabel { |
||||||
|
id: axisLabel |
||||||
|
text: modelData |
||||||
|
} |
||||||
|
AxisMonitor { |
||||||
|
id: theAxis |
||||||
|
anchors.verticalCenter: axisLabel.verticalCenter |
||||||
|
height: ScreenTools.defaultFontPixelHeight |
||||||
|
width: 200 |
||||||
|
narrowIndicator: true |
||||||
|
mapped: true |
||||||
|
reversed: false |
||||||
|
MouseArea { |
||||||
|
id: deadbandMouseArea |
||||||
|
anchors.fill: parent.item |
||||||
|
enabled: controller.deadbandToggle |
||||||
|
preventStealing: true |
||||||
|
property real startX |
||||||
|
property real direction |
||||||
|
onPressed: { |
||||||
|
startX = mouseX |
||||||
|
direction = startX > width/2 ? 1 : -1 |
||||||
|
parent.item.deadbandColor = "#3C6315" |
||||||
|
} |
||||||
|
onPositionChanged: { |
||||||
|
var mouseToDeadband = 32768/(width/2) // Factor to have deadband follow the mouse movement |
||||||
|
var newValue = parent.item.deadbandValue + direction*(mouseX - startX)*mouseToDeadband |
||||||
|
if ((newValue > 0) && (newValue <32768)){parent.item.deadbandValue=newValue;} |
||||||
|
startX = mouseX |
||||||
|
} |
||||||
|
onReleased: { |
||||||
|
controller.setDeadbandValue(modelData,parent.item.deadbandValue) |
||||||
|
parent.item.deadbandColor = "#8c161a" |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
// Command Buttons |
||||||
|
Row { |
||||||
|
spacing: ScreenTools.defaultFontPixelWidth * 2 |
||||||
|
visible: _activeJoystick.requiresCalibration |
||||||
|
anchors.horizontalCenter: parent.horizontalCenter |
||||||
|
QGCButton { |
||||||
|
id: skipButton |
||||||
|
text: qsTr("Skip") |
||||||
|
enabled: controller.calibrating ? controller.skipEnabled : false |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 10 |
||||||
|
onClicked: controller.skipButtonClicked() |
||||||
|
} |
||||||
|
QGCButton { |
||||||
|
text: qsTr("Cancel") |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 10 |
||||||
|
enabled: controller.calibrating |
||||||
|
onClicked: { |
||||||
|
if(controller.calibrating) |
||||||
|
controller.cancelButtonClicked() |
||||||
|
} |
||||||
|
} |
||||||
|
QGCButton { |
||||||
|
id: nextButton |
||||||
|
primary: true |
||||||
|
enabled: controller.calibrating ? controller.nextEnabled : true |
||||||
|
text: controller.calibrating ? qsTr("Next") : qsTr("Start") |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 10 |
||||||
|
onClicked: controller.nextButtonClicked() |
||||||
|
} |
||||||
|
} |
||||||
|
// Status Text |
||||||
|
QGCLabel { |
||||||
|
text: controller.statusText |
||||||
|
width: parent.width * 0.8 |
||||||
|
wrapMode: Text.WordWrap |
||||||
|
horizontalAlignment: Text.AlignHCenter |
||||||
|
anchors.horizontalCenter: parent.horizontalCenter |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
@ -0,0 +1,298 @@ |
|||||||
|
/**************************************************************************** |
||||||
|
* |
||||||
|
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> |
||||||
|
* |
||||||
|
* QGroundControl is licensed according to the terms in the file |
||||||
|
* COPYING.md in the root of the source code directory. |
||||||
|
* |
||||||
|
****************************************************************************/ |
||||||
|
|
||||||
|
import QtQuick 2.11 |
||||||
|
import QtQuick.Controls 2.4 |
||||||
|
import QtQuick.Dialogs 1.3 |
||||||
|
import QtQuick.Layouts 1.11 |
||||||
|
|
||||||
|
import QGroundControl 1.0 |
||||||
|
import QGroundControl.Palette 1.0 |
||||||
|
import QGroundControl.Controls 1.0 |
||||||
|
import QGroundControl.ScreenTools 1.0 |
||||||
|
import QGroundControl.Controllers 1.0 |
||||||
|
import QGroundControl.FactSystem 1.0 |
||||||
|
import QGroundControl.FactControls 1.0 |
||||||
|
|
||||||
|
Item { |
||||||
|
width: mainCol.width + (ScreenTools.defaultFontPixelWidth * 2) |
||||||
|
height: mainCol.height + (ScreenTools.defaultFontPixelHeight * 2) |
||||||
|
readonly property real axisMonitorWidth: ScreenTools.defaultFontPixelWidth * 32 |
||||||
|
Column { |
||||||
|
id: mainCol |
||||||
|
anchors.centerIn: parent |
||||||
|
spacing: ScreenTools.defaultFontPixelHeight |
||||||
|
GridLayout { |
||||||
|
columns: 2 |
||||||
|
columnSpacing: ScreenTools.defaultFontPixelWidth |
||||||
|
rowSpacing: ScreenTools.defaultFontPixelHeight |
||||||
|
//--------------------------------------------------------------------- |
||||||
|
//-- Enable Joystick |
||||||
|
QGCLabel { |
||||||
|
text: _activeJoystick ? _activeJoystick.calibrated ? qsTr("Enable joystick input") : qsTr("Enable not allowed (Calibrate First)") : "" |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 36 |
||||||
|
} |
||||||
|
QGCCheckBox { |
||||||
|
id: enabledSwitch |
||||||
|
enabled: _activeJoystick ? _activeJoystick.calibrated : false |
||||||
|
onClicked: activeVehicle.joystickEnabled = checked |
||||||
|
Component.onCompleted: { |
||||||
|
checked = activeVehicle.joystickEnabled |
||||||
|
} |
||||||
|
Connections { |
||||||
|
target: activeVehicle |
||||||
|
onJoystickEnabledChanged: { |
||||||
|
enabledSwitch.checked = activeVehicle.joystickEnabled |
||||||
|
} |
||||||
|
} |
||||||
|
Connections { |
||||||
|
target: joystickManager |
||||||
|
onActiveJoystickChanged: { |
||||||
|
if(_activeJoystick) { |
||||||
|
enabledSwitch.checked = Qt.binding(function() { return _activeJoystick.calibrated && activeVehicle.joystickEnabled }) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
//--------------------------------------------------------------------- |
||||||
|
//-- Joystick Selector |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("Active joystick:") |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
} |
||||||
|
QGCComboBox { |
||||||
|
id: joystickCombo |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 40 |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
model: joystickManager.joystickNames |
||||||
|
onActivated: joystickManager.activeJoystickName = textAt(index) |
||||||
|
Component.onCompleted: { |
||||||
|
var index = joystickCombo.find(joystickManager.activeJoystickName) |
||||||
|
if (index === -1) { |
||||||
|
console.warn(qsTr("Active joystick name not in combo"), joystickManager.activeJoystickName) |
||||||
|
} else { |
||||||
|
joystickCombo.currentIndex = index |
||||||
|
} |
||||||
|
} |
||||||
|
Connections { |
||||||
|
target: joystickManager |
||||||
|
onAvailableJoysticksChanged: { |
||||||
|
var index = joystickCombo.find(joystickManager.activeJoystickName) |
||||||
|
if (index >= 0) { |
||||||
|
joystickCombo.currentIndex = index |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
//--------------------------------------------------------------------- |
||||||
|
//-- RC Mode |
||||||
|
QGCLabel { |
||||||
|
text: qsTr("RC Mode:") |
||||||
|
Layout.alignment: Qt.AlignVCenter |
||||||
|
} |
||||||
|
Row { |
||||||
|
spacing: ScreenTools.defaultFontPixelWidth |
||||||
|
QGCRadioButton { |
||||||
|
text: "1" |
||||||
|
checked: controller.transmitterMode === 1 |
||||||
|
enabled: !controller.calibrating |
||||||
|
onClicked: controller.transmitterMode = 1 |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
} |
||||||
|
QGCRadioButton { |
||||||
|
text: "2" |
||||||
|
checked: controller.transmitterMode === 2 |
||||||
|
enabled: !controller.calibrating |
||||||
|
onClicked: controller.transmitterMode = 2 |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
} |
||||||
|
QGCRadioButton { |
||||||
|
text: "3" |
||||||
|
checked: controller.transmitterMode === 3 |
||||||
|
enabled: !controller.calibrating |
||||||
|
onClicked: controller.transmitterMode = 3 |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
} |
||||||
|
QGCRadioButton { |
||||||
|
text: "4" |
||||||
|
checked: controller.transmitterMode === 4 |
||||||
|
enabled: !controller.calibrating |
||||||
|
onClicked: controller.transmitterMode = 4 |
||||||
|
anchors.verticalCenter: parent.verticalCenter |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
Row { |
||||||
|
spacing: ScreenTools.defaultFontPixelWidth |
||||||
|
//--------------------------------------------------------------------- |
||||||
|
//-- Axis Monitors |
||||||
|
Rectangle { |
||||||
|
id: axisRect |
||||||
|
color: Qt.rgba(0,0,0,0) |
||||||
|
border.color: qgcPal.text |
||||||
|
border.width: 1 |
||||||
|
radius: ScreenTools.defaultFontPixelWidth * 0.5 |
||||||
|
width: axisGrid.width + (ScreenTools.defaultFontPixelWidth * 2) |
||||||
|
height: axisGrid.height + (ScreenTools.defaultFontPixelHeight * 2) |
||||||
|
GridLayout { |
||||||
|
id: axisGrid |
||||||
|
columns: 2 |
||||||
|
columnSpacing: ScreenTools.defaultFontPixelWidth |
||||||
|
rowSpacing: ScreenTools.defaultFontPixelHeight |
||||||
|
anchors.centerIn: parent |
||||||
|
QGCLabel { |
||||||
|
text: activeVehicle.sub ? qsTr("Lateral") : qsTr("Roll") |
||||||
|
} |
||||||
|
AxisMonitor { |
||||||
|
id: rollAxis |
||||||
|
height: ScreenTools.defaultFontPixelHeight |
||||||
|
width: axisMonitorWidth |
||||||
|
mapped: controller.rollAxisMapped |
||||||
|
reversed: controller.rollAxisReversed |
||||||
|
Connections { |
||||||
|
target: _activeJoystick |
||||||
|
onManualControl: rollAxis.axisValue = roll * 32768.0 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
QGCLabel { |
||||||
|
id: pitchLabel |
||||||
|
width: _attitudeLabelWidth |
||||||
|
text: activeVehicle.sub ? qsTr("Forward") : qsTr("Pitch") |
||||||
|
} |
||||||
|
AxisMonitor { |
||||||
|
id: pitchAxis |
||||||
|
height: ScreenTools.defaultFontPixelHeight |
||||||
|
width: axisMonitorWidth |
||||||
|
mapped: controller.pitchAxisMapped |
||||||
|
reversed: controller.pitchAxisReversed |
||||||
|
Connections { |
||||||
|
target: _activeJoystick |
||||||
|
onManualControl: pitchAxis.axisValue = pitch * 32768.0 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
QGCLabel { |
||||||
|
id: yawLabel |
||||||
|
width: _attitudeLabelWidth |
||||||
|
text: qsTr("Yaw") |
||||||
|
} |
||||||
|
AxisMonitor { |
||||||
|
id: yawAxis |
||||||
|
height: ScreenTools.defaultFontPixelHeight |
||||||
|
width: axisMonitorWidth |
||||||
|
mapped: controller.yawAxisMapped |
||||||
|
reversed: controller.yawAxisReversed |
||||||
|
Connections { |
||||||
|
target: _activeJoystick |
||||||
|
onManualControl: yawAxis.axisValue = yaw * 32768.0 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
QGCLabel { |
||||||
|
id: throttleLabel |
||||||
|
width: _attitudeLabelWidth |
||||||
|
text: qsTr("Throttle") |
||||||
|
} |
||||||
|
AxisMonitor { |
||||||
|
id: throttleAxis |
||||||
|
height: ScreenTools.defaultFontPixelHeight |
||||||
|
width: axisMonitorWidth |
||||||
|
mapped: controller.throttleAxisMapped |
||||||
|
reversed: controller.throttleAxisReversed |
||||||
|
Connections { |
||||||
|
target: _activeJoystick |
||||||
|
onManualControl: throttleAxis.axisValue = _activeJoystick.negativeThrust ? throttle * -32768.0 : (-2 * throttle + 1) * 32768.0 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
QGCLabel { |
||||||
|
id: gimbalPitchLabel |
||||||
|
width: _attitudeLabelWidth |
||||||
|
text: qsTr("Gimbal Pitch") |
||||||
|
visible: controller.hasGimbal |
||||||
|
} |
||||||
|
AxisMonitor { |
||||||
|
id: gimbalPitchAxis |
||||||
|
height: ScreenTools.defaultFontPixelHeight |
||||||
|
width: axisMonitorWidth |
||||||
|
mapped: controller.gimbalPitchAxisMapped |
||||||
|
reversed: controller.gimbalPitchAxisReversed |
||||||
|
visible: controller.hasGimbal |
||||||
|
Connections { |
||||||
|
target: _activeJoystick |
||||||
|
onManualControl: gimbalPitchAxis.axisValue = gimbalPitch * 32768.0 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
QGCLabel { |
||||||
|
id: gimbalYawLabel |
||||||
|
width: _attitudeLabelWidth |
||||||
|
text: qsTr("Gimbal Yaw") |
||||||
|
visible: controller.hasGimbal |
||||||
|
} |
||||||
|
AxisMonitor { |
||||||
|
id: gimbalYawAxis |
||||||
|
height: ScreenTools.defaultFontPixelHeight |
||||||
|
width: axisMonitorWidth |
||||||
|
mapped: controller.gimbalYawAxisMapped |
||||||
|
reversed: controller.gimbalYawAxisReversed |
||||||
|
Connections { |
||||||
|
target: _activeJoystick |
||||||
|
onManualControl: gimbalYawAxis.axisValue = gimbalYaw * 32768.0 |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
Rectangle { |
||||||
|
color: Qt.rgba(0,0,0,0) |
||||||
|
border.color: qgcPal.text |
||||||
|
border.width: 1 |
||||||
|
radius: ScreenTools.defaultFontPixelWidth * 0.5 |
||||||
|
width: axisRect.width |
||||||
|
height: axisRect.height |
||||||
|
Flow { |
||||||
|
width: ScreenTools.defaultFontPixelWidth * 30 |
||||||
|
spacing: -1 |
||||||
|
anchors.centerIn: parent |
||||||
|
Connections { |
||||||
|
target: _activeJoystick |
||||||
|
onRawButtonPressedChanged: { |
||||||
|
if (buttonMonitorRepeater.itemAt(index)) { |
||||||
|
buttonMonitorRepeater.itemAt(index).pressed = pressed |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
Repeater { |
||||||
|
id: buttonMonitorRepeater |
||||||
|
model: _activeJoystick ? _activeJoystick.totalButtonCount : [] |
||||||
|
Rectangle { |
||||||
|
width: ScreenTools.defaultFontPixelHeight * 1.5 |
||||||
|
height: width |
||||||
|
border.width: 1 |
||||||
|
border.color: qgcPal.text |
||||||
|
color: pressed ? qgcPal.buttonHighlight : qgcPal.windowShade |
||||||
|
property bool pressed |
||||||
|
QGCLabel { |
||||||
|
anchors.fill: parent |
||||||
|
color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText |
||||||
|
horizontalAlignment: Text.AlignHCenter |
||||||
|
verticalAlignment: Text.AlignVCenter |
||||||
|
text: modelData |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
Loading…
Reference in new issue