Skip to content

Commit

Permalink
Begin migration to integrated param widget
Browse files Browse the repository at this point in the history
don't process updates to unmapped rc channels when we're not in
calibration mode
  • Loading branch information
tstellanova committed Aug 24, 2013
1 parent c373ec7 commit c45feb2
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 208 deletions.
2 changes: 2 additions & 0 deletions src/uas/QGCUASParamManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void QGCUASParamManager::connectToModelAndComms()
void QGCUASParamManager::clearAllPendingParams()
{
paramDataModel.clearAllPendingParams();
emit parameterStatusMsgUpdated(tr("Cleared all pending params"), UASParameterCommsMgr::ParamCommsStatusLevel_OK);

}


Expand Down
141 changes: 59 additions & 82 deletions src/ui/QGCPX4VehicleConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "QGCPX4VehicleConfig.h"

#include "QGC.h"
//#include "QGCPendingParamWidget.h"
#include "QGCToolWidget.h"
#include "UASManager.h"
#include "UASParameterCommsMgr.h"
Expand Down Expand Up @@ -130,8 +129,6 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :

ui->rcCalibrationButton->setCheckable(true);
connect(ui->rcCalibrationButton, SIGNAL(clicked(bool)), this, SLOT(toggleCalibrationRC(bool)));
connect(ui->writeButton, SIGNAL(clicked()),
this, SLOT(writeParameters()));

//TODO connect buttons here to save/clear actions?
UASInterface* tmpMav = UASManager::instance()->getActiveUAS();
Expand Down Expand Up @@ -516,26 +513,29 @@ void QGCPX4VehicleConfig::loadQgcConfig(bool primary)
}
}

// Generate widgets for the Advanced tab.
foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot))
{
if (file.toLower().endsWith(".qgw")) {
QWidget* parent = ui->advanceColumnContents;
tool = new QGCToolWidget("", parent);
if (tool->loadSettings(vehicledir.absoluteFilePath(file), false))
{
toolWidgets.append(tool);
QGroupBox *box = new QGroupBox(parent);
box->setTitle(tool->objectName());
box->setLayout(new QVBoxLayout(box));
box->layout()->addWidget(tool);
ui->advancedColumnLayout->addWidget(box);

} else {
delete tool;
}
}
}
//TODO fix and reintegrate the Advanced parameter editor
// // Generate widgets for the Advanced tab.
// foreach (QString file,vehicledir.entryList(QDir::Files | QDir::NoDotAndDotDot))
// {
// if (file.toLower().endsWith(".qgw")) {
// QWidget* parent = ui->advanceColumnContents;
// tool = new QGCToolWidget("", parent);
// if (tool->loadSettings(vehicledir.absoluteFilePath(file), false))
// {
// toolWidgets.append(tool);
// QGroupBox *box = new QGroupBox(parent);
// box->setTitle(tool->objectName());
// box->setLayout(new QVBoxLayout(box));
// box->layout()->addWidget(tool);
// ui->advancedColumnLayout->addWidget(box);

// } else {
// delete tool;
// }
// }
// }


// Load tabs for general configuration
foreach (QString dir,generaldir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
Expand Down Expand Up @@ -1023,17 +1023,6 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
{
// Hide items if NULL and abort
if (!active) {
ui->refreshButton->setEnabled(false);
ui->refreshButton->show();
ui->readButton->setEnabled(false);
ui->readButton->show();
ui->writeButton->setEnabled(false);
ui->writeButton->show();
ui->loadFileButton->setEnabled(false);
ui->loadFileButton->show();
ui->saveFileButton->setEnabled(false);
ui->saveFileButton->show();

return;
}

Expand All @@ -1051,8 +1040,6 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
//TODO use paramCommsMgr instead
disconnect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant)));
disconnect(ui->refreshButton,SIGNAL(clicked()),
paramMgr,SLOT(requestParameterList()));

// Delete all children from all fixed tabs.
foreach(QWidget* child, ui->generalLeftContents->findChildren<QWidget*>()) {
Expand Down Expand Up @@ -1093,6 +1080,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
paramMgr = mav->getParamManager();

ui->pendingCommitsWidget->setUAS(mav);
ui->paramTreeWidget->setUAS(mav);

// Reset current state
resetCalibrationRC();
Expand All @@ -1106,8 +1094,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
SLOT(remoteControlChannelRawChanged(int,float)));
connect(mav, SIGNAL(parameterChanged(int,int,QString,QVariant)), this,
SLOT(parameterChanged(int,int,QString,QVariant)));
connect(ui->refreshButton, SIGNAL(clicked()),
paramMgr,SLOT(requestParameterList()));


