20 changed files with 353 additions and 90 deletions
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
[ |
||||
{ |
||||
"name": "Scale", |
||||
"shortDescription": "Scale the RC range", |
||||
"type": "double", |
||||
"min": -1, |
||||
"max": 1, |
||||
"defaultValue": 1, |
||||
"decimalPlaces": 1 |
||||
}, |
||||
{ |
||||
"name": "CenterValue", |
||||
"shortDescription": "Parameter value when RC output is 0", |
||||
"type": "double", |
||||
"min": -180.0, |
||||
"max": 180.0, |
||||
"decimalPlaces": 7 |
||||
}, |
||||
{ |
||||
"name": "MinValue", |
||||
"shortDescription": "Minimum parameter value", |
||||
"type": "double", |
||||
"decimalPlaces": 7 |
||||
}, |
||||
{ |
||||
"name": "MaxValue", |
||||
"shortDescription": "Maximum parameter value", |
||||
"type": "double", |
||||
"decimalPlaces": 7 |
||||
} |
||||
] |
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
/**************************************************************************** |
||||
* |
||||
* (c) 2009-2020 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.12 |
||||
import QtQuick.Layouts 1.2 |
||||
import QtQuick.Controls 2.5 |
||||
import QtQuick.Dialogs 1.3 |
||||
|
||||
import QGroundControl 1.0 |
||||
import QGroundControl.Controls 1.0 |
||||
import QGroundControl.ScreenTools 1.0 |
||||
import QGroundControl.FactSystem 1.0 |
||||
import QGroundControl.FactControls 1.0 |
||||
import QGroundControl.Controllers 1.0 |
||||
|
||||
QGCPopupDialog { |
||||
property alias tuningFact: controller.tuningFact |
||||
|
||||
title: qsTr("RC To Param") |
||||
buttons: StandardButton.Cancel | StandardButton.Ok |
||||
|
||||
function accept() { |
||||
QGroundControl.multiVehicleManager.activeVehicle.sendParamMapRC(tuningFact.name, scale.text, centerValue.text, tuningID.currentIndex, minValue.text, maxValue.text); |
||||
hideDialog() |
||||
} |
||||
|
||||
RCToParamDialogController { |
||||
id: controller |
||||
} |
||||
|
||||
ColumnLayout { |
||||
spacing: ScreenTools.defaultDialogControlSpacing |
||||
|
||||
QGCLabel { |
||||
Layout.preferredWidth: mainGrid.width |
||||
Layout.fillWidth: true |
||||
wrapMode: Text.WordWrap |
||||
text: qsTr("Bind an RC Channel to a parameter value. Tuning IDs can be mapped to an RC Channel from Radio Setup page.") |
||||
} |
||||
|
||||
QGCLabel { |
||||
Layout.preferredWidth: mainGrid.width |
||||
Layout.fillWidth: true |
||||
text: qsTr("Waiting on parameter update from Vehicle.") |
||||
visible: !controller.ready |
||||
} |
||||
|
||||
GridLayout { |
||||
id: mainGrid |
||||
columns: 2 |
||||
rowSpacing: ScreenTools.defaultDialogControlSpacing |
||||
columnSpacing: ScreenTools.defaultDialogControlSpacing |
||||
enabled: controller.ready |
||||
|
||||
QGCLabel { text: qsTr("Parameter") } |
||||
QGCLabel { text: tuningFact.name } |
||||
|
||||
QGCLabel { text: qsTr("Tuning ID") } |
||||
QGCComboBox { |
||||
id: tuningID |
||||
Layout.fillWidth: true |
||||
currentIndex: 0 |
||||
model: [ 1, 2, 3 ] |
||||
} |
||||
|
||||
QGCLabel { text: qsTr("Scale") } |
||||
QGCTextField { |
||||
id: scale |
||||
text: controller.scale.valueString |
||||
} |
||||
|
||||
QGCLabel { text: qsTr("Center Value") } |
||||
QGCTextField { |
||||
id: centerValue |
||||
text: controller.center.valueString |
||||
} |
||||
|
||||
QGCLabel { text: qsTr("Min Value") } |
||||
QGCTextField { |
||||
id: minValue |
||||
text: controller.min.valueString |
||||
} |
||||
|
||||
QGCLabel { text: qsTr("Max Value") } |
||||
QGCTextField { |
||||
id: maxValue |
||||
text: controller.max.valueString |
||||
} |
||||
} |
||||
|
||||
QGCLabel { |
||||
Layout.preferredWidth: mainGrid.width |
||||
Layout.fillWidth: true |
||||
wrapMode: Text.WordWrap |
||||
text: qsTr("Double check that all values are correct prior to confirming dialog.") |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2020 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. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
#include "RCToParamDialogController.h" |
||||
#include "QGCApplication.h" |
||||
#include "ParameterManager.h" |
||||
|
||||
const char* RCToParamDialogController::_scaleFactName = "Scale"; |
||||
const char* RCToParamDialogController::_centerFactName = "CenterValue"; |
||||
const char* RCToParamDialogController::_minFactName = "MinValue"; |
||||
const char* RCToParamDialogController::_maxFactName = "MaxValue"; |
||||
|
||||
QMap<QString, FactMetaData*> RCToParamDialogController::_metaDataMap; |
||||
|
||||
RCToParamDialogController::RCToParamDialogController(void) |
||||
: _scaleFact (0, _scaleFactName, FactMetaData::valueTypeDouble) |
||||
, _centerFact (0, _centerFactName, FactMetaData::valueTypeDouble) |
||||
, _minFact (0, _minFactName, FactMetaData::valueTypeDouble) |
||||
, _maxFact (0, _maxFactName, FactMetaData::valueTypeDouble) |
||||
{ |
||||
if (_metaDataMap.isEmpty()) { |
||||
_metaDataMap = FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/RCToParamDialog.FactMetaData.json"), nullptr /* QObject parent */); |
||||
} |
||||
|
||||
_scaleFact.setMetaData (_metaDataMap[_scaleFactName], true /* setDefaultFromMetaData */); |
||||
_centerFact.setMetaData (_metaDataMap[_centerFactName]); |
||||
_minFact.setMetaData (_metaDataMap[_minFactName]); |
||||
_maxFact.setMetaData (_metaDataMap[_maxFactName]); |
||||
} |
||||
|
||||
void RCToParamDialogController::setTuningFact(Fact* tuningFact) |
||||
{ |
||||
_tuningFact = tuningFact; |
||||
emit tuningFactChanged(tuningFact); |
||||
|
||||
_centerFact.setRawValue(_tuningFact->rawValue().toDouble()); |
||||
_minFact.setRawValue(_tuningFact->rawMin().toDouble()); |
||||
_maxFact.setRawValue(_tuningFact->rawMax().toDouble()); |
||||
|
||||
connect(_tuningFact, &Fact::vehicleUpdated, this, &RCToParamDialogController::_parameterUpdated); |
||||
qgcApp()->toolbox()->multiVehicleManager()->activeVehicle()->parameterManager()->refreshParameter(FactSystem::defaultComponentId, _tuningFact->name()); |
||||
} |
||||
|
||||
void RCToParamDialogController::_parameterUpdated(void) |
||||
{ |
||||
_ready = true; |
||||
emit readyChanged(true); |
||||
} |
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2020 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. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
#pragma once |
||||
|
||||
#include <QObject> |
||||
#include <QGeoCoordinate> |
||||
|
||||
#include "FactSystem.h" |
||||
|
||||
class RCToParamDialogController : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
RCToParamDialogController(void); |
||||
|
||||
Q_PROPERTY(Fact* tuningFact READ tuningFact WRITE setTuningFact NOTIFY tuningFactChanged) |
||||
Q_PROPERTY(bool ready MEMBER _ready NOTIFY readyChanged) // true: editing can begin, false: still waiting for param update from vehicle
|
||||
Q_PROPERTY(Fact* scale READ scale CONSTANT) |
||||
Q_PROPERTY(Fact* center READ center CONSTANT) |
||||
Q_PROPERTY(Fact* min READ min CONSTANT) |
||||
Q_PROPERTY(Fact* max READ max CONSTANT) |
||||
|
||||
Fact* tuningFact (void) { return _tuningFact; } |
||||
Fact* scale (void) { return &_scaleFact; } |
||||
Fact* center (void) { return &_centerFact; } |
||||
Fact* min (void) { return &_minFact; } |
||||
Fact* max (void) { return &_maxFact; } |
||||
void setTuningFact (Fact* tuningFact); |
||||
|
||||
signals: |
||||
void tuningFactChanged (Fact* fact); |
||||
void readyChanged (bool ready); |
||||
|
||||
private slots: |
||||
void _parameterUpdated(void); |
||||
|
||||
private: |
||||
static QMap<QString, FactMetaData*> _metaDataMap; |
||||
|
||||
Fact* _tuningFact = nullptr; |
||||
bool _ready = false; |
||||
Fact _scaleFact; |
||||
Fact _centerFact; |
||||
Fact _minFact; |
||||
Fact _maxFact; |
||||
|
||||
static const char* _scaleFactName; |
||||
static const char* _centerFactName; |
||||
static const char* _minFactName; |
||||
static const char* _maxFactName; |
||||
}; |
Loading…
Reference in new issue