mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
Minor Cleaning
This commit is contained in:
parent
cac495cebb
commit
689eb2c588
@ -397,12 +397,8 @@ void ConfigAirframeWidget::resetCt2Mixer()
|
||||
*/
|
||||
void ConfigAirframeWidget::resetMixer(MixerCurveWidget *mixer, int numElements, double maxvalue)
|
||||
{
|
||||
QList<double> curveValues;
|
||||
for (double i=0; i<numElements; i++) {
|
||||
curveValues.append(maxvalue*(i/(numElements-1)));
|
||||
}
|
||||
// Setup all Throttle1 curves for all types of airframes
|
||||
mixer->initCurve(curveValues);
|
||||
mixer->initLinearCurve((quint32)numElements,maxvalue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -469,38 +465,30 @@ void ConfigAirframeWidget::requestAircraftUpdate()
|
||||
QList<double> curveValues;
|
||||
// If the 1st element of the curve is <= -10, then the curve
|
||||
// is a straight line (that's how the mixer works on the mainboard):
|
||||
double temp=0; //used to check if default value(all 0s) is being returned
|
||||
if (field->getValue(0).toInt() <= -10) {
|
||||
double temp=1;
|
||||
for (double i=0; i<field->getNumElements(); i++) {
|
||||
curveValues.append(i/(field->getNumElements()-1));
|
||||
}
|
||||
} else {
|
||||
m_aircraft->multiThrottleCurve->initLinearCurve(field->getNumElements(),(double)1);
|
||||
m_aircraft->fixedWingThrottle->initLinearCurve(field->getNumElements(),(double)1);
|
||||
}
|
||||
else {
|
||||
double temp=0;
|
||||
double value;
|
||||
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
||||
value=field->getValue(i).toDouble();
|
||||
temp+=value;
|
||||
curveValues.append(value);
|
||||
}
|
||||
if(temp==0)
|
||||
{
|
||||
m_aircraft->multiThrottleCurve->initLinearCurve(field->getNumElements(),0.95);;
|
||||
m_aircraft->fixedWingThrottle->initLinearCurve(field->getNumElements(),(double)1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_aircraft->multiThrottleCurve->initCurve(curveValues);
|
||||
m_aircraft->fixedWingThrottle->initCurve(curveValues);
|
||||
}
|
||||
}
|
||||
// Setup all Throttle1 curves for all types of airframes
|
||||
if(temp==0)
|
||||
{ curveValues.clear();
|
||||
for (double i=0; i<field->getNumElements(); i++) {
|
||||
curveValues.append(0.95*(i/(field->getNumElements()-1)));
|
||||
}
|
||||
m_aircraft->multiThrottleCurve->initCurve(curveValues);
|
||||
curveValues.clear();
|
||||
for (double i=0; i<field->getNumElements(); i++) {
|
||||
curveValues.append(i/(field->getNumElements()-1));
|
||||
}
|
||||
m_aircraft->fixedWingThrottle->initCurve(curveValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_aircraft->multiThrottleCurve->initCurve(curveValues);
|
||||
m_aircraft->fixedWingThrottle->initCurve(curveValues);
|
||||
}
|
||||
// Load the Settings for fixed wing frames:
|
||||
if (frameType.startsWith("FixedWing")) {
|
||||
// Then retrieve how channels are setup
|
||||
@ -1758,45 +1746,33 @@ void ConfigAirframeWidget::updateCustomAirframeUI()
|
||||
QList<double> curveValues;
|
||||
// If the 1st element of the curve is <= -10, then the curve
|
||||
// is a straight line (that's how the mixer works on the mainboard):
|
||||
double temp=0; //used to check if default value(all 0s) is being returned
|
||||
if (field->getValue(0).toInt() <= -10) {
|
||||
double temp=1;
|
||||
for (double i=0; i<field->getNumElements(); i++) {
|
||||
curveValues.append(i/(field->getNumElements()-1));
|
||||
}
|
||||
m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1);
|
||||
} else {
|
||||
double temp=0;
|
||||
double value;
|
||||
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
||||
value=field->getValue(i).toDouble();
|
||||
temp+=value;
|
||||
curveValues.append(value);
|
||||
}
|
||||
if(temp==0)
|
||||
m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1);
|
||||
else
|
||||
m_aircraft->customThrottle1Curve->initCurve(curveValues);
|
||||
}
|
||||
|
||||
// Setup all Throttle1 curves for all types of airframes
|
||||
if(temp==0)
|
||||
{ curveValues.clear();
|
||||
for (double i=0; i<field->getNumElements(); i++) {
|
||||
curveValues.append(1*(i/(field->getNumElements()-1)));
|
||||
}
|
||||
}
|
||||
m_aircraft->customThrottle1Curve->initCurve(curveValues);
|
||||
|
||||
field = obj->getField(QString("ThrottleCurve2"));
|
||||
curveValues.clear();;
|
||||
// If the 1st element of the curve is <= -10, then the curve
|
||||
// is a straight line (that's how the mixer works on the mainboard):
|
||||
if (field->getValue(0).toInt() <= -10) {
|
||||
for (double i=0; i<field->getNumElements(); i++) {
|
||||
curveValues.append(i/(field->getNumElements()-1));
|
||||
}
|
||||
m_aircraft->customThrottle2Curve->initLinearCurve(field->getNumElements(),(double)1);
|
||||
} else {
|
||||
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
||||
curveValues.append(field->getValue(i).toDouble());
|
||||
}
|
||||
m_aircraft->customThrottle2Curve->initCurve(curveValues);
|
||||
}
|
||||
m_aircraft->customThrottle2Curve->initCurve(curveValues);
|
||||
|
||||
// Retrieve Feed Forward:
|
||||
field = obj->getField(QString("FeedForward"));
|
||||
m_aircraft->customFFSlider->setValue(field->getDouble()*100);
|
||||
|
@ -372,12 +372,7 @@ void ConfigccpmWidget::UpdateType()
|
||||
*/
|
||||
void ConfigccpmWidget::resetMixer(MixerCurveWidget *mixer, int numElements)
|
||||
{
|
||||
QList<double> curveValues;
|
||||
for (double i=0; i<numElements; i++) {
|
||||
curveValues.append(i/(numElements-1));
|
||||
}
|
||||
// Setup all Throttle1 curves for all types of airframes
|
||||
mixer->initCurve(curveValues);
|
||||
mixer->initLinearCurve(numElements,(double)1);
|
||||
}
|
||||
|
||||
void ConfigccpmWidget::UpdateCurveWidgets()
|
||||
|
@ -147,7 +147,17 @@ QList<double> MixerCurveWidget::getCurve() {
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
Sets a linear graph
|
||||
*/
|
||||
void MixerCurveWidget::initLinearCurve(quint32 numPoints, double maxValue)
|
||||
{
|
||||
QList<double> points;
|
||||
for (double i=0; i<numPoints;i++) {
|
||||
points.append(maxValue*(i/(numPoints-1)));
|
||||
}
|
||||
initCurve(points);
|
||||
}
|
||||
/**
|
||||
Setd the current curve settings
|
||||
*/
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
void itemMoved(double itemValue); // Callback when a point is moved, to be updated
|
||||
void initCurve (QList<double> points);
|
||||
QList<double> getCurve();
|
||||
void initLinearCurve(quint32 numPoints, double maxValue);
|
||||
void setCurve(QList<double>);
|
||||
void setMin(double value);
|
||||
void setMax(double value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user