if (systemTypeToParamMap.contains(mav->getSystemTypeName())) {
paramToWidgetMap = systemTypeToParamMap[mav->getSystemTypeName()];
Expand All @@ -1131,22 +1118,7 @@ void QGCPX4VehicleConfig::setActiveUAS(UASInterface* active)
updateStatus(QString("Reading from system %1").arg(mav->getUASName()));

// Since a system is now connected, enable the VehicleConfig UI.
ui->refreshButton->setEnabled(true);
ui->refreshButton->show();
ui->readButton->setEnabled(true);
ui->readButton->show();
ui->writeButton->setEnabled(true);
ui->writeButton->show();
ui->loadFileButton->setEnabled(true);
ui->loadFileButton->show();
ui->saveFileButton->setEnabled(true);
ui->saveFileButton->show();

//TODO never true?
if (mav->getAutopilotTypeName() == "ARDUPILOTMEGA") {
ui->readButton->hide();
ui->writeButton->hide();
}
//TODO anything?
}

void QGCPX4VehicleConfig::resetCalibrationRC()
Expand Down Expand Up @@ -1222,8 +1194,13 @@ void QGCPX4VehicleConfig::remoteControlChannelRawChanged(int chan, float fval)
}

// Raw value
int delta = abs(fval - rcMappedValue[rcToFunctionMapping[chan]]);
if (!configEnabled && !calibrationEnabled && delta < 12 && delta >= 0 && rcValue[chan] > 800 && rcValue[chan] < 2200) {
float mappedVal = rcMappedValue[rcToFunctionMapping[chan]];
bool isMapped = (((float)UINT16_MAX) != mappedVal);
float delta = fabsf(fval - mappedVal);
if (!configEnabled && !calibrationEnabled &&
(!isMapped ||
(delta < 12.0f && rcValue[chan] > 800 && rcValue[chan] < 2200) )
) {
//ignore tiny jitter values
return;
}
Expand Down Expand Up @@ -1690,33 +1667,33 @@ void QGCPX4VehicleConfig::parameterChanged(int uas, int component, QString param
break;
}
}
if (!found) {
//New param type, create a QGroupBox for it.
QWidget* parent = ui->advanceColumnContents;

// Create the tool, attaching it to the QGroupBox
QGCToolWidget *tool = new QGCToolWidget("", parent);
QString tooltitle = parameterName;
if (parameterName.split("_").size() > 1) {
tooltitle = parameterName.split("_")[0] + "_";
}
tool->setTitle(tooltitle);
tool->setObjectName(tooltitle);
//tool->setSettings(set);
libParamToWidgetMap.insert(parameterName,tool);
toolWidgets.append(tool);
tool->addParam(uas, component, parameterName, value);
QGroupBox *box = new QGroupBox(parent);
box->setTitle(tool->objectName());
box->setLayout(new QVBoxLayout(box));
box->layout()->addWidget(tool);

libParamToWidgetMap.insert(parameterName,tool);
toolWidgets.append(tool);
ui->advancedColumnLayout->addWidget(box);

toolToBoxMap[tool] = box;
}
// if (!found) {
// //New param type, create a QGroupBox for it.
// QWidget* parent = ui->advanceColumnContents;

// // Create the tool, attaching it to the QGroupBox
// QGCToolWidget *tool = new QGCToolWidget("", parent);
// QString tooltitle = parameterName;
// if (parameterName.split("_").size() > 1) {
// tooltitle = parameterName.split("_")[0] + "_";
// }
// tool->setTitle(tooltitle);
// tool->setObjectName(tooltitle);
// //tool->setSettings(set);
// libParamToWidgetMap.insert(parameterName,tool);
// toolWidgets.append(tool);
// tool->addParam(uas, component, parameterName, value);
// QGroupBox *box = new QGroupBox(parent);
// box->setTitle(tool->objectName());
// box->setLayout(new QVBoxLayout(box));
// box->layout()->addWidget(tool);

// libParamToWidgetMap.insert(parameterName,tool);
// toolWidgets.append(tool);
// ui->advancedColumnLayout->addWidget(box);

// toolToBoxMap[tool] = box;
// }
}

}
Expand Down
Loading

0 comments on commit c45feb2

Please sign in to comment.