1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Updates to ccpm mixer ui.

the curve settings now update the MixerCurveWidgets when generated or manually edited.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2046 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
andrew 2010-10-31 05:55:23 +00:00 committed by andrew
parent beda5965bf
commit bc8ec75ed5
3 changed files with 213 additions and 118 deletions

View File

@ -33,24 +33,24 @@
<rect>
<x>0</x>
<y>30</y>
<width>731</width>
<width>681</width>
<height>470</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>692</width>
<width>660</width>
<height>419</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -61,7 +61,7 @@
<rect>
<x>0</x>
<y>10</y>
<width>721</width>
<width>657</width>
<height>427</height>
</rect>
</property>
@ -482,7 +482,7 @@
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_7">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="ccpmPitchMixingBox">
<property name="enabled">
@ -497,13 +497,13 @@
<property name="minimumSize">
<size>
<width>50</width>
<height>250</height>
<height>200</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>250</height>
<height>200</height>
</size>
</property>
<property name="font">
@ -522,12 +522,12 @@
<rect>
<x>0</x>
<y>20</y>
<width>48</width>
<height>218</height>
<width>54</width>
<height>168</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="enabled">
<bool>true</bool>
@ -543,7 +543,7 @@
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_3">
@ -564,7 +564,7 @@
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -572,7 +572,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
<height>100</height>
</size>
</property>
<property name="maximum">
@ -604,7 +604,7 @@
</item>
</layout>
</item>
<item>
<item row="2" column="0">
<widget class="QLabel" name="label_16">
<property name="enabled">
<bool>true</bool>
@ -617,7 +617,7 @@
</property>
</widget>
</item>
<item>
<item row="3" column="0">
<widget class="QSpinBox" name="ccpmCollectivespinBox">
<property name="maximum">
<number>100</number>
@ -634,7 +634,7 @@
</widget>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="0">
<widget class="QGroupBox" name="ccpmRevoMixingBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
@ -645,13 +645,13 @@
<property name="minimumSize">
<size>
<width>50</width>
<height>250</height>
<height>200</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>250</height>
<height>200</height>
</size>
</property>
<property name="title">
@ -662,12 +662,12 @@
<rect>
<x>0</x>
<y>20</y>
<width>47</width>
<height>218</height>
<width>53</width>
<height>168</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QFormLayout" name="formLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="label_14">
<property name="enabled">
<bool>false</bool>
@ -680,7 +680,7 @@
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_5">
@ -700,10 +700,16 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
<height>100</height>
</size>
</property>
<property name="maximum">
@ -732,7 +738,7 @@
</item>
</layout>
</item>
<item>
<item row="2" column="0">
<widget class="QLabel" name="label_13">
<property name="enabled">
<bool>false</bool>
@ -745,7 +751,7 @@
</property>
</widget>
</item>
<item>
<item row="3" column="0">
<widget class="QSpinBox" name="ccpmREVOspinBox"/>
</item>
</layout>
@ -796,7 +802,7 @@
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
<height>400</height>
</size>
</property>
<property name="maximumSize">
@ -815,10 +821,10 @@
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="backgroundBrush">
<brush brushstyle="SolidPattern">
@ -875,8 +881,8 @@
<rect>
<x>10</x>
<y>10</y>
<width>670</width>
<height>390</height>
<width>631</width>
<height>387</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -1052,9 +1058,15 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QTableWidget" name="CurveSettings">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>243</width>
@ -1063,7 +1075,7 @@
</property>
<property name="maximumSize">
<size>
<width>243</width>
<width>250</width>
<height>273</height>
</size>
</property>
@ -1324,92 +1336,108 @@
</item>
</widget>
</item>
<item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_20">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_39">
<property name="text">
<widget class="QGroupBox" name="ThrottleCurveBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>160</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>Throttle Curve</string>
</property>
<widget class="MixerCurveWidget" name="ThrottleCurve" native="true">
<property name="geometry">
<rect>
<x>5</x>
<y>20</y>
<width>150</width>
<height>150</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
</widget>
</widget>
</item>
</layout>
</item>
<item>
<widget class="MixerCurveWidget" name="ThrottleCurve" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="customThrottleCurve1Value">
<property name="text">
<string>Val: 0.00</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout_21">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="label_41">
<property name="text">
<string>Blade Pitch Curve</string>
<widget class="QGroupBox" name="PitchCurveBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Pitch Curve</string>
</property>
<widget class="MixerCurveWidget" name="PitchCurve" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>150</width>
<height>150</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
</widget>
</widget>
</item>
</layout>
</item>
<item>
<widget class="MixerCurveWidget" name="PitchCurve" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>150</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="customThrottleCurve2Value">
<property name="text">
<string>Val: 0.00</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -1426,8 +1454,8 @@
<rect>
<x>15</x>
<y>21</y>
<width>661</width>
<height>211</height>
<width>651</width>
<height>201</height>
</rect>
</property>
<property name="sizePolicy">
@ -1442,6 +1470,9 @@
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="autoScroll">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>

