diff --git a/src/uas/QGCUASParamManager.cc b/src/uas/QGCUASParamManager.cc
index 93ab410e2448d417d546c768dd03544f333b0fb3..82ea6f514323f46d47c65799708ce2771c874d64 100644
--- a/src/uas/QGCUASParamManager.cc
+++ b/src/uas/QGCUASParamManager.cc
@@ -23,10 +23,4 @@ void QGCUASParamManager::requestParameterListUpdate(int component)
}
-/**
- * The .. signal is emitted
- */
-void QGCUASParamManager::requestParameterUpdate(int component, const QString& parameter)
-{
-}
diff --git a/src/uas/QGCUASParamManager.h b/src/uas/QGCUASParamManager.h
index 1846f183e6557713c17f8910a9f860b3e2b1b7b3..4a86fbef7b85ee139ea44681e17f4de7f9dd1760 100644
--- a/src/uas/QGCUASParamManager.h
+++ b/src/uas/QGCUASParamManager.h
@@ -20,10 +20,7 @@ public:
/** @brief Request an update for the parameter list */
void requestParameterListUpdate(int component = 0);
/** @brief Request an update for this specific parameter */
- void requestParameterUpdate(int component, const QString& parameter);
-
- /** @brief Request list of parameters from MAV */
- virtual void requestParameterList() = 0;
+ virtual void requestParameterUpdate(int component, const QString& parameter) = 0;
signals:
void parameterChanged(int component, QString parameter, float value);
@@ -31,6 +28,10 @@ signals:
void parameterListUpToDate(int component);
public slots:
+ /** @brief Write one parameter to the MAV */
+ virtual void setParameter(int component, QString parameterName, float value) = 0;
+ /** @brief Request list of parameters from MAV */
+ virtual void requestParameterList() = 0;
protected:
UASInterface* mav; ///< The MAV this widget is controlling
diff --git a/src/ui/QGCParamWidget.cc b/src/ui/QGCParamWidget.cc
index ad79618e4b5b86b6262b4176896715f5fa337bc8..52c0e313f0082bd39dcf91acefafcce909332e86 100644
--- a/src/ui/QGCParamWidget.cc
+++ b/src/ui/QGCParamWidget.cc
@@ -746,6 +746,15 @@ void QGCParamWidget::retransmissionGuardTick()
}
+/**
+ * The .. signal is emitted
+ */
+void QGCParamWidget::requestParameterUpdate(int component, const QString& parameter)
+{
+
+}
+
+
/**
* @param component the subsystem which has the parameter
* @param parameterName name of the parameter, as delivered by the system
diff --git a/src/ui/QGCParamWidget.h b/src/ui/QGCParamWidget.h
index 67db9a2d15f098addb36fdcc57aea0d24e861e7f..9c281a4b549767128610d98248e15d6f2e20b73e 100644
--- a/src/ui/QGCParamWidget.h
+++ b/src/ui/QGCParamWidget.h
@@ -64,6 +64,8 @@ public slots:
void addParameter(int uas, int component, QString parameterName, float value);
/** @brief Request list of parameters from MAV */
void requestParameterList();
+ /** @brief Request one single parameter */
+ void requestParameterUpdate(int component, const QString& parameter);
/** @brief Set one parameter, changes value in RAM of MAV */
void setParameter(int component, QString parameterName, float value);
/** @brief Set all parameters, changes the value in RAM of MAV */
diff --git a/src/ui/designer/QGCActionButton.ui b/src/ui/designer/QGCActionButton.ui
index 16e38a95a1e7953776b85eceddc9dfbf4f4ac32c..e1d73e3c3dce8f7da39bd3a28a89f52b56889e48 100644
--- a/src/ui/designer/QGCActionButton.ui
+++ b/src/ui/designer/QGCActionButton.ui
@@ -13,7 +13,7 @@
Form
-
+
-
diff --git a/src/ui/designer/QGCParamSlider.cc b/src/ui/designer/QGCParamSlider.cc
index ee81c8d55affb4703be5491ecb2a8dcb439022d7..042450566d69caf22160cd832a4cbc254eb06dc1 100644
--- a/src/ui/designer/QGCParamSlider.cc
+++ b/src/ui/designer/QGCParamSlider.cc
@@ -1,6 +1,7 @@
#include
#include
#include
+#include
#include "QGCParamSlider.h"
#include "ui_QGCParamSlider.h"
@@ -42,11 +43,16 @@ QGCParamSlider::QGCParamSlider(QWidget *parent) :
connect(ui->editSelectComponentComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectComponent(int)));
connect(ui->editSelectParamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectParameter(int)));
connect(ui->valueSlider, SIGNAL(valueChanged(int)), this, SLOT(setSliderValue(int)));
+ connect(ui->valueSpinBox, SIGNAL(valueChanged(double)), this, SLOT(setParamValue(double)));
connect(ui->editNameLabel, SIGNAL(textChanged(QString)), ui->nameLabel, SLOT(setText(QString)));
connect(ui->readButton, SIGNAL(clicked()), this, SLOT(requestParameter()));
+ connect(ui->editRefreshParamsButton, SIGNAL(clicked()), this, SLOT(refreshParamList()));
// Set the current UAS if present
setActiveUAS(UASManager::instance()->getActiveUAS());
+
+ // Get param value
+ QTimer::singleShot(1000, this, SLOT(requestParameter()));
}
QGCParamSlider::~QGCParamSlider()
@@ -54,6 +60,16 @@ QGCParamSlider::~QGCParamSlider()
delete ui;
}
+void QGCParamSlider::refreshParamList()
+{
+ ui->editSelectParamComboBox->setEnabled(true);
+ ui->editSelectComponentComboBox->setEnabled(true);
+ if (uas)
+ {
+ uas->getParamManager()->requestParameterList();
+ }
+}
+
void QGCParamSlider::setActiveUAS(UASInterface* activeUas)
{
if (activeUas)
@@ -61,12 +77,10 @@ void QGCParamSlider::setActiveUAS(UASInterface* activeUas)
if (uas)
{
disconnect(uas, SIGNAL(parameterChanged(int,int,int,int,QString,float)), this, SLOT(setParameterValue(int,int,int,int,QString,float)));
- disconnect(ui->editRefreshParamsButton, SIGNAL(clicked()), uas->getParamManager(), SLOT(requestParameterList()));
}
// Connect buttons and signals
connect(activeUas, SIGNAL(parameterChanged(int,int,int,int,QString,float)), this, SLOT(setParameterValue(int,int,int,int,QString,float)), Qt::UniqueConnection);
- connect(ui->editRefreshParamsButton, SIGNAL(clicked()), activeUas->getParamManager(), SLOT(requestParameterList()), Qt::UniqueConnection);
uas = activeUas;
}
}
@@ -79,6 +93,12 @@ void QGCParamSlider::requestParameter()
}
}
+void QGCParamSlider::setParamValue(double value)
+{
+ parameterValue = value;
+ ui->valueSlider->setValue(floatToScaledInt(value));
+}
+
void QGCParamSlider::selectComponent(int componentIndex)
{
this->component = ui->editSelectComponentComboBox->itemData(componentIndex).toInt();
@@ -139,10 +159,10 @@ void QGCParamSlider::endEditMode()
void QGCParamSlider::sendParameter()
{
- if (QGCToolWidgetItem::uas)
+ if (uas)
{
- qDebug() << "SENDING" << component << parameterName << parameterValue;
- QGCToolWidgetItem::uas->setParameter(component, parameterName, parameterValue);
+ // Set value, param manager handles retransmission
+ uas->getParamManager()->setParameter(component, parameterName, parameterValue);
}
else
{
@@ -153,8 +173,9 @@ void QGCParamSlider::sendParameter()
void QGCParamSlider::setSliderValue(int sliderValue)
{
parameterValue = scaledIntToFloat(sliderValue);
- QString unit("");
- ui->valueLabel->setText(QString("%1 %2").arg(parameterValue, 6, 'f', 6, ' ').arg(unit));
+ ui->valueSpinBox->setValue(parameterValue);
+// QString unit("");
+// ui->valueLabel->setText(QString("%1 %2").arg(parameterValue, 6, 'f', 6, ' ').arg(unit));
}
/**
@@ -200,8 +221,7 @@ void QGCParamSlider::setParameterValue(int uas, int component, int paramCount, i
if (component == this->component && parameterName == this->parameterName)
{
parameterValue = value;
- QString unit("");
- ui->valueLabel->setText(QString("%1 %2").arg(value, 0, 'f', 3).arg(unit));
+ ui->valueSpinBox->setValue(value);
ui->valueSlider->setValue(floatToScaledInt(value));
}
}
@@ -221,14 +241,14 @@ void QGCParamSlider::changeEvent(QEvent *e)
float QGCParamSlider::scaledIntToFloat(int sliderValue)
{
float result = (((double)sliderValue)/(double)scaledInt)*(ui->editMaxSpinBox->value() - ui->editMinSpinBox->value());
- qDebug() << "INT TO FLOAT: CONVERTED" << sliderValue << "TO" << result;
+ //qDebug() << "INT TO FLOAT: CONVERTED" << sliderValue << "TO" << result;
return result;
}
int QGCParamSlider::floatToScaledInt(float value)
{
int result = ((value - ui->editMinSpinBox->value())/(ui->editMaxSpinBox->value() - ui->editMinSpinBox->value()))*scaledInt;
- qDebug() << "FLOAT TO INT: CONVERTED" << value << "TO" << result << "SCALEDINT" << scaledInt;
+ //qDebug() << "FLOAT TO INT: CONVERTED" << value << "TO" << result << "SCALEDINT" << scaledInt;
return result;
}
@@ -255,5 +275,6 @@ void QGCParamSlider::readSettings(const QSettings& settings)
ui->editSelectComponentComboBox->addItem(tr("Component #%1").arg(settings.value("QGC_PARAM_SLIDER_COMPONENTID").toInt()), settings.value("QGC_PARAM_SLIDER_COMPONENTID").toInt());
ui->editMinSpinBox->setValue(settings.value("QGC_PARAM_SLIDER_MIN").toFloat());
ui->editMaxSpinBox->setValue(settings.value("QGC_PARAM_SLIDER_MAX").toFloat());
- qDebug() << "DONE READING SETTINGS";
+ ui->editSelectParamComboBox->setEnabled(true);
+ ui->editSelectComponentComboBox->setEnabled(true);
}
diff --git a/src/ui/designer/QGCParamSlider.h b/src/ui/designer/QGCParamSlider.h
index ba941e5c677eaabff34f03026887af6547aebaa8..cadfefcf1e6c2de8fe3dcf113168f16adebfb148 100644
--- a/src/ui/designer/QGCParamSlider.h
+++ b/src/ui/designer/QGCParamSlider.h
@@ -30,9 +30,11 @@ public slots:
void setParameterValue(int uas, int component, int paramCount, int paramIndex, QString parameterName, float value);
void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings);
+ void refreshParamList();
void setActiveUAS(UASInterface *uas);
void selectComponent(int componentIndex);
void selectParameter(int paramIndex);
+ void setParamValue(double value);
protected slots:
/** @brief Request the parameter of this widget from the MAV */
diff --git a/src/ui/designer/QGCParamSlider.ui b/src/ui/designer/QGCParamSlider.ui
index 3b5429f13a42fb6b0c48292b3953fef93cf75ad3..53a34957f091eba77c0671b5048f6fb91874ddcf 100644
--- a/src/ui/designer/QGCParamSlider.ui
+++ b/src/ui/designer/QGCParamSlider.ui
@@ -6,29 +6,35 @@
0
0
- 606
+ 839
179
Form
-
-
-
+
+
+ 6
+
+
+ 12
+
+
-
Informal Name..
- -
+
-
Min
- -
+
-
Max
@@ -45,14 +51,7 @@
- -
-
-
- 0.00
-
-
-
- -
+
-
-999999999.000000000000000
@@ -62,11 +61,11 @@
- -
+
-
- 300
+ 250
16777215
@@ -78,7 +77,7 @@
- -
+
-
-999999999.000000000000000
@@ -88,22 +87,25 @@
- -
+
-
Please configure the parameter slider now:
- -
+
-
Please click first on refresh to update selection menus..
- -
+
-
+
+ false
+
Select component
@@ -112,8 +114,11 @@
- -
+
-
+
+ false
+
Select parameter
@@ -123,24 +128,13 @@
-
-
-
- Transmit the current slider value to the system
-
-
- Transmit the current slider value to the system
-
-
-
-
-
-
- :/images/devices/network-wireless.svg:/images/devices/network-wireless.svg
-
-
-
- -
+
+
+ 0
+ 0
+
+
Read the current parameter value on the system
@@ -152,7 +146,7 @@
- -
+
-
true
@@ -162,15 +156,22 @@
- -
+
-
Done
- -
-
+
-
+
+
+ -999999999.000000000000000
+
+
+ 999999999.000000000000000
+
+
-
@@ -185,6 +186,35 @@
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+ Transmit the current slider value to the system
+
+
+ Transmit the current slider value to the system
+
+
+
+
+
+
+ :/images/devices/network-wireless.svg:/images/devices/network-wireless.svg
+
+
+
diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc
index ccb980c69c8cd3211326386523dff81abda308d4..83bded202f66f6510da93f550a2090327058282c 100644
--- a/src/ui/designer/QGCToolWidget.cc
+++ b/src/ui/designer/QGCToolWidget.cc
@@ -23,6 +23,7 @@ QGCToolWidget::QGCToolWidget(const QString& title, QWidget *parent) :
createActions();
toolLayout = ui->toolLayout;
toolLayout->setAlignment(Qt::AlignTop);
+ toolLayout->setSpacing(8);
QDockWidget* dock = dynamic_cast(this->parentWidget());
if (dock)