1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

OP-867 Added output rate settings for revolution.

This commit is contained in:
Fredrik Arvidsson 2013-03-11 23:22:10 +01:00
parent f1214df633
commit f27a69802d
2 changed files with 280 additions and 123 deletions

View File

@ -244,13 +244,12 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject * obj)
Q_ASSERT(actuatorSettings); Q_ASSERT(actuatorSettings);
ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData(); ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData();
// get channel descriptions // Get channel descriptions
QStringList ChannelDesc = ConfigVehicleTypeWidget::getChannelDescriptions(); QStringList ChannelDesc = ConfigVehicleTypeWidget::getChannelDescriptions();
// Initialize output forms // Initialize output forms
QList<OutputChannelForm*> outputChannelForms = findChildren<OutputChannelForm*>(); QList<OutputChannelForm*> outputChannelForms = findChildren<OutputChannelForm*>();
foreach(OutputChannelForm *outputChannelForm, outputChannelForms) foreach(OutputChannelForm *outputChannelForm, outputChannelForms) {
{
outputChannelForm->setAssignment(ChannelDesc[outputChannelForm->index()]); outputChannelForm->setAssignment(ChannelDesc[outputChannelForm->index()]);
// init min,max,neutral // init min,max,neutral
@ -265,25 +264,57 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject * obj)
// Get the SpinWhileArmed setting // Get the SpinWhileArmed setting
m_config->spinningArmed->setChecked(actuatorSettingsData.MotorsSpinWhileArmed == ActuatorSettings::MOTORSSPINWHILEARMED_TRUE); m_config->spinningArmed->setChecked(actuatorSettingsData.MotorsSpinWhileArmed == ActuatorSettings::MOTORSSPINWHILEARMED_TRUE);
// Get Output rates for both banks // Setup output rates for all banks
if(m_config->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0]))==-1) if(m_config->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0])) == -1) {
{
m_config->cb_outputRate1->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[0])); m_config->cb_outputRate1->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[0]));
} }
if(m_config->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1]))==-1) if(m_config->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1])) == -1) {
{
m_config->cb_outputRate2->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[1])); m_config->cb_outputRate2->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[1]));
} }
if(m_config->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2]) )== -1) {
m_config->cb_outputRate3->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[2]));
}
if(m_config->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])) == -1) {
m_config->cb_outputRate4->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[3]));
}
if(m_config->cb_outputRate5->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[4])) == -1) {
m_config->cb_outputRate5->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[4]));
}
if(m_config->cb_outputRate6->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[5])) == -1) {
m_config->cb_outputRate6->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[5]));
}
m_config->cb_outputRate1->setCurrentIndex(m_config->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0]))); m_config->cb_outputRate1->setCurrentIndex(m_config->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0])));
m_config->cb_outputRate2->setCurrentIndex(m_config->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1]))); m_config->cb_outputRate2->setCurrentIndex(m_config->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1])));
m_config->cb_outputRate3->setCurrentIndex(m_config->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2])));
m_config->cb_outputRate4->setCurrentIndex(m_config->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])));
m_config->cb_outputRate3->setCurrentIndex(m_config->cb_outputRate5->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[4])));
m_config->cb_outputRate4->setCurrentIndex(m_config->cb_outputRate6->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[5])));
// Reset to all disabled
m_config->chBank1->setText("-");
m_config->chBank2->setText("-");
m_config->chBank3->setText("-");
m_config->chBank4->setText("-");
m_config->chBank5->setText("-");
m_config->chBank6->setText("-");
m_config->cb_outputRate1->setEnabled(false);
m_config->cb_outputRate2->setEnabled(false);
m_config->cb_outputRate3->setEnabled(false);
m_config->cb_outputRate4->setEnabled(false);
m_config->cb_outputRate5->setEnabled(false);
m_config->cb_outputRate6->setEnabled(false);
// Get connected board model
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
Q_ASSERT(pm); Q_ASSERT(pm);
UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>(); UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
if (utilMngr) { Q_ASSERT(utilMngr);
if(utilMngr) {
int board = utilMngr->getBoardModel(); int board = utilMngr->getBoardModel();
if ((board & 0xff00) == 1024) { // Setup labels and combos for banks according to board type
// CopterControl family if ((board & 0xff00) == 0x0400) {
// Coptercontrol family of boards 4 timer banks
m_config->chBank1->setText("1-3"); m_config->chBank1->setText("1-3");
m_config->chBank2->setText("4"); m_config->chBank2->setText("4");
m_config->chBank3->setText("5,7-8"); m_config->chBank3->setText("5,7-8");
@ -292,37 +323,27 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject * obj)
m_config->cb_outputRate2->setEnabled(true); m_config->cb_outputRate2->setEnabled(true);
m_config->cb_outputRate3->setEnabled(true); m_config->cb_outputRate3->setEnabled(true);
m_config->cb_outputRate4->setEnabled(true); m_config->cb_outputRate4->setEnabled(true);
if(m_config->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2]))==-1) }
{ else if((board & 0xff00) == 0x0900) {
m_config->cb_outputRate3->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[2])); // Revolution family of boards 6 timer banks
} m_config->chBank1->setText("1-2");
if(m_config->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3]))==-1) m_config->chBank2->setText("3");
{ m_config->chBank3->setText("4");
m_config->cb_outputRate4->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])); m_config->chBank4->setText("5-6");
} m_config->chBank5->setText("7-8");
m_config->cb_outputRate3->setCurrentIndex(m_config->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2]))); m_config->chBank6->setText("9-10");
m_config->cb_outputRate4->setCurrentIndex(m_config->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])));
} else if ((board & 0xff00) == 256 ) {
// Mainboard family
m_config->cb_outputRate1->setEnabled(true); m_config->cb_outputRate1->setEnabled(true);
m_config->cb_outputRate2->setEnabled(true); m_config->cb_outputRate2->setEnabled(true);
m_config->cb_outputRate3->setEnabled(false); m_config->cb_outputRate3->setEnabled(true);
m_config->cb_outputRate4->setEnabled(false); m_config->cb_outputRate4->setEnabled(true);
m_config->chBank1->setText("1-4"); m_config->cb_outputRate5->setEnabled(true);
m_config->chBank2->setText("5-8"); m_config->cb_outputRate6->setEnabled(true);
m_config->chBank3->setText("-");
m_config->chBank4->setText("-");
m_config->cb_outputRate3->addItem("0");
m_config->cb_outputRate3->setCurrentIndex(m_config->cb_outputRate3->findText("0"));
m_config->cb_outputRate4->addItem("0");
m_config->cb_outputRate4->setCurrentIndex(m_config->cb_outputRate4->findText("0"));
} }
} }
// Get Channel ranges: // Get Channel ranges:
foreach(OutputChannelForm *outputChannelForm, outputChannelForms) foreach(OutputChannelForm *outputChannelForm, outputChannelForms) {
{ int minValue = actuatorSettingsData.ChannelMin[outputChannelForm->index()];
int minValue = actuatorSettingsData.ChannelMin[outputChannelForm->index()];
int maxValue = actuatorSettingsData.ChannelMax[outputChannelForm->index()]; int maxValue = actuatorSettingsData.ChannelMax[outputChannelForm->index()];
outputChannelForm->minmax(minValue, maxValue); outputChannelForm->minmax(minValue, maxValue);
@ -345,8 +366,7 @@ void ConfigOutputWidget::updateObjectsFromWidgets()
// Set channel ranges // Set channel ranges
QList<OutputChannelForm*> outputChannelForms = findChildren<OutputChannelForm*>(); QList<OutputChannelForm*> outputChannelForms = findChildren<OutputChannelForm*>();
foreach(OutputChannelForm *outputChannelForm, outputChannelForms) foreach(OutputChannelForm *outputChannelForm, outputChannelForms) {
{
actuatorSettingsData.ChannelMax[outputChannelForm->index()] = outputChannelForm->max(); actuatorSettingsData.ChannelMax[outputChannelForm->index()] = outputChannelForm->max();
actuatorSettingsData.ChannelMin[outputChannelForm->index()] = outputChannelForm->min(); actuatorSettingsData.ChannelMin[outputChannelForm->index()] = outputChannelForm->min();
actuatorSettingsData.ChannelNeutral[outputChannelForm->index()] = outputChannelForm->neutral(); actuatorSettingsData.ChannelNeutral[outputChannelForm->index()] = outputChannelForm->neutral();
@ -357,11 +377,12 @@ void ConfigOutputWidget::updateObjectsFromWidgets()
actuatorSettingsData.ChannelUpdateFreq[1] = m_config->cb_outputRate2->currentText().toUInt(); actuatorSettingsData.ChannelUpdateFreq[1] = m_config->cb_outputRate2->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[2] = m_config->cb_outputRate3->currentText().toUInt(); actuatorSettingsData.ChannelUpdateFreq[2] = m_config->cb_outputRate3->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[3] = m_config->cb_outputRate4->currentText().toUInt(); actuatorSettingsData.ChannelUpdateFreq[3] = m_config->cb_outputRate4->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[4] = m_config->cb_outputRate5->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[5] = m_config->cb_outputRate6->currentText().toUInt();
if(m_config->spinningArmed->isChecked() == true) actuatorSettingsData.MotorsSpinWhileArmed = m_config->spinningArmed->isChecked() ?
actuatorSettingsData.MotorsSpinWhileArmed = ActuatorSettings::MOTORSSPINWHILEARMED_TRUE; ActuatorSettings::MOTORSSPINWHILEARMED_TRUE :
else ActuatorSettings::MOTORSSPINWHILEARMED_FALSE;
actuatorSettingsData.MotorsSpinWhileArmed = ActuatorSettings::MOTORSSPINWHILEARMED_FALSE;
// Apply settings // Apply settings
actuatorSettings->setData(actuatorSettingsData); actuatorSettings->setData(actuatorSettingsData);
@ -370,7 +391,6 @@ void ConfigOutputWidget::updateObjectsFromWidgets()
void ConfigOutputWidget::openHelp() void ConfigOutputWidget::openHelp()
{ {
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/x/WIGf", QUrl::StrictMode) ); QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/x/WIGf", QUrl::StrictMode) );
} }
@ -381,11 +401,12 @@ void ConfigOutputWidget::stopTests()
void ConfigOutputWidget::disableIfNotMe(UAVObject* obj) void ConfigOutputWidget::disableIfNotMe(UAVObject* obj)
{ {
if(UAVObject::GetGcsTelemetryUpdateMode(obj->getMetadata()) == UAVObject::UPDATEMODE_ONCHANGE) if(UAVObject::GetGcsTelemetryUpdateMode(obj->getMetadata()) == UAVObject::UPDATEMODE_ONCHANGE) {
{ if(!wasItMe) {
if(!wasItMe)
this->setEnabled(false); this->setEnabled(false);
}
} }
else else {
this->setEnabled(true); this->setEnabled(true);
}
} }

View File

@ -117,12 +117,12 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>668</width> <width>668</width>
<height>654</height> <height>671</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing"> <property name="spacing">
<number>-1</number> <number>6</number>
</property> </property>
<property name="margin"> <property name="margin">
<number>12</number> <number>12</number>
@ -145,27 +145,31 @@
<string>Output Update Speed</string> <string>Output Update Speed</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="margin"> <property name="margin">
<number>12</number> <number>12</number>
</property> </property>
<item row="0" column="0"> <property name="horizontalSpacing">
<spacer name="horizontalSpacer_3"> <number>6</number>
<property name="orientation"> </property>
<enum>Qt::Horizontal</enum> <item row="0" column="6">
<widget class="QLabel" name="chBank5">
<property name="text">
<string>-</string>
</property> </property>
<property name="sizeType"> <property name="alignment">
<enum>QSizePolicy::Minimum</enum> <set>Qt::AlignCenter</set>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>5</width> <item row="0" column="2">
<height>20</height> <widget class="QLabel" name="chBank1">
</size> <property name="text">
<string>-</string>
</property> </property>
</spacer> <property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="label_9">
@ -183,45 +187,21 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="0">
<widget class="QLabel" name="chBank1"> <spacer name="horizontalSpacer_3">
<property name="text"> <property name="orientation">
<string>-</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="alignment"> <property name="sizeType">
<set>Qt::AlignCenter</set> <enum>QSizePolicy::Minimum</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
<item row="0" column="3"> <width>5</width>
<widget class="QLabel" name="chBank2"> <height>20</height>
<property name="text"> </size>
<string>-</string>
</property> </property>
<property name="alignment"> </spacer>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="chBank3">
<property name="text">
<string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="chBank4">
<property name="text">
<string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<spacer name="horizontalSpacer_4"> <spacer name="horizontalSpacer_4">
@ -251,31 +231,33 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="1"> <item row="0" column="3">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="chBank2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text"> <property name="text">
<string>Update rate:</string> <string>-</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="chBank3">
<property name="text">
<string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="chBank4">
<property name="text">
<string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -395,6 +377,34 @@ Leave at 50Hz for fixed wing.</string>
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Update rate:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="4"> <item row="1" column="4">
<widget class="QComboBox" name="cb_outputRate3"> <widget class="QComboBox" name="cb_outputRate3">
<property name="enabled"> <property name="enabled">
@ -472,6 +482,132 @@ Leave at 50Hz for fixed wing.</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Setup &quot;TurboPWM&quot; here: usual value is 400 Hz for multirotor airframes. <string>Setup &quot;TurboPWM&quot; here: usual value is 400 Hz for multirotor airframes.
Leave at 50Hz for fixed wing.</string>
</property>
<item>
<property name="text">
<string>50</string>
</property>
</item>
<item>
<property name="text">
<string>60</string>
</property>
</item>
<item>
<property name="text">
<string>125</string>
</property>
</item>
<item>
<property name="text">
<string>165</string>
</property>
</item>
<item>
<property name="text">
<string>270</string>
</property>
</item>
<item>
<property name="text">
<string>330</string>
</property>
</item>
<item>
<property name="text">
<string>400</string>
</property>
</item>
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="chBank6">
<property name="text">
<string>-</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QComboBox" name="cb_outputRate5">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Setup &quot;TurboPWM&quot; here: usual value is 400 Hz for multirotor airframes.
Leave at 50Hz for fixed wing.</string>
</property>
<item>
<property name="text">
<string>50</string>
</property>
</item>
<item>
<property name="text">
<string>60</string>
</property>
</item>
<item>
<property name="text">
<string>125</string>
</property>
</item>
<item>
<property name="text">
<string>165</string>
</property>
</item>
<item>
<property name="text">
<string>270</string>
</property>
</item>
<item>
<property name="text">
<string>330</string>
</property>
</item>
<item>
<property name="text">
<string>400</string>
</property>
</item>
</widget>
</item>
<item row="1" column="7">
<widget class="QComboBox" name="cb_outputRate6">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="toolTip">
<string>Setup &quot;TurboPWM&quot; here: usual value is 400 Hz for multirotor airframes.
Leave at 50Hz for fixed wing.</string> Leave at 50Hz for fixed wing.</string>
</property> </property>
<item> <item>