Fixes #1596
Conflicts: companion/src/firmwares/opentx/opentxeeprom.cpp More EEPROM saving in Mixes
This commit is contained in:
@@ -633,7 +633,7 @@ void concatGvarParam(int & gvar, const int _gvar, const unsigned int _gvarParam,
|
||||
|
||||
void exportGvarParam(const int gvar, int & _gvar, int version)
|
||||
{
|
||||
int GV1 = (version >= 216 ? 4096 : 512);
|
||||
int GV1 = (version >= 217 ? 1024 : (version >= 216 ? 4096 : 512));
|
||||
|
||||
if (gvar < -10000) {
|
||||
_gvar = GV1 + gvar + 10000;
|
||||
@@ -648,7 +648,7 @@ void exportGvarParam(const int gvar, int & _gvar, int version)
|
||||
|
||||
void importGvarParam(int & gvar, const int _gvar, int version)
|
||||
{
|
||||
int GV1 = (version >= 216 ? 4096 : 512);
|
||||
int GV1 = (version >= 217 ? 1024 : (version >= 216 ? 4096 : 512));
|
||||
|
||||
if (_gvar >= GV1) {
|
||||
gvar = 10001 + _gvar - GV1;
|
||||
@@ -867,7 +867,43 @@ class MixField: public TransformedField {
|
||||
version(version),
|
||||
model(model)
|
||||
{
|
||||
if (IS_TARANIS(board) && version >= 216) {
|
||||
if (IS_TARANIS(board) && version >= 217) {
|
||||
internalField.Append(new UnsignedField<8>(_destCh));
|
||||
internalField.Append(new UnsignedField<9>(mix.phases));
|
||||
internalField.Append(new UnsignedField<2>((unsigned int &)mix.mltpx));
|
||||
internalField.Append(new UnsignedField<1>((unsigned int &)mix.carryTrim));
|
||||
internalField.Append(new UnsignedField<4>(mix.mixWarn));
|
||||
internalField.Append(new SignedField<16>(_weight));
|
||||
internalField.Append(new SwitchField<8>(mix.swtch, board, version));
|
||||
internalField.Append(new CurveReferenceField(mix.curve, board, version));
|
||||
internalField.Append(new UnsignedField<8>(mix.delayUp));
|
||||
internalField.Append(new UnsignedField<8>(mix.delayDown));
|
||||
internalField.Append(new UnsignedField<8>(mix.speedUp));
|
||||
internalField.Append(new UnsignedField<8>(mix.speedDown));
|
||||
internalField.Append(new SourceField<8>(mix.srcRaw, board, version, FLAG_NOTELEMETRY));
|
||||
internalField.Append(new SignedField<16>(_offset));
|
||||
internalField.Append(new ZCharField<8>(mix.name));
|
||||
}
|
||||
else if (IS_ARM(board) && version >= 217) {
|
||||
internalField.Append(new UnsignedField<5>(_destCh));
|
||||
internalField.Append(new UnsignedField<3>(mix.mixWarn));
|
||||
internalField.Append(new UnsignedField<9>(mix.phases));
|
||||
internalField.Append(new BoolField<1>(_curveMode));
|
||||
internalField.Append(new BoolField<1>(mix.noExpo));
|
||||
internalField.Append(new SignedField<3>(mix.carryTrim));
|
||||
internalField.Append(new UnsignedField<2>((unsigned int &)mix.mltpx));
|
||||
internalField.Append(new SignedField<16>(_weight));
|
||||
internalField.Append(new SwitchField<8>(mix.swtch, board, version));
|
||||
internalField.Append(new SignedField<8>(_curveParam));
|
||||
internalField.Append(new UnsignedField<8>(mix.delayUp));
|
||||
internalField.Append(new UnsignedField<8>(mix.delayDown));
|
||||
internalField.Append(new UnsignedField<8>(mix.speedUp));
|
||||
internalField.Append(new UnsignedField<8>(mix.speedDown));
|
||||
internalField.Append(new SourceField<8>(mix.srcRaw, board, version, FLAG_NOTELEMETRY));
|
||||
internalField.Append(new SignedField<16>(_offset));
|
||||
internalField.Append(new ZCharField<6>(mix.name));
|
||||
}
|
||||
else if (IS_TARANIS(board) && version == 216) {
|
||||
internalField.Append(new UnsignedField<8>(_destCh));
|
||||
internalField.Append(new UnsignedField<16>(mix.phases));
|
||||
internalField.Append(new UnsignedField<2>((unsigned int &)mix.mltpx));
|
||||
@@ -887,7 +923,7 @@ class MixField: public TransformedField {
|
||||
internalField.Append(new ZCharField<8>(mix.name));
|
||||
internalField.Append(new SpareBitsField<8>());
|
||||
}
|
||||
else if (IS_ARM(board) && version >= 216) {
|
||||
else if (IS_ARM(board) && version == 216) {
|
||||
internalField.Append(new UnsignedField<5>(_destCh));
|
||||
internalField.Append(new UnsignedField<3>(mix.mixWarn));
|
||||
internalField.Append(new UnsignedField<16>(mix.phases));
|
||||
@@ -1154,7 +1190,7 @@ class InputField: public TransformedField {
|
||||
|
||||
virtual void beforeExport()
|
||||
{
|
||||
_weight = smallGvarToEEPROM(expo.weight);
|
||||
_weight = smallGvarToEEPROM(expo.weight);
|
||||
|
||||
if (!IS_TARANIS(board) || version < 216) {
|
||||
if (expo.curve.type==CurveReference::CURVE_REF_FUNC && expo.curve.value) {
|
||||
@@ -1209,13 +1245,35 @@ class InputField: public TransformedField {
|
||||
|
||||
class LimitField: public StructField {
|
||||
public:
|
||||
template <int shift>
|
||||
static int exportLimitValue(int value)
|
||||
{
|
||||
if (value > 10000)
|
||||
return 1023 + value - 10000;
|
||||
else if (value < -10000)
|
||||
return -1024 + value + 10000;
|
||||
else
|
||||
return value + shift;
|
||||
}
|
||||
|
||||
template <int shift>
|
||||
static int importLimitValue(int value)
|
||||
{
|
||||
if (value > 1023)
|
||||
return 10000 + value - 1023;
|
||||
else if (value < -1024)
|
||||
return -10000 + value + 1024;
|
||||
else
|
||||
return value - shift;
|
||||
}
|
||||
|
||||
LimitField(LimitData & limit, BoardEnum board, unsigned int version):
|
||||
StructField("Limit")
|
||||
{
|
||||
if (IS_TARANIS(board) && version >= 217) {
|
||||
Append(new ConversionField< SignedField<11> >(limit.min, +1000));
|
||||
Append(new ConversionField< SignedField<11> >(limit.max, -1000));
|
||||
Append(new SignedField<11>(limit.offset));
|
||||
Append(new ConversionField< SignedField<11> >(limit.min, exportLimitValue<1000>, importLimitValue<1000>));
|
||||
Append(new ConversionField< SignedField<11> >(limit.max, exportLimitValue<-1000>, importLimitValue<-1000>));
|
||||
Append(new ConversionField< SignedField<11> >(limit.offset, exportLimitValue<0>, importLimitValue<0>));
|
||||
Append(new SignedField<11>(limit.ppmCenter));
|
||||
Append(new BoolField<1>(limit.symetrical));
|
||||
Append(new BoolField<1>(limit.revert));
|
||||
@@ -1227,15 +1285,17 @@ class LimitField: public StructField {
|
||||
}
|
||||
else {
|
||||
if (IS_TARANIS(board) && version >= 216) {
|
||||
Append(new ConversionField< SignedField<16> >(limit.min, +1000));
|
||||
Append(new ConversionField< SignedField<16> >(limit.max, -1000));
|
||||
Append(new ConversionField< SignedField<16> >(limit.min, exportLimitValue<1000>, importLimitValue<1000>));
|
||||
Append(new ConversionField< SignedField<16> >(limit.max, exportLimitValue<-1000>, importLimitValue<-1000>));
|
||||
Append(new SignedField<8>(limit.ppmCenter));
|
||||
Append(new ConversionField< SignedField<14> >(limit.offset, exportLimitValue<0>, importLimitValue<0>));
|
||||
}
|
||||
else {
|
||||
Append(new ConversionField< SignedField<8> >(limit.min, +100, 10));
|
||||
Append(new ConversionField< SignedField<8> >(limit.max, -100, 10));
|
||||
Append(new SignedField<8>(limit.ppmCenter));
|
||||
Append(new SignedField<14>(limit.offset));
|
||||
}
|
||||
Append(new SignedField<8>(limit.ppmCenter));
|
||||
Append(new SignedField<14>(limit.offset));
|
||||
Append(new BoolField<1>(limit.symetrical));
|
||||
Append(new BoolField<1>(limit.revert));
|
||||
if (HAS_LARGE_LCD(board)) {
|
||||
|
||||
+31
-12
@@ -147,17 +147,18 @@ void populatePhasesCB(QComboBox *b, int value)
|
||||
b->setCurrentIndex(value + GetCurrentFirmware()->getCapability(FlightModes));
|
||||
}
|
||||
|
||||
GVarGroup::GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const unsigned int flags):
|
||||
GVarGroup::GVarGroup(QCheckBox *weightGV, QAbstractSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const double step, const unsigned int flags):
|
||||
QObject(),
|
||||
weightGV(weightGV),
|
||||
weightSB(weightSB),
|
||||
sb(dynamic_cast<QSpinBox *>(weightSB)),
|
||||
dsb(dynamic_cast<QDoubleSpinBox *>(weightSB)),
|
||||
weightCB(weightCB),
|
||||
weight(weight),
|
||||
step(step),
|
||||
flags(flags),
|
||||
lock(false)
|
||||
lock(true)
|
||||
{
|
||||
lock = true;
|
||||
|
||||
if (GetCurrentFirmware()->getCapability(Gvars)) {
|
||||
populateGVCB(weightCB, weight);
|
||||
connect(weightGV, SIGNAL(stateChanged(int)), this, SLOT(gvarCBChanged(int)));
|
||||
@@ -170,21 +171,32 @@ GVarGroup::GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightC
|
||||
}
|
||||
}
|
||||
|
||||
weightSB->setMinimum(mini);
|
||||
weightSB->setMaximum(maxi);
|
||||
int val;
|
||||
|
||||
if (weight>maxi || weight<mini) {
|
||||
val = deflt;
|
||||
weightGV->setChecked(true);
|
||||
weightSB->hide();
|
||||
weightCB->show();
|
||||
}
|
||||
else {
|
||||
val = weight;
|
||||
weightGV->setChecked(false);
|
||||
weightSB->setValue(weight);
|
||||
weightSB->show();
|
||||
weightCB->hide();
|
||||
}
|
||||
|
||||
if (sb) {
|
||||
sb->setMinimum(step*mini);
|
||||
sb->setMaximum(step*maxi);
|
||||
sb->setValue(step*val);
|
||||
}
|
||||
else {
|
||||
dsb->setMinimum(step*mini);
|
||||
dsb->setMaximum(step*maxi);
|
||||
dsb->setValue(step*val);
|
||||
}
|
||||
|
||||
connect(weightSB, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
|
||||
|
||||
lock = false;
|
||||
@@ -193,16 +205,23 @@ GVarGroup::GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightC
|
||||
void GVarGroup::gvarCBChanged(int state)
|
||||
{
|
||||
weightCB->setVisible(state);
|
||||
weightSB->setVisible(!state);
|
||||
if (weightSB)
|
||||
weightSB->setVisible(!state);
|
||||
else
|
||||
weightSB->setVisible(!state);
|
||||
valuesChanged();
|
||||
}
|
||||
|
||||
void GVarGroup::valuesChanged()
|
||||
{
|
||||
if (weightGV->isChecked())
|
||||
weight = weightCB->itemData(weightCB->currentIndex()).toInt();
|
||||
else
|
||||
weight = weightSB->value();
|
||||
if (!lock) {
|
||||
if (weightGV->isChecked())
|
||||
weight = weightCB->itemData(weightCB->currentIndex()).toInt();
|
||||
else if (sb)
|
||||
weight = sb->value()/step;
|
||||
else
|
||||
weight = dsb->value()/step;
|
||||
}
|
||||
}
|
||||
|
||||
CurveGroup::CurveGroup(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags):
|
||||
|
||||
@@ -37,12 +37,12 @@ class CompanionIcon: public QIcon {
|
||||
CompanionIcon(QString baseimage);
|
||||
};
|
||||
|
||||
class GVarGroup : public QObject {
|
||||
class GVarGroup: public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GVarGroup(QCheckBox *weightGV, QSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const unsigned int flags=0);
|
||||
GVarGroup(QCheckBox *weightGV, QAbstractSpinBox *weightSB, QComboBox *weightCB, int & weight, const int deflt, const int mini, const int maxi, const double step=1, const unsigned int flags=0);
|
||||
|
||||
protected slots:
|
||||
void gvarCBChanged(int);
|
||||
@@ -50,10 +50,13 @@ class GVarGroup : public QObject {
|
||||
|
||||
protected:
|
||||
QCheckBox *weightGV;
|
||||
QSpinBox *weightSB;
|
||||
QAbstractSpinBox *weightSB;
|
||||
QSpinBox *sb;
|
||||
QDoubleSpinBox *dsb;
|
||||
QComboBox *weightCB;
|
||||
int & weight;
|
||||
const unsigned int flags;
|
||||
double step;
|
||||
unsigned int flags;
|
||||
bool lock;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "channels.h"
|
||||
#include "helpers.h"
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
@@ -13,8 +14,7 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
|
||||
bool minimize = false;
|
||||
|
||||
int col = 1;
|
||||
if (firmware->getCapability(ChannelsName))
|
||||
{
|
||||
if (firmware->getCapability(ChannelsName)) {
|
||||
minimize=true;
|
||||
addLabel(gridLayout, tr("Name"), col++);
|
||||
}
|
||||
@@ -57,24 +57,51 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
|
||||
offset->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
|
||||
offset->setAccelerated(true);
|
||||
offset->setDecimals(1);
|
||||
offset->setMinimum(-100);
|
||||
offset->setSingleStep(0.1);
|
||||
offset->setValue(float(model.limitData[i].offset) / 10);
|
||||
connect(offset, SIGNAL(editingFinished()), this, SLOT(offsetEdited()));
|
||||
gridLayout->addWidget(offset, i+1, col++, 1, 1);
|
||||
if (IS_TARANIS(firmware->getBoard())) {
|
||||
QHBoxLayout * horizontalLayout = new QHBoxLayout();
|
||||
QCheckBox * ofsGV = new QCheckBox(tr("GV"));
|
||||
horizontalLayout->addWidget(ofsGV);
|
||||
QComboBox * ofsCB = new QComboBox(this);
|
||||
horizontalLayout->addWidget(ofsCB);
|
||||
horizontalLayout->addWidget(offset);
|
||||
gridLayout->addLayout(horizontalLayout, i+1, col++, 1, 1);
|
||||
ofsGroup = new GVarGroup(ofsGV, offset, ofsCB, model.limitData[i].offset, 0, -10*model.getChannelsMax(), 10*model.getChannelsMax(), 0.1);
|
||||
}
|
||||
else {
|
||||
offset->setMinimum(-100);
|
||||
offset->setMaximum(100);
|
||||
offset->setValue(float(model.limitData[i].offset) / 10);
|
||||
connect(offset, SIGNAL(editingFinished()), this, SLOT(offsetEdited()));
|
||||
gridLayout->addWidget(offset, i+1, col++, 1, 1);
|
||||
}
|
||||
|
||||
// Channel min
|
||||
QDoubleSpinBox * minSB = new QDoubleSpinBox(this);
|
||||
minSB->setProperty("index", i);
|
||||
minSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
|
||||
minSB->setAccelerated(true);
|
||||
minSB->setDecimals(1);
|
||||
minSB->setMinimum(-model.getChannelsMax());
|
||||
minSB->setSingleStep(0.1);
|
||||
minSB->setMaximum(0);
|
||||
minSB->setValue(float(model.limitData[i].min) / 10);
|
||||
connect(minSB, SIGNAL(editingFinished()), this, SLOT(minEdited()));
|
||||
gridLayout->addWidget(minSB, i+1, col++, 1, 1);
|
||||
if (IS_TARANIS(firmware->getBoard())) {
|
||||
QHBoxLayout * horizontalLayout = new QHBoxLayout();
|
||||
QCheckBox * minGV = new QCheckBox(tr("GV"));
|
||||
horizontalLayout->addWidget(minGV);
|
||||
QComboBox * minCB = new QComboBox(this);
|
||||
horizontalLayout->addWidget(minCB);
|
||||
minSB->setDecimals(1);
|
||||
minSB->setSingleStep(0.1);
|
||||
horizontalLayout->addWidget(minSB);
|
||||
gridLayout->addLayout(horizontalLayout, i+1, col++, 1, 1);
|
||||
minGroup = new GVarGroup(minGV, minSB, minCB, model.limitData[i].min, -1000, -10*model.getChannelsMax(), 0, 0.1);
|
||||
}
|
||||
else {
|
||||
minSB->setDecimals(0);
|
||||
minSB->setSingleStep(1);
|
||||
minSB->setMinimum(-model.getChannelsMax());
|
||||
minSB->setMaximum(0);
|
||||
minSB->setValue(model.limitData[i].min / 10);
|
||||
connect(minSB, SIGNAL(editingFinished()), this, SLOT(minEdited()));
|
||||
gridLayout->addWidget(minSB, i+1, col++, 1, 1);
|
||||
}
|
||||
minSpins << minSB;
|
||||
|
||||
// Channel max
|
||||
@@ -82,13 +109,27 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
|
||||
maxSB->setProperty("index", i);
|
||||
maxSB->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
|
||||
maxSB->setAccelerated(true);
|
||||
maxSB->setDecimals(1);
|
||||
maxSB->setMinimum(0);
|
||||
maxSB->setSingleStep(0.1);
|
||||
maxSB->setMaximum(model.getChannelsMax());
|
||||
maxSB->setValue(float(model.limitData[i].max) / 10);
|
||||
connect(maxSB, SIGNAL(editingFinished()), this, SLOT(maxEdited()));
|
||||
gridLayout->addWidget(maxSB, i+1, col++, 1, 1);
|
||||
if (IS_TARANIS(firmware->getBoard())) {
|
||||
QHBoxLayout * horizontalLayout = new QHBoxLayout();
|
||||
QCheckBox * maxGV = new QCheckBox(tr("GV"));
|
||||
horizontalLayout->addWidget(maxGV);
|
||||
QComboBox * maxCB = new QComboBox(this);
|
||||
horizontalLayout->addWidget(maxCB);
|
||||
maxSB->setDecimals(1);
|
||||
maxSB->setSingleStep(0.1);
|
||||
horizontalLayout->addWidget(maxSB);
|
||||
gridLayout->addLayout(horizontalLayout, i+1, col++, 1, 1);
|
||||
maxGroup = new GVarGroup(maxGV, maxSB, maxCB, model.limitData[i].max, 1000, 0, 10*model.getChannelsMax(), 0.1);
|
||||
}
|
||||
else {
|
||||
maxSB->setDecimals(0);
|
||||
maxSB->setSingleStep(1);
|
||||
maxSB->setMinimum(0);
|
||||
maxSB->setMaximum(model.getChannelsMax());
|
||||
maxSB->setValue(model.limitData[i].max / 10);
|
||||
connect(maxSB, SIGNAL(editingFinished()), this, SLOT(maxEdited()));
|
||||
gridLayout->addWidget(maxSB, i+1, col++, 1, 1);
|
||||
}
|
||||
maxSpins << maxSB;
|
||||
|
||||
// Channel inversion
|
||||
@@ -135,6 +176,7 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
|
||||
gridLayout->addWidget(symlimits, i+1, col++, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Push the rows up
|
||||
addVSpring(gridLayout, 0,firmware->getCapability(Outputs)+1);
|
||||
|
||||
@@ -143,6 +185,9 @@ Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & genera
|
||||
|
||||
Channels::~Channels()
|
||||
{
|
||||
delete ofsGroup;
|
||||
delete minGroup;
|
||||
delete maxGroup;
|
||||
}
|
||||
|
||||
void Channels::symlimitsEdited()
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "modelpanel.h"
|
||||
#include <QSpinBox>
|
||||
|
||||
class GVarGroup;
|
||||
|
||||
class Channels : public ModelPanel
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -15,6 +17,9 @@ class Channels : public ModelPanel
|
||||
private:
|
||||
QVector<QDoubleSpinBox *> minSpins;
|
||||
QVector<QDoubleSpinBox *> maxSpins;
|
||||
GVarGroup * ofsGroup;
|
||||
GVarGroup * minGroup;
|
||||
GVarGroup * maxGroup;
|
||||
|
||||
public slots:
|
||||
void refreshExtendedLimits();
|
||||
|
||||
Reference in New Issue
Block a user