diff --git a/src/AutoPilotPlugins/PX4/CameraComponent.qml b/src/AutoPilotPlugins/PX4/CameraComponent.qml index dfd079cad96193b3280ccb9321c11ba219da9a00..63c50750529ba1d07784aa54cc791ab61dfa7a58 100644 --- a/src/AutoPilotPlugins/PX4/CameraComponent.qml +++ b/src/AutoPilotPlugins/PX4/CameraComponent.qml @@ -49,8 +49,9 @@ QGCView { property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 18 property Fact _camTriggerMode: controller.getParameterFact(-1, "TRIG_MODE") + property Fact _camTriggerPol: controller.getParameterFact(-1, "TRIG_POLARITY", false) // Don't bitch about missing as these only exist if trigger mode is enabled + property Fact _auxPins: controller.getParameterFact(-1, "TRIG_PINS", false) // Ditto - property bool _hasFacts: false property bool _rebooting: false property var _auxChannels: [ 0, 0, 0, 0, 0, 0] @@ -61,28 +62,24 @@ QGCView { } function setAuxPins() { - var values = [] - for(var i = 0; i < 6; i++) { - if(_auxChannels[i]) { - values.push((i+1).toString()) + if(_auxPins) { + var values = "" + for(var i = 0; i < 6; i++) { + if(_auxChannels[i]) { + values += ((i+1).toString()) + } } + _auxPins.value = parseInt(values) } - var auxFact = controller.getParameterFact(-1, "TRIG_PINS") - auxFact.value = parseInt(values) - console.log(values) } Component.onCompleted: { - _hasFacts = _camTriggerMode.value > 0 - if(_hasFacts) { + if(_auxPins) { clearAuxArray() - var auxFact = controller.getParameterFact(-1, "TRIG_PINS") - var values = auxFact.value.toString() - console.log(values) + var values = _auxPins.value.toString() for(var i = 0; i < values.length; i++) { var b = parseInt(values[i]) - 1 if(b >= 0 && b < 6) { - console.log(b) _auxChannels[b] = 1 } } @@ -110,6 +107,7 @@ QGCView { anchors.right: parent.right text: qsTr("Apply and Restart") onClicked: { + //-- This will reboot the vehicle! We're set not to allow changes if armed. QGroundControl.multiVehicleManager.activeVehicle.rebootVehicle() applyAndRestart.visible = false _rebooting = true @@ -120,14 +118,14 @@ QGCView { clip: true anchors.top: applyAndRestart.visible ? applyAndRestart.bottom : parent.top anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - width: mainCol.width + anchors.left: parent.left + anchors.right: parent.right contentHeight: mainCol.height - contentWidth: mainCol.width flickableDirection: Flickable.VerticalFlick Column { id: mainCol spacing: _margins + anchors.horizontalCenter: parent.horizontalCenter /* **** Camera Trigger **** */ @@ -185,10 +183,10 @@ QGCView { } FactTextField { id: timeIntervalField - fact: _hasFacts ? controller.getParameterFact(-1, "TRIG_INTERVAL") : null + fact: controller.getParameterFact(-1, "TRIG_INTERVAL", false) showUnits: true width: _editFieldWidth - enabled: _hasFacts && _camTriggerMode.value === 2 + enabled: _auxPins && _camTriggerMode.value === 2 } } Row { @@ -200,10 +198,10 @@ QGCView { } FactTextField { id: trigDistField - fact: _hasFacts ? controller.getParameterFact(-1, "TRIG_DISTANCE") : null + fact: controller.getParameterFact(-1, "TRIG_DISTANCE", false) showUnits: true width: _editFieldWidth - enabled: _hasFacts && _camTriggerMode.value === 3 + enabled: _auxPins && _camTriggerMode.value === 3 } } } @@ -216,20 +214,17 @@ QGCView { QGCLabel { text: qsTr("Hardware Settings") font.weight: Font.DemiBold - visible: _hasFacts + visible: _auxPins } Rectangle { color: palette.windowShade width: camTrigRect.width height: camHardwareRow.height + _margins * 2 - visible: _hasFacts + visible: _auxPins Row { id: camHardwareRow spacing: _margins anchors.verticalCenter: parent.verticalCenter - - property Fact _camTriggerPol: controller.getParameterFact(-1, "TRIG_POLARITY") - Item { width: _margins * 0.5; height: 1; } Item { height: ScreenTools.defaultFontPixelWidth * 10 @@ -258,13 +253,23 @@ QGCView { width: ScreenTools.defaultFontPixelWidth * 2 height: ScreenTools.defaultFontPixelWidth * 2 border.color: palette.text - color: _auxChannels[model.index] ? "green" : palette.windowShadeDark + color: { + if(_auxPins) { + var pins = _auxPins.value.toString() + var pin = (model.index + 1).toString() + if(pins.indexOf(pin) < 0) + return palette.windowShadeDark + else + return "green" + } else { + return palette.windowShade + } + } MouseArea { anchors.fill: parent onClicked: { _auxChannels[model.index] = 1 - _auxChannels[model.index] auxPin.color = _auxChannels[model.index] ? "green" : palette.windowShadeDark - console.log(model.index + " " + _auxChannels[model.index]) setAuxPins() } } @@ -288,20 +293,28 @@ QGCView { spacing: _margins * 0.5 ExclusiveGroup { id: polarityGroup } QGCRadioButton { - checked: _hasFacts && camHardwareRow._camTriggerPol.value === 0 + checked: _camTriggerPol && _camTriggerPol.value === 0 exclusiveGroup: polarityGroup text: "Low (0V)" - onClicked: _camTriggerPol.value = 0 + onClicked: { + if(_camTriggerPol) { + _camTriggerPol.value = 0 + } + } } QGCRadioButton { - checked: _hasFacts && camHardwareRow._camTriggerPol.value > 0 + checked: _camTriggerPol && _camTriggerPol.value > 0 exclusiveGroup: polarityGroup text: "High (3.3V)" - onClicked: _camTriggerPol.value = 1 + onClicked: { + if(_camTriggerPol) { + _camTriggerPol.value = 1 + } + } } } } - Item { width: 1; height: _margins; } + Item { width: 1; height: _margins * 0.5; } Row { QGCLabel { text: qsTr("Trigger Period") @@ -311,7 +324,7 @@ QGCView { } FactTextField { id: trigPeriodField - fact: controller.getParameterFact(-1, "TRIG_ACT_TIME") + fact: controller.getParameterFact(-1, "TRIG_ACT_TIME", false) showUnits: true width: _editFieldWidth } diff --git a/src/AutoPilotPlugins/PX4/CameraComponentSummary.qml b/src/AutoPilotPlugins/PX4/CameraComponentSummary.qml index 3d3765f1344959c840be8d1b1a6e05cb1968c811..79aa77724d626f4d2c5332ce7b6d9418aa0639ac 100644 --- a/src/AutoPilotPlugins/PX4/CameraComponentSummary.qml +++ b/src/AutoPilotPlugins/PX4/CameraComponentSummary.qml @@ -15,15 +15,43 @@ FactPanel { FactPanelController { id: controller; factPanel: panel } property Fact _camTriggerMode: controller.getParameterFact(-1, "TRIG_MODE") + property Fact _camTriggerPol: controller.getParameterFact(-1, "TRIG_POLARITY", false) // Don't bitch about missing as these only exist if trigger mode is enabled + property Fact _auxPins: controller.getParameterFact(-1, "TRIG_PINS", false) // Ditto + property Fact _timeInterval: controller.getParameterFact(-1, "TRIG_INTERVAL", false) // Ditto + property Fact _distanceInterval:controller.getParameterFact(-1, "TRIG_DISTANCE", false) // Ditto Column { anchors.fill: parent anchors.margins: 8 VehicleSummaryRow { - labelText: qsTr("Camera Trigger Mode:") + labelText: qsTr("Camera trigger mode:") valueText: _camTriggerMode ? _camTriggerMode.enumStringValue : "" } + VehicleSummaryRow { + visible: _timeInterval && _camTriggerMode.value === 2 + labelText: qsTr("Time interval:") + valueText: _timeInterval ? _timeInterval.value : "" + } + + VehicleSummaryRow { + visible: _distanceInterval && _camTriggerMode.value === 3 + labelText: qsTr("Distance interval:") + valueText: _distanceInterval ? _distanceInterval.value : "" + } + + VehicleSummaryRow { + visible: _auxPins + labelText: qsTr("AUX pins:") + valueText: _auxPins ? _auxPins.value : "" + } + + VehicleSummaryRow { + visible: _camTriggerPol + labelText: qsTr("AUX pin polarity:") + valueText: _camTriggerPol ? (_camTriggerPol.value ? "High (3.3V)" : "Low (0V)") : "" + } + } } diff --git a/src/FactSystem/FactControls/FactPanelController.cc b/src/FactSystem/FactControls/FactPanelController.cc index 83e1696f1ef16132e0c78dba6b60dad9b41fe95d..288b409446ee43697a565ad8e8ef823b32c4a832 100644 --- a/src/FactSystem/FactControls/FactPanelController.cc +++ b/src/FactSystem/FactControls/FactPanelController.cc @@ -129,14 +129,15 @@ void FactPanelController::_checkForMissingFactPanel(void) } } -Fact* FactPanelController::getParameterFact(int componentId, const QString& name) +Fact* FactPanelController::getParameterFact(int componentId, const QString& name, bool reportMissing) { if (_autopilot && _autopilot->parameterExists(componentId, name)) { Fact* fact = _autopilot->getParameterFact(componentId, name); QQmlEngine::setObjectOwnership(fact, QQmlEngine::CppOwnership); return fact; } else { - _reportMissingParameter(componentId, name); + if(reportMissing) + _reportMissingParameter(componentId, name); return NULL; } } diff --git a/src/FactSystem/FactControls/FactPanelController.h b/src/FactSystem/FactControls/FactPanelController.h index 69dc7ee17400986550ee01f8fd067fe21755745b..0c177dbbeb5f538aa3d75ec397a5e12a7f16bd06 100644 --- a/src/FactSystem/FactControls/FactPanelController.h +++ b/src/FactSystem/FactControls/FactPanelController.h @@ -1,24 +1,24 @@ /*===================================================================== - + QGroundControl Open Source Ground Control Station - + (c) 2009 - 2014 QGROUNDCONTROL PROJECT - + This file is part of the QGROUNDCONTROL project - + QGROUNDCONTROL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + QGROUNDCONTROL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with QGROUNDCONTROL. If not, see . - + ======================================================================*/ #ifndef FactPanelController_H @@ -40,34 +40,34 @@ Q_DECLARE_LOGGING_CATEGORY(FactPanelControllerLog) /// missing Facts from C++ code. class FactPanelController : public QObject { - Q_OBJECT - + Q_OBJECT + public: - FactPanelController(void); - + FactPanelController(void); + Q_PROPERTY(QQuickItem* factPanel READ factPanel WRITE setFactPanel) - - Q_INVOKABLE Fact* getParameterFact(int componentId, const QString& name); - Q_INVOKABLE bool parameterExists(int componentId, const QString& name); - + + Q_INVOKABLE Fact* getParameterFact (int componentId, const QString& name, bool reportMissing = true); + Q_INVOKABLE bool parameterExists (int componentId, const QString& name); + QQuickItem* factPanel(void); void setFactPanel(QQuickItem* panel); - + protected: /// Checks for existence of the specified parameters /// @return true: all parameters exists, false: parameters missing and reported bool _allParametersExists(int componentId, QStringList names); - + /// Report a missing parameter to the FactPanel Qml element void _reportMissingParameter(int componentId, const QString& name); - + Vehicle* _vehicle; UASInterface* _uas; AutoPilotPlugin* _autopilot; - + private slots: void _checkForMissingFactPanel(void); - + private: void _notifyPanelMissingParameter(const QString& missingParam); void _notifyPanelErrorMsg(const QString& errorMsg); @@ -77,4 +77,4 @@ private: QStringList _delayedMissingParams; }; -#endif \ No newline at end of file +#endif