Commit a1083c53 authored by Michael Carpenter's avatar Michael Carpenter

Changes for AdvParameterList number display, and proper handling of CH6/7/8...

Changes for AdvParameterList number display, and proper handling of CH6/7/8 options in ArduCopter pids
parent 922b5d6e
......@@ -39,7 +39,7 @@ void AdvParameterList::parameterChanged(int uas, int component, QString paramete
{
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,0,new QTableWidgetItem("Unknown"));
}
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,1,new QTableWidgetItem(QString::number(value.toFloat(),'g',2)));
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,1,new QTableWidgetItem(QString::number(value.toFloat(),'f',2)));
ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,2,new QTableWidgetItem(parameterName));
if (paramToDescriptionMap.contains(parameterName))
{
......@@ -51,5 +51,5 @@ void AdvParameterList::parameterChanged(int uas, int component, QString paramete
}
paramValueMap[parameterName] = ui.tableWidget->item(ui.tableWidget->rowCount()-1,1);
}
paramValueMap[parameterName]->setText(QString::number(value.toFloat(),'g',2));
paramValueMap[parameterName]->setText(QString::number(value.toFloat(),'f',2));
}
......@@ -49,6 +49,80 @@ ArduCopterPidConfig::ArduCopterPidConfig(QWidget *parent) : AP2ConfigWidget(pare
connect(ui.writePushButton,SIGNAL(clicked()),this,SLOT(writeButtonClicked()));
connect(ui.refreshPushButton,SIGNAL(clicked()),this,SLOT(refreshButtonClicked()));
ch6ValueToTextList.append(QPair<int,QString>(0,"CH6_NONE"));
ch6ValueToTextList.append(QPair<int,QString>(1,"CH6_STABILIZE_KP"));
ch6ValueToTextList.append(QPair<int,QString>(2,"CH6_STABILIZE_KI"));
ch6ValueToTextList.append(QPair<int,QString>(3,"CH6_YAW_KP"));
ch6ValueToTextList.append(QPair<int,QString>(24,"CH6_YAW_KI"));
ch6ValueToTextList.append(QPair<int,QString>(4,"CH6_RATE_KP"));
ch6ValueToTextList.append(QPair<int,QString>(5,"CH6_RATE_KI"));
ch6ValueToTextList.append(QPair<int,QString>(6,"CH6_YAW_RATE_KP"));
ch6ValueToTextList.append(QPair<int,QString>(26,"CH6_YAW_RATE_KD"));
ch6ValueToTextList.append(QPair<int,QString>(7,"CH6_THROTTLE_KP"));
ch6ValueToTextList.append(QPair<int,QString>(9,"CH6_RELAY"));
ch6ValueToTextList.append(QPair<int,QString>(10,"CH6_WP_SPEED"));
ch6ValueToTextList.append(QPair<int,QString>(12,"CH6_LOITER_KP"));
ch6ValueToTextList.append(QPair<int,QString>(13,"CH6_HELI_EXTERNAL_GYRO"));
ch6ValueToTextList.append(QPair<int,QString>(14,"CH6_THR_HOLD_KP"));
ch6ValueToTextList.append(QPair<int,QString>(17,"CH6_OPTFLOW_KP"));
ch6ValueToTextList.append(QPair<int,QString>(18,"CH6_OPTFLOW_KI"));
ch6ValueToTextList.append(QPair<int,QString>(19,"CH6_OPTFLOW_KD"));
ch6ValueToTextList.append(QPair<int,QString>(21,"CH6_RATE_KD"));
ch6ValueToTextList.append(QPair<int,QString>(22,"CH6_LOITER_RATE_KP"));
ch6ValueToTextList.append(QPair<int,QString>(23,"CH6_LOITER_RATE_KD"));
ch6ValueToTextList.append(QPair<int,QString>(25,"CH6_ACRO_KP"));
ch6ValueToTextList.append(QPair<int,QString>(27,"CH6_LOITER_KI"));
ch6ValueToTextList.append(QPair<int,QString>(28,"CH6_LOITER_RATE_KI"));
ch6ValueToTextList.append(QPair<int,QString>(29,"CH6_STABILIZE_KD"));
ch6ValueToTextList.append(QPair<int,QString>(30,"CH6_AHRS_YAW_KP"));
ch6ValueToTextList.append(QPair<int,QString>(31,"CH6_AHRS_KP"));
ch6ValueToTextList.append(QPair<int,QString>(32,"CH6_INAV_TC"));
ch6ValueToTextList.append(QPair<int,QString>(33,"CH6_THROTTLE_KI"));
ch6ValueToTextList.append(QPair<int,QString>(34,"CH6_THR_ACCEL_KP"));
ch6ValueToTextList.append(QPair<int,QString>(35,"CH6_THR_ACCEL_KI"));
ch6ValueToTextList.append(QPair<int,QString>(36,"CH6_THR_ACCEL_KD"));
ch6ValueToTextList.append(QPair<int,QString>(38,"CH6_DECLINATION"));
ch6ValueToTextList.append(QPair<int,QString>(39,"CH6_CIRCLE_RATE"));
for (int i=0;i<ch6ValueToTextList.size();i++)
{
ui.ch6OptComboBox->addItem(ch6ValueToTextList[i].second);
}
ch7ValueToTextList.append(QPair<int,QString>(0,"Do nothing"));
ch7ValueToTextList.append(QPair<int,QString>(2,"Flip"));
ch7ValueToTextList.append(QPair<int,QString>(3,"Simple mode"));
ch7ValueToTextList.append(QPair<int,QString>(4,"RTL"));
ch7ValueToTextList.append(QPair<int,QString>(5,"Save Trim"));
ch7ValueToTextList.append(QPair<int,QString>(7,"Save WP"));
ch7ValueToTextList.append(QPair<int,QString>(8,"Multi Mode"));
ch7ValueToTextList.append(QPair<int,QString>(9,"Camera Trigger"));
ch7ValueToTextList.append(QPair<int,QString>(10,"Sonar"));
ch7ValueToTextList.append(QPair<int,QString>(11,"Fence"));
ch7ValueToTextList.append(QPair<int,QString>(12,"ResetToArmedYaw"));
for (int i=0;i<ch7ValueToTextList.size();i++)
{
ui.ch7OptComboBox->addItem(ch7ValueToTextList[i].second);
}
ch8ValueToTextList.append(QPair<int,QString>(0,"Do nothing"));
ch8ValueToTextList.append(QPair<int,QString>(2,"Flip"));
ch8ValueToTextList.append(QPair<int,QString>(3,"Simple mode"));
ch8ValueToTextList.append(QPair<int,QString>(4,"RTL"));
ch8ValueToTextList.append(QPair<int,QString>(5,"Save Trim"));
ch8ValueToTextList.append(QPair<int,QString>(7,"Save WP"));
ch8ValueToTextList.append(QPair<int,QString>(8,"Multi Mode"));
ch8ValueToTextList.append(QPair<int,QString>(9,"Camera Trigger"));
ch8ValueToTextList.append(QPair<int,QString>(10,"Sonar"));
ch8ValueToTextList.append(QPair<int,QString>(11,"Fence"));
ch8ValueToTextList.append(QPair<int,QString>(12,"ResetToArmedYaw"));
for (int i=0;i<ch8ValueToTextList.size();i++)
{
ui.ch8OptComboBox->addItem(ch8ValueToTextList[i].second);
}
}
ArduCopterPidConfig::~ArduCopterPidConfig()
......@@ -60,6 +134,35 @@ void ArduCopterPidConfig::parameterChanged(int uas, int component, QString param
{
nameToBoxMap[parameterName]->setValue(value.toDouble());
}
else if (parameterName == "TUNE")
{
for (int i=0;i<ch6ValueToTextList.size();i++)
{
if (ch6ValueToTextList[i].first == value.toInt())
{
ui.ch6OptComboBox->setCurrentIndex(i);
}
}
}
else if (parameterName == "CH7_OPT")
{
for (int i=0;i<ch7ValueToTextList.size();i++)
{
if (ch7ValueToTextList[i].first == value.toInt())
{
ui.ch7OptComboBox->setCurrentIndex(i);
}
}
}
else if (parameterName == "CH8_OPT")
{
for (int i=0;i<ch8ValueToTextList.size();i++)
{
if (ch8ValueToTextList[i].first == value.toInt())
{
ui.ch8OptComboBox->setCurrentIndex(i);
}
}
}
void ArduCopterPidConfig::writeButtonClicked()
{
......@@ -71,6 +174,9 @@ void ArduCopterPidConfig::writeButtonClicked()
{
m_uas->getParamManager()->setParameter(1,i.key(),i.value()->value());
}
m_uas->getParamManager()->setParameter(1,"TUNE",ch8ValueToTextList[ui.ch6OptComboBox->currentIndex()].first);
m_uas->getParamManager()->setParameter(1,"CH7_OPT",ch7ValueToTextList[ui.ch7OptComboBox->currentIndex()].first);
m_uas->getParamManager()->setParameter(1,"CH8_OPT",ch8ValueToTextList[ui.ch8OptComboBox->currentIndex()].first);
}
void ArduCopterPidConfig::refreshButtonClicked()
......@@ -83,4 +189,7 @@ void ArduCopterPidConfig::refreshButtonClicked()
{
m_uas->getParamManager()->requestParameterUpdate(1,i.key());
}
m_uas->getParamManager()->requestParameterUpdate(1,"TUNE");
m_uas->getParamManager()->requestParameterUpdate(1,"CH7_OPT");
m_uas->getParamManager()->requestParameterUpdate(1,"CH8_OPT");
}
......@@ -18,6 +18,9 @@ private slots:
void refreshButtonClicked();
void parameterChanged(int uas, int component, QString parameterName, QVariant value);
private:
QList<QPair<int,QString> > ch6ValueToTextList;
QList<QPair<int,QString> > ch7ValueToTextList;
QList<QPair<int,QString> > ch8ValueToTextList;
QMap<QString,QDoubleSpinBox*> nameToBoxMap;
Ui::ArduCopterPidConfig ui;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment