mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
OP-1422 Tricopter_mixers_settings Normalize mixer values saved from Wizard and Config tab. Fix bad values saved previously like -63/64.
This commit is contained in:
parent
458120cce2
commit
aea2adf2df
@ -969,13 +969,32 @@ void ConfigMultiRotorWidget::setupQuadMotor(int channel, double pitch, double ro
|
||||
|
||||
Q_ASSERT(mixer);
|
||||
|
||||
//Normalize mixer values, allow a well balanced mixer saved
|
||||
if(pitch < 0) {
|
||||
pitch = qFloor(pitch * 127);
|
||||
} else {
|
||||
pitch = qCeil(pitch * 127);
|
||||
}
|
||||
|
||||
if(roll < 0) {
|
||||
roll = qFloor(roll * 127);
|
||||
} else {
|
||||
roll = qCeil(roll * 127);
|
||||
}
|
||||
|
||||
if(yaw < 0) {
|
||||
yaw = qFloor(yaw * 127);
|
||||
} else {
|
||||
yaw = qCeil(yaw * 127);
|
||||
}
|
||||
|
||||
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
|
||||
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 0);
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll * 127);
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch * 127);
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw * 127);
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll);
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch);
|
||||
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -440,9 +440,25 @@ void VehicleConfigurationHelper::applyMixerConfiguration(mixerChannelSettings ch
|
||||
Q_ASSERT(field);
|
||||
field->setValue((channels[i].throttle1 * 127) / 100, 0);
|
||||
field->setValue((channels[i].throttle2 * 127) / 100, 1);
|
||||
field->setValue(qRound(((double)channels[i].roll * 127) / 100), 2);
|
||||
field->setValue(qRound(((double)channels[i].pitch * 127) / 100), 3);
|
||||
field->setValue((channels[i].yaw * 127) / 100, 4);
|
||||
|
||||
//Normalize mixer values, allow a well balanced mixer saved
|
||||
if(channels[i].roll < 0) {
|
||||
field->setValue(qFloor((double)(channels[i].roll * 127) / 100), 2);
|
||||
} else {
|
||||
field->setValue(qCeil((double)(channels[i].roll * 127) / 100), 2);
|
||||
}
|
||||
|
||||
if(channels[i].pitch < 0) {
|
||||
field->setValue(qFloor((double)(channels[i].pitch * 127) / 100), 3);
|
||||
} else {
|
||||
field->setValue(qCeil((double)(channels[i].pitch * 127) / 100), 3);
|
||||
}
|
||||
|
||||
if(channels[i].yaw < 0) {
|
||||
field->setValue(qFloor((double)(channels[i].yaw * 127) / 100), 4);
|
||||
} else {
|
||||
field->setValue(qCeil((double)(channels[i].yaw * 127) / 100), 4);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply updates
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QtCore/qmath.h>
|
||||
#include "vehicleconfigurationsource.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "systemsettings.h"
|
||||
|
Loading…
Reference in New Issue
Block a user