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