JoystickConfig.qml 30.4 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
9 10 11 12 13 14


import QtQuick          2.2
import QtQuick.Controls 1.2
import QtQuick.Dialogs  1.2

15
import QGroundControl               1.0
16 17 18 19
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controllers   1.0
20
import QGroundControl.FactSystem    1.0
21
import QGroundControl.FactControls  1.0
22 23

/// Joystick Config
Don Gagne's avatar
Don Gagne committed
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
SetupPage {
    id:                 joystickPage
    pageComponent:      pageComponent
    pageName:           qsTr("Joystick")
    pageDescription:    qsTr("Joystick Setup is used to configure a calibrate joysticks.")

    Component {
        id: pageComponent

        Item {
            width:  availableWidth
            height: Math.max(leftColumn.height, rightColumn.height)

            property bool controllerCompleted:      false
            property bool controllerAndViewReady:   false

            readonly property real labelToMonitorMargin: defaultTextWidth * 3

            property var _activeVehicle:    QGroundControl.multiVehicleManager.activeVehicle
            property var _activeJoystick:   joystickManager.activeJoystick

            JoystickConfigController {
                id:             controller
                factPanel:      joystickPage.viewPanel
                statusText:     statusText
                cancelButton:   cancelButton
                nextButton:     nextButton
                skipButton:     skipButton

                Component.onCompleted: {
                    controllerCompleted = true
                    if (joystickPage.completedSignalled) {
                        controllerAndViewReady = true
                        controller.start()
                    }
                }
60 61
            }

Don Gagne's avatar
Don Gagne committed
62 63 64 65 66 67
            Component.onCompleted: {
                if (controllerCompleted) {
                    controllerAndViewReady = true
                    controller.start()
                }
            }
68

Don Gagne's avatar
Don Gagne committed
69 70 71
            // Live axis monitor control component
            Component {
                id: axisMonitorDisplayComponent
72

Don Gagne's avatar
Don Gagne committed
73 74
                Item {
                    property int axisValue: 0
75 76


Don Gagne's avatar
Don Gagne committed
77 78 79
                    property int            __lastAxisValue:        0
                    readonly property int   __axisValueMaxJitter:   100
                    property color          __barColor:             qgcPal.windowShade
80

Don Gagne's avatar
Don Gagne committed
81 82 83 84 85 86 87 88
                    // Bar
                    Rectangle {
                        id:                     bar
                        anchors.verticalCenter: parent.verticalCenter
                        width:                  parent.width
                        height:                 parent.height / 2
                        color:                  __barColor
                    }
89

Don Gagne's avatar
Don Gagne committed
90 91 92 93 94 95 96
                    // Center point
                    Rectangle {
                        anchors.horizontalCenter:   parent.horizontalCenter
                        width:                      defaultTextWidth / 2
                        height:                     parent.height
                        color:                      qgcPal.window
                    }
97

Don Gagne's avatar
Don Gagne committed
98 99 100 101 102 103 104 105 106 107 108 109 110
                    // Indicator
                    Rectangle {
                        anchors.verticalCenter: parent.verticalCenter
                        width:                  parent.height * 0.75
                        height:                 width
                        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
                    }
111

Don Gagne's avatar
Don Gagne committed
112 113 114 115 116 117 118
                    QGCLabel {
                        anchors.fill:           parent
                        horizontalAlignment:    Text.AlignHCenter
                        verticalAlignment:      Text.AlignVCenter
                        text:                   qsTr("Not Mapped")
                        visible:                !mapped
                    }
119

Don Gagne's avatar
Don Gagne committed
120 121 122 123 124 125 126 127
                    ColorAnimation {
                        id:         barAnimation
                        target:     bar
                        property:   "color"
                        from:       "yellow"
                        to:         __barColor
                        duration:   1500
                    }
128

Don Gagne's avatar
Don Gagne committed
129 130 131 132 133 134 135
                    /*
                    // Axis value debugger
                    QGCLabel {
                        anchors.fill: parent
                        text: axisValue
                    }
                    */
136
                }
Don Gagne's avatar
Don Gagne committed
137
            } // Component - axisMonitorDisplayComponent
138

Don Gagne's avatar
Don Gagne committed
139 140 141 142 143 144 145 146 147
            // Main view Qml starts here

            // Left side column
            Column {
                id:                     leftColumn
                anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                anchors.left:           parent.left
                anchors.right:          rightColumn.left
                spacing:                10
148

Don Gagne's avatar
Don Gagne committed
149 150 151 152
                // Attitude Controls
                Column {
                    width:      parent.width
                    spacing:    5
153

Don Gagne's avatar
Don Gagne committed
154
                    QGCLabel { text: qsTr("Attitude Controls") }
155

Don Gagne's avatar
Don Gagne committed
156 157 158
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
159

Don Gagne's avatar
Don Gagne committed
160 161 162 163 164
                        QGCLabel {
                            id:     rollLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Roll")
                        }
165

Don Gagne's avatar
Don Gagne committed
166 167 168 169 170 171 172 173 174 175 176 177
                        Loader {
                            id:                 rollLoader
                            anchors.left:       rollLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.rollAxisMapped
                            property bool reversed:         controller.rollAxisReversed
                        }
178

Don Gagne's avatar
Don Gagne committed
179 180
                        Connections {
                            target: controller
181

Don Gagne's avatar
Don Gagne committed
182 183
                            onRollAxisValueChanged: rollLoader.item.axisValue = value
                        }
184 185
                    }

Don Gagne's avatar
Don Gagne committed
186 187 188
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
189

Don Gagne's avatar
Don Gagne committed
190 191 192 193 194
                        QGCLabel {
                            id:     pitchLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Pitch")
                        }
195

Don Gagne's avatar
Don Gagne committed
196 197 198 199 200 201 202 203 204 205 206 207
                        Loader {
                            id:                 pitchLoader
                            anchors.left:       pitchLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.pitchAxisMapped
                            property bool reversed:         controller.pitchAxisReversed
                        }
208

Don Gagne's avatar
Don Gagne committed
209 210
                        Connections {
                            target: controller
211

Don Gagne's avatar
Don Gagne committed
212 213
                            onPitchAxisValueChanged: pitchLoader.item.axisValue = value
                        }
214 215
                    }

Don Gagne's avatar
Don Gagne committed
216 217 218
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
219

Don Gagne's avatar
Don Gagne committed
220 221 222 223 224
                        QGCLabel {
                            id:     yawLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Yaw")
                        }
225

Don Gagne's avatar
Don Gagne committed
226 227 228 229 230 231 232 233 234 235 236 237
                        Loader {
                            id:                 yawLoader
                            anchors.left:       yawLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.yawAxisMapped
                            property bool reversed:         controller.yawAxisReversed
                        }
238

Don Gagne's avatar
Don Gagne committed
239 240
                        Connections {
                            target: controller
241

Don Gagne's avatar
Don Gagne committed
242 243
                            onYawAxisValueChanged: yawLoader.item.axisValue = value
                        }
244 245
                    }

Don Gagne's avatar
Don Gagne committed
246 247 248
                    Item {
                        width:  parent.width
                        height: defaultTextHeight * 2
249

Don Gagne's avatar
Don Gagne committed
250 251 252 253 254
                        QGCLabel {
                            id:     throttleLabel
                            width:  defaultTextWidth * 10
                            text:   qsTr("Throttle")
                        }
255

Don Gagne's avatar
Don Gagne committed
256 257 258 259 260 261 262 263 264 265 266 267
                        Loader {
                            id:                 throttleLoader
                            anchors.left:       throttleLabel.right
                            anchors.right:      parent.right
                            height:             ScreenTools.defaultFontPixelHeight
                            width:              100
                            sourceComponent:    axisMonitorDisplayComponent

                            property real defaultTextWidth: ScreenTools.defaultFontPixelWidth
                            property bool mapped:           controller.throttleAxisMapped
                            property bool reversed:         controller.throttleAxisReversed
                        }
268

Don Gagne's avatar
Don Gagne committed
269 270
                        Connections {
                            target: controller
271

Don Gagne's avatar
Don Gagne committed
272 273
                            onThrottleAxisValueChanged: throttleLoader.item.axisValue = value
                        }
274
                    }
Don Gagne's avatar
Don Gagne committed
275
                } // Column - Attitude Control labels
276

Don Gagne's avatar
Don Gagne committed
277 278 279 280 281 282 283
                // Command Buttons
                Row {
                    spacing: 10

                    QGCButton {
                        id:     skipButton
                        text:   qsTr("Skip")
284

Don Gagne's avatar
Don Gagne committed
285
                        onClicked: controller.skipButtonClicked()
286 287
                    }

Don Gagne's avatar
Don Gagne committed
288 289 290
                    QGCButton {
                        id:     cancelButton
                        text:   qsTr("Cancel")
291

Don Gagne's avatar
Don Gagne committed
292 293
                        onClicked: controller.cancelButtonClicked()
                    }
294

Don Gagne's avatar
Don Gagne committed
295 296 297 298
                    QGCButton {
                        id:         nextButton
                        primary:    true
                        text:       qsTr("Calibrate")
299

Don Gagne's avatar
Don Gagne committed
300 301 302
                        onClicked: controller.nextButtonClicked()
                    }
                } // Row - Buttons
303

Don Gagne's avatar
Don Gagne committed
304 305 306 307 308
                // Status Text
                QGCLabel {
                    id:         statusText
                    width:      parent.width
                    wrapMode:   Text.WordWrap
309 310
                }

Don Gagne's avatar
Don Gagne committed
311 312 313 314 315
                Rectangle {
                    width:          parent.width
                    height:         1
                    border.color:   qgcPal.text
                    border.width:   1
316 317
                }

Don Gagne's avatar
Don Gagne committed
318 319 320 321
                // Settings
                Row {
                    width:      parent.width
                    spacing:    ScreenTools.defaultFontPixelWidth
322

Don Gagne's avatar
Don Gagne committed
323
                    // Left column settings
324
                    Column {
Don Gagne's avatar
Don Gagne committed
325
                        width:      parent.width / 2
326 327
                        spacing:    ScreenTools.defaultFontPixelHeight

Don Gagne's avatar
Don Gagne committed
328
                        QGCLabel { text: qsTr("Additional Joystick settings:") }
329

Don Gagne's avatar
Don Gagne committed
330 331 332
                        Column {
                            width:      parent.width
                            spacing:    ScreenTools.defaultFontPixelHeight
333 334


Don Gagne's avatar
Don Gagne committed
335 336 337 338
                            QGCCheckBox {
                                enabled:    checked || _activeJoystick.calibrated
                                text:       _activeJoystick.calibrated ? qsTr("Enable joystick input") : qsTr("Enable not allowed (Calibrate First)")
                                checked:    _activeVehicle.joystickEnabled
339

Don Gagne's avatar
Don Gagne committed
340
                                onClicked:  _activeVehicle.joystickEnabled = checked
341 342
                            }

Don Gagne's avatar
Don Gagne committed
343 344 345
                            Row {
                                width:      parent.width
                                spacing:    ScreenTools.defaultFontPixelWidth
346

Don Gagne's avatar
Don Gagne committed
347 348 349 350 351
                                QGCLabel {
                                    id:                 activeJoystickLabel
                                    anchors.baseline:   joystickCombo.baseline
                                    text:               qsTr("Active joystick:")
                                }
352

Don Gagne's avatar
Don Gagne committed
353 354 355 356 357 358 359 360 361 362 363 364 365 366
                                QGCComboBox {
                                    id:                 joystickCombo
                                    width:              parent.width - activeJoystickLabel.width - parent.spacing
                                    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
                                        }
367 368
                                    }
                                }
369 370
                            }

Don Gagne's avatar
Don Gagne committed
371 372 373
                            Column {
                                spacing: ScreenTools.defaultFontPixelHeight / 3
                                visible: _activeVehicle.supportsThrottleModeCenterZero
374

Don Gagne's avatar
Don Gagne committed
375
                                ExclusiveGroup { id: throttleModeExclusiveGroup }
376

Don Gagne's avatar
Don Gagne committed
377 378 379 380
                                QGCRadioButton {
                                    exclusiveGroup: throttleModeExclusiveGroup
                                    text:           qsTr("Center stick is zero throttle")
                                    checked:        _activeJoystick.throttleMode == 0
381

Don Gagne's avatar
Don Gagne committed
382 383
                                    onClicked: _activeJoystick.throttleMode = 0
                                }
384

Don Gagne's avatar
Don Gagne committed
385 386 387 388
                                QGCRadioButton {
                                    exclusiveGroup: throttleModeExclusiveGroup
                                    text:           qsTr("Full down stick is zero throttle")
                                    checked:        _activeJoystick.throttleMode == 1
389

Don Gagne's avatar
Don Gagne committed
390 391
                                    onClicked: _activeJoystick.throttleMode = 1
                                }
392 393
                            }

Don Gagne's avatar
Don Gagne committed
394 395
                            Column {
                                spacing: ScreenTools.defaultFontPixelHeight / 3
396

Don Gagne's avatar
Don Gagne committed
397 398 399 400
                                QGCCheckBox {
                                    id:         exponential
                                    checked:    _activeJoystick.exponential
                                    text:       qsTr("Use exponential curve on roll, pitch, yaw")
401

Don Gagne's avatar
Don Gagne committed
402 403
                                    onClicked:  _activeJoystick.exponential = checked
                                }
404 405
                            }

Don Gagne's avatar
Don Gagne committed
406 407 408 409
                            QGCCheckBox {
                                id:         advancedSettings
                                checked:    _activeVehicle.joystickMode != 0
                                text:       qsTr("Advanced settings (careful!)")
410

Don Gagne's avatar
Don Gagne committed
411 412 413 414
                                onClicked: {
                                    if (!checked) {
                                        _activeVehicle.joystickMode = 0
                                    }
415 416 417
                                }
                            }

Don Gagne's avatar
Don Gagne committed
418 419 420 421 422 423 424 425 426 427
                            Row {
                                width:      parent.width
                                spacing:    ScreenTools.defaultFontPixelWidth
                                visible:    advancedSettings.checked

                                QGCLabel {
                                    id:                 joystickModeLabel
                                    anchors.baseline:   joystickModeCombo.baseline
                                    text:               qsTr("Joystick mode:")
                                }
428

Don Gagne's avatar
Don Gagne committed
429 430 431 432 433
                                QGCComboBox {
                                    id:             joystickModeCombo
                                    currentIndex:   _activeVehicle.joystickMode
                                    width:          ScreenTools.defaultFontPixelWidth * 20
                                    model:          _activeVehicle.joystickModes
434

Don Gagne's avatar
Don Gagne committed
435 436
                                    onActivated: _activeVehicle.joystickMode = index
                                }
437 438
                            }
                        }
Don Gagne's avatar
Don Gagne committed
439
                    } // Column - left column
