JoystickConfigAdvanced.qml 9.18 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
Gus Grubba's avatar
Gus Grubba committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
 *
 * 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
                }
            }
        }
Gus Grubba's avatar
Gus Grubba committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
        //---------------------------------------------------------------------
        //-- Enable Gimbal
        QGCLabel {
            text:               qsTr("Enable gimbal control (Experimental)")
            visible:            advancedSettings.checked
            Layout.alignment:   Qt.AlignVCenter
        }
        QGCCheckBox {
            id:                 enabledGimbal
            visible:            advancedSettings.checked
            enabled:            _activeJoystick
            onClicked:          _activeJoystick.gimbalEnabled = checked
            Component.onCompleted: {
                checked = _activeJoystick.gimbalEnabled
            }
            Connections {
                target: joystickManager
                onActiveJoystickChanged: {
                    if(_activeJoystick) {
                        enabledGimbal.checked = Qt.binding(function() { return _activeJoystick.gimbalEnabled })
                    }
                }
            }
        }
Gus Grubba's avatar
Gus Grubba committed
130
        //-----------------------------------------------------------------
Gus Grubba's avatar
Gus Grubba committed
131
        //-- Axis Message Frequency
Gus Grubba's avatar
Gus Grubba committed
132
        QGCLabel {
Gus Grubba's avatar
Gus Grubba committed
133
            text:               qsTr("Axis frequency (Hz):")
Gus Grubba's avatar
Gus Grubba committed
134 135 136 137
            Layout.alignment:   Qt.AlignVCenter
            visible:            advancedSettings.checked
        }
        QGCTextField {
138
            text:               _activeJoystick.axisFrequencyHz
Gus Grubba's avatar
Gus Grubba committed
139
            enabled:            advancedSettings.checked
140
            validator:          DoubleValidator { bottom: _activeJoystick.minAxisFrequencyHz; top: _activeJoystick.maxAxisFrequencyHz; }
Gus Grubba's avatar
Gus Grubba committed
141 142 143
            inputMethodHints:   Qt.ImhFormattedNumbersOnly
            Layout.alignment:   Qt.AlignVCenter
            onEditingFinished: {
144
                _activeJoystick.axisFrequencyHz = parseFloat(text)
Gus Grubba's avatar
Gus Grubba committed
145 146 147 148 149 150 151 152 153 154 155
            }
            visible:            advancedSettings.checked
        }
        //-----------------------------------------------------------------
        //-- Button Repeat Frequency
        QGCLabel {
            text:               qsTr("Button repeat frequency (Hz):")
            Layout.alignment:   Qt.AlignVCenter
            visible:            advancedSettings.checked
        }
        QGCTextField {
156
            text:               _activeJoystick.buttonFrequencyHz
Gus Grubba's avatar
Gus Grubba committed
157
            enabled:            advancedSettings.checked
158
            validator:          DoubleValidator { bottom: _activeJoystick.minButtonFrequencyHz; top: _activeJoystick.maxButtonFrequencyHz; }
Gus Grubba's avatar
Gus Grubba committed
159 160 161
            inputMethodHints:   Qt.ImhFormattedNumbersOnly
            Layout.alignment:   Qt.AlignVCenter
            onEditingFinished: {
162
                _activeJoystick.buttonFrequencyHz = parseFloat(text)
Gus Grubba's avatar
Gus Grubba committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
            }
            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.")
        }
    }
}