View File

@ -172,6 +172,8 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent)
connect(m_ccpm->PitchCurve, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updatePitchCurveValue(QList<double>,double)));
connect(m_ccpm->ThrottleCurve, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateThrottleCurveValue(QList<double>,double)));
@ -223,8 +225,8 @@ void ConfigccpmWidget::UpdateType()
m_ccpm->CurveToGenerate->setEnabled(1);
m_ccpm->CurveSettings->setColumnHidden(1,0);
m_ccpm->PitchCurve->setVisible(1);
m_ccpm->customThrottleCurve2Value->setVisible(1);
m_ccpm->label_41->setVisible(1);
//m_ccpm->customThrottleCurve2Value->setVisible(1);
//m_ccpm->label_41->setVisible(1);
//set values for pre defined heli types
if (TypeText.compare(QString("CCPM 2 Servo 90º"), Qt::CaseInsensitive)==0)
@ -288,8 +290,8 @@ void ConfigccpmWidget::UpdateType()
m_ccpm->CurveToGenerate->setEnabled(0);
m_ccpm->CurveSettings->setColumnHidden(1,1);
m_ccpm->PitchCurve->setVisible(0);
m_ccpm->customThrottleCurve2Value->setVisible(0);
m_ccpm->label_41->setVisible(0);
//m_ccpm->customThrottleCurve2Value->setVisible(0);
//m_ccpm->label_41->setVisible(0);
}
@ -314,29 +316,79 @@ void ConfigccpmWidget::resetMixer(MixerCurveWidget *mixer, int numElements)
void ConfigccpmWidget::UpdateCurveWidgets()
{
int NumCurvePoints,i;
int NumCurvePoints,i,Changed;
QList<double> curveValues;
QList<double> OldCurveValues;
double ThisValue;
//get the user settings
NumCurvePoints=m_ccpm->NumCurvePoints->value();
curveValues.clear();
Changed=0;
OldCurveValues=m_ccpm->ThrottleCurve->getCurve();
for (i=0; i<NumCurvePoints; i++)
{
curveValues.append(m_ccpm->CurveSettings->item(i, 0 )->text().toDouble());
ThisValue=m_ccpm->CurveSettings->item(i, 0 )->text().toDouble();
curveValues.append(ThisValue);
if (ThisValue!=OldCurveValues.at(i))Changed=1;
}
// Setup all Throttle1 curves for all types of airframes
m_ccpm->ThrottleCurve->initCurve(curveValues);
if (Changed==1)m_ccpm->ThrottleCurve->setCurve(curveValues);
curveValues.clear();
Changed=0;
OldCurveValues=m_ccpm->PitchCurve->getCurve();
for (i=0; i<NumCurvePoints; i++)
{
curveValues.append(m_ccpm->CurveSettings->item(i, 1 )->text().toDouble());
ThisValue=m_ccpm->CurveSettings->item(i, 1 )->text().toDouble();
curveValues.append(ThisValue);
if (ThisValue!=OldCurveValues.at(i))Changed=1;
}
// Setup all Throttle1 curves for all types of airframes
m_ccpm->PitchCurve->initCurve(curveValues);
if (Changed==1)m_ccpm->PitchCurve->setCurve(curveValues);
}
void ConfigccpmWidget::updatePitchCurveValue(QList<double> curveValues,double Value)
{
int NumCurvePoints,i;
double CurrentValue;
QList<double> internalCurveValues;
//get the user settings
NumCurvePoints=m_ccpm->NumCurvePoints->value();
internalCurveValues=m_ccpm->PitchCurve->getCurve();
for (i=0; i<internalCurveValues.length(); i++)
{
CurrentValue=m_ccpm->CurveSettings->item(i, 1 )->text().toDouble();
if (CurrentValue!=internalCurveValues[i])
{
//m_ccpm->CurveSettings->item(i, 1)->setText(tr( "%1" ).arg(internalCurveValues[i]));
m_ccpm->CurveSettings->item(i, 1)->setText(QString().sprintf("%.3f",internalCurveValues.at(i)));
}
}
}
void ConfigccpmWidget::updateThrottleCurveValue(QList<double> curveValues,double Value)
{
int NumCurvePoints,i;
double CurrentValue;
//get the user settings
NumCurvePoints=m_ccpm->NumCurvePoints->value();
for (i=0; i<curveValues.length(); i++)
{
CurrentValue=m_ccpm->CurveSettings->item(i, 1 )->text().toDouble();
if (CurrentValue!=curveValues[i])
{
//m_ccpm->CurveSettings->item(i, 0)->setText(tr( "%1" ).arg(curveValues[i]));
m_ccpm->CurveSettings->item(i, 0)->setText(QString().sprintf("%.3f",curveValues.at(i)));
}
}
}
void ConfigccpmWidget::UpdateCurveSettings()
@ -475,6 +527,7 @@ void ConfigccpmWidget::GenerateCurve()
double value1, value2, value3, scale;
QString CurveType;
QTableWidgetItem *item;
double newValue;
//get the user settings
@ -494,30 +547,39 @@ void ConfigccpmWidget::GenerateCurve()
if ( CurveType.compare("Flat")==0)
{
item->setText( tr( "%1" ).arg( value1 ) );
//item->setText( tr( "%1" ).arg( value1 ) );
item->setText(QString().sprintf("%.3f",value1));
}
if ( CurveType.compare("Linear")==0)
{
item->setText( tr( "%1" ).arg(value1 +(scale*(value2-value1))) );
newValue =value1 +(scale*(value2-value1));
//item->setText( tr( "%1" ).arg(value1 +(scale*(value2-value1))) );
item->setText(QString().sprintf("%.3f",newValue));
}
if ( CurveType.compare("Step")==0)
{
if (scale*100<value3)
{
item->setText( tr( "%1" ).arg(value1) );
//item->setText( tr( "%1" ).arg(value1) );
item->setText(QString().sprintf("%.3f",value1));
}
else
{
item->setText( tr( "%1" ).arg(value2) );
//item->setText( tr( "%1" ).arg(value2) );
item->setText(QString().sprintf("%.3f",value2));
}
}
if ( CurveType.compare("Exp")==0)
{
item->setText( tr( "%1" ).arg(value1 +(((exp(scale*(value3/10))-1))/(exp((value3/10))-1)*(value2-value1))) );
newValue =value1 +(((exp(scale*(value3/10))-1))/(exp((value3/10))-1)*(value2-value1));
//item->setText( tr( "%1" ).arg(value1 +(((exp(scale*(value3/10))-1))/(exp((value3/10))-1)*(value2-value1))) );
item->setText(QString().sprintf("%.3f",newValue));
}
if ( CurveType.compare("Log")==0)
{
item->setText( tr( "%1" ).arg(value1 +(((log(scale*(value3*2)+1))/(log(1+(value3*2))))*(value2-value1))) );
newValue = value1 +(((log(scale*(value3*2)+1))/(log(1+(value3*2))))*(value2-value1));
//item->setText( tr( "%1" ).arg(value1 +(((log(scale*(value3*2)+1))/(log(1+(value3*2))))*(value2-value1))) );
item->setText(QString().sprintf("%.3f",newValue));
}
}
for (i=NumCurvePoints;i<10;i++)

View File

@ -70,6 +70,8 @@ private:
void UpdateType();
void resetMixer(MixerCurveWidget *mixer, int numElements);
void UpdateCurveWidgets();
void updatePitchCurveValue(QList<double>,double);
void updateThrottleCurveValue(QList<double>,double);
public slots:
void requestccpmUpdate();
void sendccpmUpdate();