440

Don Gagne's avatar
Don Gagne committed
441 442 443 444
                    // Right column settings
                    Column {
                        width:      parent.width / 2
                        spacing:    ScreenTools.defaultFontPixelHeight
445

Don Gagne's avatar
Don Gagne committed
446 447
                        Connections {
                            target: _activeJoystick
448

Don Gagne's avatar
Don Gagne committed
449 450 451 452 453 454 455
                            onRawButtonPressedChanged: {
                                if (buttonActionRepeater.itemAt(index)) {
                                    buttonActionRepeater.itemAt(index).pressed = pressed
                                }
                                if (jsButtonActionRepeater.itemAt(index)) {
                                    jsButtonActionRepeater.itemAt(index).pressed = pressed
                                }
456
                            }
457 458
                        }

Don Gagne's avatar
Don Gagne committed
459
                        QGCLabel { text: qsTr("Button actions:") }
460

Don Gagne's avatar
Don Gagne committed
461 462 463
                        Column {
                            width:      parent.width
                            spacing:    ScreenTools.defaultFontPixelHeight / 3
464

Don Gagne's avatar
Don Gagne committed
465 466 467
                            QGCLabel {
                                visible: _activeVehicle.manualControlReservedButtonCount != 0
                                text: qsTr("Buttons 0-%1 reserved for firmware use").arg(reservedButtonCount)
468

Don Gagne's avatar
Don Gagne committed
469 470
                                property int reservedButtonCount: _activeVehicle.manualControlReservedButtonCount == -1 ? _activeJoystick.totalButtonCount : _activeVehicle.manualControlReservedButtonCount
                            }
471

Don Gagne's avatar
Don Gagne committed
472 473 474
                            Repeater {
                                id:     buttonActionRepeater
                                model:  _activeJoystick.totalButtonCount
475

Don Gagne's avatar
Don Gagne committed
476 477 478
                                Row {
                                    spacing: ScreenTools.defaultFontPixelWidth
                                    visible: (_activeVehicle.manualControlReservedButtonCount == -1 ? false : modelData >= _activeVehicle.manualControlReservedButtonCount) && !_activeVehicle.supportsJSButton
479

Don Gagne's avatar
Don Gagne committed
480
                                    property bool pressed
481

Don Gagne's avatar
Don Gagne committed
482 483 484
                                    QGCCheckBox {
                                        anchors.verticalCenter:     parent.verticalCenter
                                        checked:                    _activeJoystick.buttonActions[modelData] != ""
485

Don Gagne's avatar
Don Gagne committed
486 487
                                        onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "")
                                    }
488

Don Gagne's avatar
Don Gagne committed
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
                                    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
                                        }
505 506
                                    }

Don Gagne's avatar
Don Gagne committed
507 508 509 510
                                    QGCComboBox {
                                        id:             buttonActionCombo
                                        width:          ScreenTools.defaultFontPixelWidth * 20
                                        model:          _activeJoystick.actions
511

Don Gagne's avatar
Don Gagne committed
512 513 514
                                        onActivated:            _activeJoystick.setButtonAction(modelData, textAt(index))
                                        Component.onCompleted:  currentIndex = find(_activeJoystick.buttonActions[modelData])
                                    }
515
                                }
Don Gagne's avatar
Don Gagne committed
516
                            } // Repeater
517 518 519

                            Row {
                                spacing: ScreenTools.defaultFontPixelWidth
520
                                visible: _activeVehicle.supportsJSButton
521

Don Gagne's avatar
Don Gagne committed
522 523 524 525
                                QGCLabel {
                                    horizontalAlignment:    Text.AlignHCenter
                                    width:                  ScreenTools.defaultFontPixelHeight * 1.5
                                    text:                   qsTr("#")
526 527
                                }

Don Gagne's avatar
Don Gagne committed
528 529 530
                                QGCLabel {
                                    width:                  ScreenTools.defaultFontPixelWidth * 15
                                    text:                   qsTr("Function: ")
531 532
                                }

Don Gagne's avatar
Don Gagne committed
533 534 535
                                QGCLabel {
                                    width:                  ScreenTools.defaultFontPixelWidth * 15
                                    text:                   qsTr("Shift Function: ")
536 537
                                }
                            } // Row
538

Don Gagne's avatar
Don Gagne committed
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
                            Repeater {
                                id:     jsButtonActionRepeater
                                model:  _activeJoystick.totalButtonCount

                                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
                                    }
                                } // Row
                            } // Repeater
                        } // Column
                    } // Column - right setting column
                } // Row - Settings
            } // Column - Left Main Column

            // Right side column
588
            Column {
Don Gagne's avatar
Don Gagne committed
589 590 591 592 593 594 595 596 597 598 599 600 601
                id:             rightColumn
                anchors.top:    parent.top
                anchors.right:  parent.right
                width:          defaultTextWidth * 35
                spacing:        10

                Image {
                    //width:      parent.width
                    height:     defaultTextHeight * 15
                    fillMode:   Image.PreserveAspectFit
                    smooth:     true
                    source:     controller.imageHelp
                }
602

Don Gagne's avatar
Don Gagne committed
603 604 605 606
                // Axis monitor
                Column {
                    width:      parent.width
                    spacing:    5
607

Don Gagne's avatar
Don Gagne committed
608
                    QGCLabel { text: qsTr("Axis Monitor") }
609

Don Gagne's avatar
Don Gagne committed
610 611 612 613 614 615 616
                    Connections {
                        target: controller

                        onAxisValueChanged: {
                            if (axisMonitorRepeater.itemAt(axis)) {
                                axisMonitorRepeater.itemAt(axis).loader.item.axisValue = value
                            }
617 618 619
                        }
                    }

Don Gagne's avatar
Don Gagne committed
620 621 622 623
                    Repeater {
                        id:     axisMonitorRepeater
                        model:  _activeJoystick.axisCount
                        width:  parent.width
624

Don Gagne's avatar
Don Gagne committed
625 626
                        Row {
                            spacing:    5
627

Don Gagne's avatar
Don Gagne committed
628 629
                            // Need this to get to loader from Connections above
                            property Item loader: theLoader
630

Don Gagne's avatar
Don Gagne committed
631 632 633 634
                            QGCLabel {
                                id:     axisLabel
                                text:   modelData
                            }
635

Don Gagne's avatar
Don Gagne committed
636 637 638 639 640 641 642 643 644 645 646
                            Loader {
                                id:                     theLoader
                                anchors.verticalCenter: axisLabel.verticalCenter
                                height:                 ScreenTools.defaultFontPixelHeight
                                width:                  200
                                sourceComponent:        axisMonitorDisplayComponent

                                property real defaultTextWidth:     ScreenTools.defaultFontPixelWidth
                                property bool mapped:               true
                                readonly property bool reversed:    false
                            }
647 648
                        }
                    }
Don Gagne's avatar
Don Gagne committed
649
                } // Column - Axis Monitor
650

Don Gagne's avatar
Don Gagne committed
651 652 653 654
                // Button monitor
                Column {
                    width:      parent.width
                    spacing:    ScreenTools.defaultFontPixelHeight
655

Don Gagne's avatar
Don Gagne committed
656
                    QGCLabel { text: qsTr("Button Monitor") }
657

Don Gagne's avatar
Don Gagne committed
658 659
                    Connections {
                        target: _activeJoystick
660

Don Gagne's avatar
Don Gagne committed
661 662 663 664
                        onRawButtonPressedChanged: {
                            if (buttonMonitorRepeater.itemAt(index)) {
                                buttonMonitorRepeater.itemAt(index).pressed = pressed
                            }
665 666 667
                        }
                    }

Don Gagne's avatar
Don Gagne committed
668 669 670
                    Flow {
                        width:      parent.width
                        spacing:    -1
671

Don Gagne's avatar
Don Gagne committed
672 673 674
                        Repeater {
                            id:     buttonMonitorRepeater
                            model:  _activeJoystick.totalButtonCount
675

Don Gagne's avatar
Don Gagne committed
676 677 678 679 680 681
                            Rectangle {
                                width:          ScreenTools.defaultFontPixelHeight * 1.2
                                height:         width
                                border.width:   1
                                border.color:   qgcPal.text
                                color:          pressed ? qgcPal.buttonHighlight : qgcPal.button
682

Don Gagne's avatar
Don Gagne committed
683
                                property bool pressed
684

Don Gagne's avatar
Don Gagne committed
685 686 687 688 689 690 691
                                QGCLabel {
                                    anchors.fill:           parent
                                    color:                  pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
                                    horizontalAlignment:    Text.AlignHCenter
                                    verticalAlignment:      Text.AlignVCenter
                                    text:                   modelData
                                }
692
                            }
Don Gagne's avatar
Don Gagne committed
693 694 695 696 697 698 699
                        } // Repeater
                    } // Row
                } // Column - Axis Monitor
            } // Column - Right Column
        } // Item
    } // Component - pageComponent
} // SetupPage