mirror of
https://github.com/opentx/opentx.git
synced 2025-07-22 15:55:26 +03:00
EEPROM 'next' support. A lot of corrections.
This commit is contained in:
parent
0b387a2467
commit
cedddfe8d2
20 changed files with 419 additions and 434 deletions
|
@ -550,6 +550,7 @@ class ConversionField: public TransformedField {
|
||||||
_field(0),
|
_field(0),
|
||||||
table(table),
|
table(table),
|
||||||
shift(0),
|
shift(0),
|
||||||
|
scale(1),
|
||||||
min(INT_MIN),
|
min(INT_MIN),
|
||||||
max(INT_MAX),
|
max(INT_MAX),
|
||||||
exportFunc(NULL),
|
exportFunc(NULL),
|
||||||
|
@ -565,6 +566,7 @@ class ConversionField: public TransformedField {
|
||||||
_field(0),
|
_field(0),
|
||||||
table(table),
|
table(table),
|
||||||
shift(0),
|
shift(0),
|
||||||
|
scale(0),
|
||||||
min(INT_MIN),
|
min(INT_MIN),
|
||||||
max(INT_MAX),
|
max(INT_MAX),
|
||||||
exportFunc(NULL),
|
exportFunc(NULL),
|
||||||
|
@ -580,6 +582,7 @@ class ConversionField: public TransformedField {
|
||||||
_field(0),
|
_field(0),
|
||||||
table(NULL),
|
table(NULL),
|
||||||
shift(0),
|
shift(0),
|
||||||
|
scale(0),
|
||||||
min(INT_MIN),
|
min(INT_MIN),
|
||||||
max(INT_MAX),
|
max(INT_MAX),
|
||||||
exportFunc(exportFunc),
|
exportFunc(exportFunc),
|
||||||
|
@ -588,13 +591,14 @@ class ConversionField: public TransformedField {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ConversionField(int & field, int shift, int min=INT_MIN, int max=INT_MAX, const char *name = "Signed shifted"):
|
ConversionField(int & field, int shift, int scale=0, int min=INT_MIN, int max=INT_MAX, const char *name = "Signed shifted"):
|
||||||
TransformedField(internalField),
|
TransformedField(internalField),
|
||||||
internalField(_field, name),
|
internalField(_field, name),
|
||||||
field(field),
|
field(field),
|
||||||
_field(0),
|
_field(0),
|
||||||
table(NULL),
|
table(NULL),
|
||||||
shift(shift),
|
shift(shift),
|
||||||
|
scale(scale),
|
||||||
min(min),
|
min(min),
|
||||||
max(max),
|
max(max),
|
||||||
exportFunc(NULL),
|
exportFunc(NULL),
|
||||||
|
@ -603,13 +607,14 @@ class ConversionField: public TransformedField {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ConversionField(unsigned int & field, int shift):
|
ConversionField(unsigned int & field, int shift, int scale=0):
|
||||||
TransformedField(internalField),
|
TransformedField(internalField),
|
||||||
internalField((unsigned int &)_field),
|
internalField((unsigned int &)_field),
|
||||||
field((int &)field),
|
field((int &)field),
|
||||||
_field(0),
|
_field(0),
|
||||||
table(NULL),
|
table(NULL),
|
||||||
shift(shift),
|
shift(shift),
|
||||||
|
scale(scale),
|
||||||
min(INT_MIN),
|
min(INT_MIN),
|
||||||
max(INT_MAX),
|
max(INT_MAX),
|
||||||
exportFunc(NULL),
|
exportFunc(NULL),
|
||||||
|
@ -620,19 +625,25 @@ class ConversionField: public TransformedField {
|
||||||
|
|
||||||
virtual void beforeExport()
|
virtual void beforeExport()
|
||||||
{
|
{
|
||||||
|
int val = field;
|
||||||
|
|
||||||
|
if (scale) {
|
||||||
|
val /= scale;
|
||||||
|
}
|
||||||
|
|
||||||
if (table) {
|
if (table) {
|
||||||
if (table->exportValue(field, _field))
|
if (table->exportValue(val, _field))
|
||||||
return;
|
return;
|
||||||
if (!error.isEmpty())
|
if (!error.isEmpty())
|
||||||
EEPROMWarnings += error + "\n";
|
EEPROMWarnings += error + "\n";
|
||||||
}
|
}
|
||||||
else if (shift) {
|
else if (shift) {
|
||||||
if (field < min) _field = min + shift;
|
if (val < min) _field = min + shift;
|
||||||
else if (field > max) _field = max + shift;
|
else if (val > max) _field = max + shift;
|
||||||
else _field = field + shift;
|
else _field = val + shift;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_field = exportFunc(field);
|
_field = exportFunc(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,6 +659,10 @@ class ConversionField: public TransformedField {
|
||||||
else {
|
else {
|
||||||
field = importFunc(_field);
|
field = importFunc(_field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scale) {
|
||||||
|
field *= scale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -656,6 +671,7 @@ class ConversionField: public TransformedField {
|
||||||
int _field;
|
int _field;
|
||||||
ConversionTable * table;
|
ConversionTable * table;
|
||||||
int shift;
|
int shift;
|
||||||
|
int scale;
|
||||||
int min;
|
int min;
|
||||||
int max;
|
int max;
|
||||||
int (*exportFunc)(int);
|
int (*exportFunc)(int);
|
||||||
|
|
|
@ -417,9 +417,9 @@ QString CurveReference::toString()
|
||||||
else {
|
else {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case CURVE_REF_DIFF:
|
case CURVE_REF_DIFF:
|
||||||
return QObject::tr("Diff(%1%%)").arg(getGVarString(value));
|
return QObject::tr("Diff(%1)").arg(getGVarString(value));
|
||||||
case CURVE_REF_EXPO:
|
case CURVE_REF_EXPO:
|
||||||
return QObject::tr("Expo(%1%%)").arg(getGVarString(value));
|
return QObject::tr("Expo(%1)").arg(getGVarString(value));
|
||||||
case CURVE_REF_FUNC:
|
case CURVE_REF_FUNC:
|
||||||
return QObject::tr("Function(%1)").arg(QString("x>0" "x<0" "|x|" "f>0" "f<0" "|f|").mid(3*(value-1), 3));
|
return QObject::tr("Function(%1)").arg(QString("x>0" "x<0" "|x|" "f>0" "f<0" "|f|").mid(3*(value-1), 3));
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -65,8 +65,8 @@ const uint8_t modn12x3[4][4]= {
|
||||||
#define C9X_MAX_MODELS 60
|
#define C9X_MAX_MODELS 60
|
||||||
#define C9X_MAX_PHASES 9
|
#define C9X_MAX_PHASES 9
|
||||||
#define C9X_MAX_MIXERS 64
|
#define C9X_MAX_MIXERS 64
|
||||||
#define C9X_MAX_EXPOS 32
|
#define C9X_MAX_EXPOS 64
|
||||||
#define C9X_MAX_CURVES 16
|
#define C9X_MAX_CURVES 32
|
||||||
#define C9X_MAX_POINTS 17
|
#define C9X_MAX_POINTS 17
|
||||||
#define C9X_MAX_GVARS 9
|
#define C9X_MAX_GVARS 9
|
||||||
#define C9X_MAX_ENCODERS 2
|
#define C9X_MAX_ENCODERS 2
|
||||||
|
@ -628,10 +628,7 @@ enum AssignFunc {
|
||||||
FuncBackgroundMusic,
|
FuncBackgroundMusic,
|
||||||
FuncBackgroundMusicPause,
|
FuncBackgroundMusicPause,
|
||||||
FuncAdjustGV1,
|
FuncAdjustGV1,
|
||||||
FuncAdjustGV2,
|
FuncAdjustGVLast = FuncAdjustGV1+C9X_MAX_GVARS-1,
|
||||||
FuncAdjustGV3,
|
|
||||||
FuncAdjustGV4,
|
|
||||||
FuncAdjustGV5,
|
|
||||||
FuncCount
|
FuncCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -977,7 +974,6 @@ enum Capability {
|
||||||
GvarsFlightPhases,
|
GvarsFlightPhases,
|
||||||
GvarsHaveSources,
|
GvarsHaveSources,
|
||||||
GvarsAsSources,
|
GvarsAsSources,
|
||||||
GvarsAsWeight,
|
|
||||||
GvarsName,
|
GvarsName,
|
||||||
NoTelemetryProtocol,
|
NoTelemetryProtocol,
|
||||||
TelemetryCSFields,
|
TelemetryCSFields,
|
||||||
|
|
|
@ -283,7 +283,6 @@ int Er9xInterface::getCapability(const Capability capability)
|
||||||
return 7;
|
return 7;
|
||||||
case GvarsHaveSources:
|
case GvarsHaveSources:
|
||||||
case GvarsAsSources:
|
case GvarsAsSources:
|
||||||
case GvarsAsWeight:
|
|
||||||
return 1;
|
return 1;
|
||||||
case GetThrSwitch:
|
case GetThrSwitch:
|
||||||
return DSW_THR;
|
return DSW_THR;
|
||||||
|
|
|
@ -319,7 +319,6 @@ int Ersky9xInterface::getCapability(const Capability capability)
|
||||||
return 23;
|
return 23;
|
||||||
case GvarsHaveSources:
|
case GvarsHaveSources:
|
||||||
case GvarsAsSources:
|
case GvarsAsSources:
|
||||||
case GvarsAsWeight:
|
|
||||||
return 1;
|
return 1;
|
||||||
case TelemetryMaxMultiplier:
|
case TelemetryMaxMultiplier:
|
||||||
return 2;
|
return 2;
|
||||||
|
|
|
@ -630,7 +630,7 @@ t_Open9xArmFuncSwData_v211::operator FuncSwData ()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c9x.param = value;
|
c9x.param = value;
|
||||||
if ((c9x.func == FuncPlayValue || c9x.func == FuncVolume || (c9x.func >= FuncAdjustGV1 && c9x.func <= FuncAdjustGV5)) && value > 7) {
|
if ((c9x.func == FuncPlayValue || c9x.func == FuncVolume || (c9x.func >= FuncAdjustGV1 && c9x.func <= FuncAdjustGVLast)) && value > 7) {
|
||||||
c9x.param++;
|
c9x.param++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,13 +363,34 @@ class SourceField: public ConversionField< UnsignedField<N> > {
|
||||||
unsigned int _source;
|
unsigned int _source;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CurveReferenceField: public StructField {
|
class CurveReferenceField: public TransformedField {
|
||||||
public:
|
public:
|
||||||
CurveReferenceField(CurveReference & curve, BoardEnum board, unsigned int version)
|
CurveReferenceField(CurveReference & curve, BoardEnum board, unsigned int version):
|
||||||
|
TransformedField(internalField),
|
||||||
|
curve(curve),
|
||||||
|
_curve_type(0)
|
||||||
{
|
{
|
||||||
Append(new UnsignedField<8>((unsigned int &)curve.type));
|
internalField.Append(new UnsignedField<8>(_curve_type));
|
||||||
Append(new SignedField<8>(curve.value));
|
internalField.Append(new SignedField<8>(curve.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void beforeExport()
|
||||||
|
{
|
||||||
|
if (curve.value != 0)
|
||||||
|
_curve_type = (unsigned int)curve.type;
|
||||||
|
else
|
||||||
|
_curve_type = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void afterImport()
|
||||||
|
{
|
||||||
|
curve.type = (CurveReference::CurveRefType)_curve_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
StructField internalField;
|
||||||
|
CurveReference & curve;
|
||||||
|
unsigned int _curve_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HeliField: public StructField {
|
class HeliField: public StructField {
|
||||||
|
@ -804,13 +825,13 @@ class ExpoField: public TransformedField {
|
||||||
if (IS_TARANIS(board) && version >= 216) {
|
if (IS_TARANIS(board) && version >= 216) {
|
||||||
internalField.Append(new SourceField<8>(expo.srcRaw, board, version, 0));
|
internalField.Append(new SourceField<8>(expo.srcRaw, board, version, 0));
|
||||||
internalField.Append(new UnsignedField<16>(expo.scale));
|
internalField.Append(new UnsignedField<16>(expo.scale));
|
||||||
internalField.Append(new UnsignedField<8>(expo.chn));
|
internalField.Append(new UnsignedField<8>(expo.chn, "Channel"));
|
||||||
internalField.Append(new SwitchField<8>(expo.swtch, board, version));
|
internalField.Append(new SwitchField<8>(expo.swtch, board, version));
|
||||||
internalField.Append(new UnsignedField<16>(expo.phases));
|
internalField.Append(new UnsignedField<16>(expo.phases));
|
||||||
internalField.Append(new SignedField<8>(_weight));
|
internalField.Append(new SignedField<8>(_weight, "Weight"));
|
||||||
internalField.Append(new SignedField<8>(expo.carryTrim));
|
internalField.Append(new SignedField<8>(expo.carryTrim));
|
||||||
internalField.Append(new ZCharField<8>(expo.name));
|
internalField.Append(new ZCharField<8>(expo.name));
|
||||||
internalField.Append(new SignedField<8>(expo.offset));
|
internalField.Append(new SignedField<8>(expo.offset, "Offset"));
|
||||||
internalField.Append(new CurveReferenceField(expo.curve, board, version));
|
internalField.Append(new CurveReferenceField(expo.curve, board, version));
|
||||||
internalField.Append(new SpareBitsField<8>());
|
internalField.Append(new SpareBitsField<8>());
|
||||||
}
|
}
|
||||||
|
@ -903,8 +924,8 @@ class LimitField: public StructField {
|
||||||
Append(new ConversionField< SignedField<16> >(limit.max, -1000));
|
Append(new ConversionField< SignedField<16> >(limit.max, -1000));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Append(new ConversionField< SignedField<8> >(limit.min, +100));
|
Append(new ConversionField< SignedField<8> >(limit.min, +100, 10));
|
||||||
Append(new ConversionField< SignedField<8> >(limit.max, -100));
|
Append(new ConversionField< SignedField<8> >(limit.max, -100, 10));
|
||||||
}
|
}
|
||||||
Append(new SignedField<8>(limit.ppmCenter));
|
Append(new SignedField<8>(limit.ppmCenter));
|
||||||
Append(new SignedField<14>(limit.offset));
|
Append(new SignedField<14>(limit.offset));
|
||||||
|
@ -1352,7 +1373,7 @@ class CustomFunctionField: public TransformedField {
|
||||||
else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic) {
|
else if (fn.func == FuncPlayPrompt || fn.func == FuncBackgroundMusic) {
|
||||||
memcpy(_arm_param, fn.paramarm, sizeof(_arm_param));
|
memcpy(_arm_param, fn.paramarm, sizeof(_arm_param));
|
||||||
}
|
}
|
||||||
else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGV5) {
|
else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) {
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
if (version >= 214) {
|
if (version >= 214) {
|
||||||
_mode = fn.adjustMode;
|
_mode = fn.adjustMode;
|
||||||
|
@ -1382,7 +1403,7 @@ class CustomFunctionField: public TransformedField {
|
||||||
/* the default behavior */
|
/* the default behavior */
|
||||||
_param = fn.param;
|
_param = fn.param;
|
||||||
_union_param = (fn.enabled ? 1 : 0);
|
_union_param = (fn.enabled ? 1 : 0);
|
||||||
if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGV5) {
|
if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) {
|
||||||
if (version >= 213) {
|
if (version >= 213) {
|
||||||
_union_param += (fn.adjustMode << 1);
|
_union_param += (fn.adjustMode << 1);
|
||||||
if (fn.adjustMode == 1)
|
if (fn.adjustMode == 1)
|
||||||
|
@ -1435,7 +1456,7 @@ class CustomFunctionField: public TransformedField {
|
||||||
else if (fn.func == FuncVolume) {
|
else if (fn.func == FuncVolume) {
|
||||||
sourcesConversionTable->importValue(value, (int &)fn.param);
|
sourcesConversionTable->importValue(value, (int &)fn.param);
|
||||||
}
|
}
|
||||||
else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGV5) {
|
else if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) {
|
||||||
if (version >= 214) {
|
if (version >= 214) {
|
||||||
fn.adjustMode = _mode;
|
fn.adjustMode = _mode;
|
||||||
if (fn.adjustMode == 1)
|
if (fn.adjustMode == 1)
|
||||||
|
@ -1464,7 +1485,7 @@ class CustomFunctionField: public TransformedField {
|
||||||
if (version >= 213) {
|
if (version >= 213) {
|
||||||
fn.enabled = (_union_param & 0x01);
|
fn.enabled = (_union_param & 0x01);
|
||||||
}
|
}
|
||||||
if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGV5) {
|
if (fn.func >= FuncAdjustGV1 && fn.func <= FuncAdjustGVLast) {
|
||||||
if (version >= 213) {
|
if (version >= 213) {
|
||||||
fn.adjustMode = ((_union_param >> 1) & 0x03);
|
fn.adjustMode = ((_union_param >> 1) & 0x03);
|
||||||
if (fn.adjustMode == 1)
|
if (fn.adjustMode == 1)
|
||||||
|
@ -1725,7 +1746,7 @@ class FrskyField: public StructField {
|
||||||
Append(new SignedField<4>(frsky.varioMax));
|
Append(new SignedField<4>(frsky.varioMax));
|
||||||
for (int i=0; i<2; i++) {
|
for (int i=0; i<2; i++) {
|
||||||
Append(new ConversionField< UnsignedField<2> >(frsky.rssiAlarms[i].level, &rssiConversionTable[i], "RSSI level"));
|
Append(new ConversionField< UnsignedField<2> >(frsky.rssiAlarms[i].level, &rssiConversionTable[i], "RSSI level"));
|
||||||
Append(new ConversionField< SignedField<6> >(frsky.rssiAlarms[i].value, -45+i*3, 0, 100, "RSSI value"));
|
Append(new ConversionField< SignedField<6> >(frsky.rssiAlarms[i].value, -45+i*3, 0, 0, 100, "RSSI value"));
|
||||||
}
|
}
|
||||||
for (int i=0; i<2; i++) {
|
for (int i=0; i<2; i++) {
|
||||||
Append(new FrskyScreenField(frsky.screens[i], board, version));
|
Append(new FrskyScreenField(frsky.screens[i], board, version));
|
||||||
|
@ -1949,6 +1970,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
|
||||||
void Open9xModelDataNew::beforeExport()
|
void Open9xModelDataNew::beforeExport()
|
||||||
{
|
{
|
||||||
// qDebug() << QString("before export model") << modelData.name;
|
// qDebug() << QString("before export model") << modelData.name;
|
||||||
|
|
||||||
for (int module=0; module<3; module++) {
|
for (int module=0; module<3; module++) {
|
||||||
if (modelData.moduleData[module].protocol >= PXX_XJT_X16 && modelData.moduleData[module].protocol <= PXX_XJT_LR12)
|
if (modelData.moduleData[module].protocol >= PXX_XJT_X16 && modelData.moduleData[module].protocol <= PXX_XJT_LR12)
|
||||||
subprotocols[module] = modelData.moduleData[module].protocol - PXX_XJT_X16;
|
subprotocols[module] = modelData.moduleData[module].protocol - PXX_XJT_X16;
|
||||||
|
@ -1959,7 +1981,7 @@ void Open9xModelDataNew::beforeExport()
|
||||||
|
|
||||||
void Open9xModelDataNew::afterImport()
|
void Open9xModelDataNew::afterImport()
|
||||||
{
|
{
|
||||||
// qDebug() << QString("after import model") << modelData.name;
|
// qDebug() << QString("after import model") << modelData.name ;
|
||||||
|
|
||||||
for (int module=0; module<3; module++) {
|
for (int module=0; module<3; module++) {
|
||||||
if (modelData.moduleData[module].protocol == PXX_XJT_X16) {
|
if (modelData.moduleData[module].protocol == PXX_XJT_X16) {
|
||||||
|
@ -2050,9 +2072,9 @@ Open9xGeneralDataNew::Open9xGeneralDataNew(GeneralSettings & generalData, BoardE
|
||||||
internalField.Append(new UnsignedField<8>(generalData.speakerPitch));
|
internalField.Append(new UnsignedField<8>(generalData.speakerPitch));
|
||||||
|
|
||||||
if (IS_ARM(board))
|
if (IS_ARM(board))
|
||||||
internalField.Append(new ConversionField< SignedField<8> >(generalData.speakerVolume, -12, 0, 23, "Volume"));
|
internalField.Append(new ConversionField< SignedField<8> >(generalData.speakerVolume, -12, 0, 0, 23, "Volume"));
|
||||||
else
|
else
|
||||||
internalField.Append(new ConversionField< SignedField<8> >(generalData.speakerVolume, -7, 0, 7, "Volume"));
|
internalField.Append(new ConversionField< SignedField<8> >(generalData.speakerVolume, -7, 0, 0, 7, "Volume"));
|
||||||
|
|
||||||
if (version >= 214 || (!IS_ARM(board) && version >= 213)) {
|
if (version >= 214 || (!IS_ARM(board) && version >= 213)) {
|
||||||
internalField.Append(new SignedField<8>(generalData.vBatMin));
|
internalField.Append(new SignedField<8>(generalData.vBatMin));
|
||||||
|
|
|
@ -420,7 +420,6 @@ int Open9xInterface::getSize(ModelData &model)
|
||||||
efile->EeFsCreate(tmp, EESIZE_RLC_MAX, board);
|
efile->EeFsCreate(tmp, EESIZE_RLC_MAX, board);
|
||||||
|
|
||||||
Open9xModelDataNew open9xModel(model, board, 255, GetCurrentFirmwareVariant());
|
Open9xModelDataNew open9xModel(model, board, 255, GetCurrentFirmwareVariant());
|
||||||
// open9xModel.Dump();
|
|
||||||
|
|
||||||
QByteArray eeprom;
|
QByteArray eeprom;
|
||||||
open9xModel.Export(eeprom);
|
open9xModel.Export(eeprom);
|
||||||
|
@ -502,7 +501,6 @@ int Open9xInterface::getCapability(const Capability capability)
|
||||||
case GvarsName:
|
case GvarsName:
|
||||||
return (IS_TARANIS(board) ? 10 : 6);
|
return (IS_TARANIS(board) ? 10 : 6);
|
||||||
case GvarsInCS:
|
case GvarsInCS:
|
||||||
case GvarsAsWeight:
|
|
||||||
case HasFAIMode:
|
case HasFAIMode:
|
||||||
return 1;
|
return 1;
|
||||||
case GvarsAreNamed:
|
case GvarsAreNamed:
|
||||||
|
|
|
@ -155,16 +155,8 @@ QString getFuncName(unsigned int val)
|
||||||
return QObject::tr("Background Music");
|
return QObject::tr("Background Music");
|
||||||
else if (val == FuncBackgroundMusicPause)
|
else if (val == FuncBackgroundMusicPause)
|
||||||
return QObject::tr("Background Music Pause");
|
return QObject::tr("Background Music Pause");
|
||||||
else if (val == FuncAdjustGV1)
|
else if (val >= FuncAdjustGV1 && val <= FuncAdjustGVLast)
|
||||||
return QObject::tr("Adjust GV1");
|
return QObject::tr("Adjust GV%1").arg(val-FuncAdjustGV1+1);
|
||||||
else if (val == FuncAdjustGV2)
|
|
||||||
return QObject::tr("Adjust GV2");
|
|
||||||
else if (val == FuncAdjustGV3)
|
|
||||||
return QObject::tr("Adjust GV3");
|
|
||||||
else if (val == FuncAdjustGV4)
|
|
||||||
return QObject::tr("Adjust GV4");
|
|
||||||
else if (val == FuncAdjustGV5)
|
|
||||||
return QObject::tr("Adjust GV5");
|
|
||||||
else {
|
else {
|
||||||
return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is)
|
return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is)
|
||||||
}
|
}
|
||||||
|
@ -424,7 +416,7 @@ void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsign
|
||||||
else if (function==FuncPlayValue) {
|
else if (function==FuncPlayValue) {
|
||||||
populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
|
populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
|
||||||
}
|
}
|
||||||
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGV5 ) {
|
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
|
||||||
switch (adjustmode) {
|
switch (adjustmode) {
|
||||||
case 1:
|
case 1:
|
||||||
populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
|
populateSourceCB(b, RawSource(value), POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
|
||||||
|
@ -440,7 +432,6 @@ void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsign
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
b->hide();
|
b->hide();
|
||||||
}
|
}
|
||||||
|
@ -482,16 +473,18 @@ void populatePhasesCB(QComboBox *b, int value)
|
||||||
|
|
||||||
void populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags)
|
void populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags)
|
||||||
{
|
{
|
||||||
curveTypeCB->clear();
|
if (curveTypeCB->count() == 0) {
|
||||||
curveTypeCB->addItem(QObject::tr("Diff"));
|
curveTypeCB->addItem(QObject::tr("Diff"));
|
||||||
curveTypeCB->addItem(QObject::tr("Expo"));
|
curveTypeCB->addItem(QObject::tr("Expo"));
|
||||||
curveTypeCB->addItem(QObject::tr("Func"));
|
curveTypeCB->addItem(QObject::tr("Func"));
|
||||||
curveTypeCB->addItem(QObject::tr("Curve"));
|
curveTypeCB->addItem(QObject::tr("Curve"));
|
||||||
|
}
|
||||||
|
|
||||||
curveTypeCB->setCurrentIndex(curve.type);
|
curveTypeCB->setCurrentIndex(curve.type);
|
||||||
|
|
||||||
if (curve.type == CurveReference::CURVE_REF_DIFF || curve.type == CurveReference::CURVE_REF_EXPO) {
|
if (curve.type == CurveReference::CURVE_REF_DIFF || curve.type == CurveReference::CURVE_REF_EXPO) {
|
||||||
curveGVarCB->show();
|
curveGVarCB->show();
|
||||||
if (curve.value>100 || curve.value<-100) {
|
if (curve.value > 100 || curve.value < -100) {
|
||||||
curveGVarCB->setChecked(true);
|
curveGVarCB->setChecked(true);
|
||||||
populateGVCB(curveValueCB, curve.value);
|
populateGVCB(curveValueCB, curve.value);
|
||||||
curveValueCB->show();
|
curveValueCB->show();
|
||||||
|
@ -533,6 +526,31 @@ void populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QCom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void retrieveCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags)
|
||||||
|
{
|
||||||
|
switch (curveTypeCB->currentIndex()) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
if (curveGVarCB->isChecked())
|
||||||
|
value = curveValueCB->itemData(curveValueCB->currentIndex()).toInt();
|
||||||
|
else
|
||||||
|
value = curveValueSB->value();
|
||||||
|
qDebug() << value;
|
||||||
|
curve = CurveReference(curveTypeCB->currentIndex() == 0 ? CurveReference::CURVE_REF_DIFF : CurveReference::CURVE_REF_EXPO, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
curve = CurveReference(CurveReference::CURVE_REF_FUNC, curveValueCB->currentIndex());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, curveValueCB->currentIndex() - GetEepromInterface()->getCapability(NumCurves));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
populateCurveReference(curveTypeCB, curveGVarCB, curveValueCB, curveValueSB, curve, flags);
|
||||||
|
}
|
||||||
|
|
||||||
void populateTrimUseCB(QComboBox *b, unsigned int phase)
|
void populateTrimUseCB(QComboBox *b, unsigned int phase)
|
||||||
{
|
{
|
||||||
b->addItem(QObject::tr("Own trim"));
|
b->addItem(QObject::tr("Own trim"));
|
||||||
|
@ -1008,17 +1026,18 @@ QString getSignedStr(int value)
|
||||||
|
|
||||||
QString getGVarString(int16_t val, bool sign)
|
QString getGVarString(int16_t val, bool sign)
|
||||||
{
|
{
|
||||||
if (val >= -10000 && val <= 10000)
|
if (val >= -10000 && val <= 10000) {
|
||||||
if (sign)
|
if (sign)
|
||||||
return QString("(%1%)").arg(getSignedStr(val));
|
return QString("%1%").arg(getSignedStr(val));
|
||||||
else
|
else
|
||||||
return QString("(%1%)").arg(val);
|
return QString("%1%").arg(val);
|
||||||
else
|
}
|
||||||
if (val<0) {
|
else {
|
||||||
return QObject::tr("(-GV%1)").arg(-val-10000);
|
if (val<0)
|
||||||
} else {
|
return QObject::tr("-GV%1").arg(-val-10000);
|
||||||
return QObject::tr("(GV%1)").arg(val-10000);
|
else
|
||||||
}
|
return QObject::tr("GV%1").arg(val-10000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString image2qstring(QImage image)
|
QString image2qstring(QImage image)
|
||||||
|
|
|
@ -43,6 +43,7 @@ void populatePhasesCB(QComboBox *b, int value);
|
||||||
void populateTrimUseCB(QComboBox *b, unsigned int phase);
|
void populateTrimUseCB(QComboBox *b, unsigned int phase);
|
||||||
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||||
void populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags);
|
void populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags);
|
||||||
|
void retrieveCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags);
|
||||||
void populateCurvesCB(QComboBox *b, int value);
|
void populateCurvesCB(QComboBox *b, int value);
|
||||||
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
|
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
|
||||||
void populateTimerSwitchCB(QComboBox *b, int value);
|
void populateTimerSwitchCB(QComboBox *b, int value);
|
||||||
|
|
|
@ -281,7 +281,8 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
if (modified) model.funcSw[i].param = fswtchParam[i]->value()*10.0;
|
if (modified) model.funcSw[i].param = fswtchParam[i]->value()*10.0;
|
||||||
fswtchParam[i]->setValue(model.funcSw[i].param/10.0);
|
fswtchParam[i]->setValue(model.funcSw[i].param/10.0);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
|
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
|
||||||
} else if (index>=FuncAdjustGV1 && index<=FuncAdjustGV5) {
|
}
|
||||||
|
else if (index>=FuncAdjustGV1 && index<=FuncAdjustGVLast) {
|
||||||
if (modified) model.funcSw[i].adjustMode = fswtchGVmode[i]->currentIndex();
|
if (modified) model.funcSw[i].adjustMode = fswtchGVmode[i]->currentIndex();
|
||||||
widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE;
|
widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE;
|
||||||
if (model.funcSw[i].adjustMode==0) {
|
if (model.funcSw[i].adjustMode==0) {
|
||||||
|
|
|
@ -15,109 +15,47 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
|
||||||
setWindowTitle(tr("DEST -> %1").arg(getStickStr(ed->chn)));
|
setWindowTitle(tr("DEST -> %1").arg(getStickStr(ed->chn)));
|
||||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||||
|
|
||||||
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
|
int gvars=0;
|
||||||
int gvars=0;
|
if (GetEepromInterface()->getCapability(HasVariants)) {
|
||||||
if (GetEepromInterface()->getCapability(HasVariants)) {
|
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
|
||||||
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
|
|
||||||
gvars=1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
gvars=1;
|
gvars=1;
|
||||||
}
|
}
|
||||||
if (gvars==0) {
|
} else {
|
||||||
ui->expoGV->setDisabled(true);
|
gvars=1;
|
||||||
ui->weightGV->setDisabled(true);
|
|
||||||
ui->expoCurveGV->setDisabled(true);
|
|
||||||
|
|
||||||
/* TODO
|
|
||||||
if (ed->expo>100) {
|
|
||||||
ed->expo=0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (ed->weight>100 || ed->weight<-100) {
|
|
||||||
ed->weight=100;
|
|
||||||
}
|
|
||||||
/* TODO
|
|
||||||
if (ed->curveParam>100 || ed->curveParam<-100) {
|
|
||||||
ed->curveParam=0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
// TODO populateGVCB(ui->expoCB, ed->expo);
|
|
||||||
populateGVCB(ui->weightCB, ed->weight);
|
|
||||||
// TODO populateGVCB(ui->expoCurveCB, ed->curveParam);
|
|
||||||
|
|
||||||
ui->weightSB->setMinimum(0);
|
|
||||||
ui->weightSB->setMaximum(100);
|
|
||||||
if (ed->weight>100 || ed->weight<0) {
|
|
||||||
ui->weightGV->setChecked(true);
|
|
||||||
ui->weightSB->hide();
|
|
||||||
ui->weightCB->show();
|
|
||||||
} else {
|
|
||||||
ui->weightGV->setChecked(false);
|
|
||||||
ui->weightSB->setValue(ed->weight);
|
|
||||||
ui->weightSB->show();
|
|
||||||
ui->weightCB->hide();
|
|
||||||
}
|
|
||||||
/* TODO
|
|
||||||
ui->expoSB->setMinimum(-100);
|
|
||||||
ui->expoSB->setMaximum(100);
|
|
||||||
if (ed->expo>100 || ed->expo<-100) {
|
|
||||||
ui->expoGV->setChecked(true);
|
|
||||||
ui->expoSB->hide();
|
|
||||||
ui->expoCB->show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui->expoGV->setChecked(false);
|
|
||||||
ui->expoSB->setValue(ed->expo);
|
|
||||||
ui->expoSB->show();
|
|
||||||
ui->expoCB->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->expoCurveSB->setMinimum(-100);
|
|
||||||
ui->expoCurveSB->setMaximum(100);
|
|
||||||
if (ed->curveParam>100 || ed->curveParam<-100) {
|
|
||||||
ui->expoCurveGV->setChecked(true);
|
|
||||||
ui->expoCurveSB->hide();
|
|
||||||
ui->expoCurveCB->show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui->expoCurveGV->setChecked(false);
|
|
||||||
ui->expoCurveSB->setValue(ed->curveParam);
|
|
||||||
ui->expoCurveSB->show();
|
|
||||||
ui->expoCurveCB->hide();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// TODO ui->expoGV->hide();
|
if (gvars==0) {
|
||||||
ui->weightGV->hide();
|
ui->weightGV->setDisabled(true);
|
||||||
// TODO ui->expoCurveGV->hide();
|
ui->curveGVarCB->hide();
|
||||||
// TODO ui->expoSB->setMinimum(-100);
|
if ((ed->curve.type == CurveReference::CURVE_REF_EXPO || ed->curve.type == CurveReference::CURVE_REF_DIFF) && ed->curve.value > 100) {
|
||||||
// TODO ui->expoSB->setMaximum(100);
|
ed->curve.value = 0;
|
||||||
// TODO ui->expoSB->setValue(ed->expo);
|
}
|
||||||
// TODO ui->expoCurveSB->setMinimum(-100);
|
if (ed->weight>100 || ed->weight<-100) {
|
||||||
// TODO ui->expoCurveSB->setMaximum(100);
|
ed->weight = 100;
|
||||||
// TODO ui->expoCurveSB->setValue(ed->curveParam);
|
}
|
||||||
ui->weightSB->setMinimum(0);
|
}
|
||||||
ui->weightSB->setMaximum(100);
|
|
||||||
|
populateGVCB(ui->weightCB, ed->weight);
|
||||||
|
|
||||||
|
ui->weightSB->setMinimum(0);
|
||||||
|
ui->weightSB->setMaximum(100);
|
||||||
|
if (ed->weight>100 || ed->weight<0) {
|
||||||
|
ui->weightGV->setChecked(true);
|
||||||
|
ui->weightSB->hide();
|
||||||
|
ui->weightCB->show();
|
||||||
|
} else {
|
||||||
|
ui->weightGV->setChecked(false);
|
||||||
ui->weightSB->setValue(ed->weight);
|
ui->weightSB->setValue(ed->weight);
|
||||||
|
ui->weightSB->show();
|
||||||
|
ui->weightCB->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
populateSwitchCB(ui->switchesCB,ed->swtch);
|
populateSwitchCB(ui->switchesCB,ed->swtch);
|
||||||
/* if (ed->curveMode==0) {
|
populateCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, 0);
|
||||||
populateExpoCurvesCB(ui->curvesCB,0); // TODO capacity for er9x
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
populateExpoCurvesCB(ui->curvesCB,ed->curveParam); // TODO capacity for er9x
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
ui->modeCB->setCurrentIndex(ed->mode-1);
|
ui->modeCB->setCurrentIndex(ed->mode-1);
|
||||||
|
|
||||||
ui->label_expo->hide();
|
ui->label_expo->hide();
|
||||||
// TODO ui->expoCB->hide();
|
|
||||||
// TODO ui->expoGV->hide();
|
|
||||||
// TODO ui->expoSB->hide();
|
|
||||||
|
|
||||||
if (!GetEepromInterface()->getCapability(FlightPhases)) {
|
if (!GetEepromInterface()->getCapability(FlightPhases)) {
|
||||||
ui->label_phases->hide();
|
ui->label_phases->hide();
|
||||||
|
@ -138,6 +76,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
|
||||||
cb_fp[i]->hide();
|
cb_fp[i]->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int expolength=GetEepromInterface()->getCapability(HasExpoNames);
|
int expolength=GetEepromInterface()->getCapability(HasExpoNames);
|
||||||
if (!expolength) {
|
if (!expolength) {
|
||||||
ui->label_name->hide();
|
ui->label_name->hide();
|
||||||
|
@ -145,21 +84,25 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
|
||||||
} else {
|
} else {
|
||||||
ui->expoName->setMaxLength(expolength);
|
ui->expoName->setMaxLength(expolength);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->expoName->setValidator(new QRegExpValidator(rx, this));
|
ui->expoName->setValidator(new QRegExpValidator(rx, this));
|
||||||
ui->expoName->setText(ed->name);
|
ui->expoName->setText(ed->name);
|
||||||
valuesChanged();
|
valuesChanged();
|
||||||
|
|
||||||
connect(ui->expoName,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
|
connect(ui->expoName,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
|
||||||
connect(ui->expoCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
connect(ui->expoCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
||||||
connect(ui->expoSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
|
connect(ui->expoSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
|
||||||
connect(ui->expoCurveCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
|
||||||
connect(ui->expoCurveSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
|
connect(ui->curveTypeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
||||||
|
connect(ui->curveGVarCB,SIGNAL(stateChanged(int)),this,SLOT(valuesChanged()));
|
||||||
|
connect(ui->curveValueCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
||||||
|
connect(ui->curveValueSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
|
||||||
|
|
||||||
connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
||||||
connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
|
connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
|
||||||
connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
||||||
connect(ui->curvesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
|
||||||
connect(ui->modeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
connect(ui->modeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
|
||||||
connect(ui->expoGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
|
connect(ui->expoGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
|
||||||
connect(ui->expoCurveGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
|
|
||||||
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
|
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
|
||||||
for (int i=0; i<9; i++) {
|
for (int i=0; i<9; i++) {
|
||||||
connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
|
connect(cb_fp[i],SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
|
||||||
|
@ -186,63 +129,43 @@ void ExpoDialog::changeEvent(QEvent *e)
|
||||||
|
|
||||||
void ExpoDialog::widgetChanged()
|
void ExpoDialog::widgetChanged()
|
||||||
{
|
{
|
||||||
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
|
// TODO so many times duplicated :(
|
||||||
int gvars=0;
|
int gvars=0;
|
||||||
if (GetEepromInterface()->getCapability(HasVariants)) {
|
if (GetEepromInterface()->getCapability(HasVariants)) {
|
||||||
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
|
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
|
||||||
gvars=1;
|
gvars=1;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
gvars=1;
|
|
||||||
}
|
|
||||||
if (gvars==1) {
|
|
||||||
if (ui->expoCurveGV->isChecked()) {
|
|
||||||
ui->expoCurveCB->show();
|
|
||||||
ui->expoCurveSB->hide();
|
|
||||||
} else {
|
|
||||||
ui->expoCurveCB->hide();
|
|
||||||
ui->expoCurveSB->show();
|
|
||||||
}
|
|
||||||
if (ui->weightGV->isChecked()) {
|
|
||||||
ui->weightCB->show();
|
|
||||||
ui->weightSB->hide();
|
|
||||||
} else {
|
|
||||||
ui->weightCB->hide();
|
|
||||||
ui->weightSB->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
valuesChanged();
|
|
||||||
QTimer::singleShot(0, this, SLOT(shrink()));
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
gvars=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO if (gvars==1) {
|
||||||
|
if (ui->expoCurveGV->isChecked()) {
|
||||||
|
ui->expoCurveCB->show();
|
||||||
|
ui->expoCurveSB->hide();
|
||||||
|
} else {
|
||||||
|
ui->expoCurveCB->hide();
|
||||||
|
ui->expoCurveSB->show();
|
||||||
|
}
|
||||||
|
if (ui->weightGV->isChecked()) {
|
||||||
|
ui->weightCB->show();
|
||||||
|
ui->weightSB->hide();
|
||||||
|
} else {
|
||||||
|
ui->weightCB->hide();
|
||||||
|
ui->weightSB->show();
|
||||||
|
}
|
||||||
|
} */
|
||||||
|
valuesChanged();
|
||||||
|
QTimer::singleShot(0, this, SLOT(shrink()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExpoDialog::valuesChanged()
|
void ExpoDialog::valuesChanged()
|
||||||
{
|
{
|
||||||
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
|
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
|
||||||
if (ui->curvesCB->currentIndex()==0) {
|
|
||||||
// TODO ed->curveMode = 0;
|
retrieveCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, 0);
|
||||||
ui->expoCurveGV->show();
|
|
||||||
if (ui->expoCurveGV->isChecked()) {
|
|
||||||
ui->expoCurveCB->show();
|
|
||||||
ui->expoCurveSB->hide();
|
|
||||||
// TODO ed->curveParam = ui->expoCurveCB->itemData(ui->expoCurveCB->currentIndex()).toInt();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui->expoCurveCB->hide();
|
|
||||||
ui->expoCurveSB->show();
|
|
||||||
// TODO ed->curveParam = ui->expoCurveSB->value();
|
|
||||||
}
|
|
||||||
// TODO ed->expo = ed->curveParam;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// TODO ed->curveMode = 1;
|
|
||||||
// TODO ed->curveParam = ui->curvesCB->currentIndex();
|
|
||||||
// TODO ed->expo = 0;
|
|
||||||
ui->expoCurveCB->hide();
|
|
||||||
ui->expoCurveSB->hide();
|
|
||||||
ui->expoCurveGV->hide();
|
|
||||||
}
|
|
||||||
if (ui->weightGV->isChecked()) {
|
if (ui->weightGV->isChecked()) {
|
||||||
ed->weight = ui->weightCB->itemData(ui->weightCB->currentIndex()).toInt();
|
ed->weight = ui->weightCB->itemData(ui->weightCB->currentIndex()).toInt();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>370</width>
|
<width>370</width>
|
||||||
<height>289</height>
|
<height>291</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset resource="companion9x.qrc">
|
<iconset>
|
||||||
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
@ -308,14 +308,14 @@ If blank then the expo is considered to be "ON" all the time.</string>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="label_curves">
|
<widget class="QLabel" name="label_curves">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Curve/Exponential</string>
|
<string>Curve</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="5" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,0,1">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,1,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="curvesCB">
|
<widget class="QComboBox" name="curveTypeCB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
@ -325,22 +325,22 @@ If blank then the expo is considered to be "ON" all the time.</string>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="expoCurveGV">
|
<widget class="QCheckBox" name="curveGVarCB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>GV</string>
|
<string>GV</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="expoCurveSB"/>
|
<widget class="QComboBox" name="curveValueCB">
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="expoCurveCB">
|
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="curveValueSB"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
|
|
|
@ -82,7 +82,7 @@ void InputsPanel::update()
|
||||||
default: str += " "; break;
|
default: str += " "; break;
|
||||||
};
|
};
|
||||||
|
|
||||||
str += tr("Weight") + getGVarString(md->weight).rightJustified(6, ' ');
|
str += tr("Weight(%1)").arg(getGVarString(md->weight));
|
||||||
|
|
||||||
QString curveStr = md->curve.toString();
|
QString curveStr = md->curve.toString();
|
||||||
if (!curveStr.isEmpty()) {
|
if (!curveStr.isEmpty()) {
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
|
MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::MixerDialog),
|
ui(new Ui::MixerDialog),
|
||||||
md(mixdata)
|
md(mixdata),
|
||||||
|
lock(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||||
|
@ -22,63 +23,51 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
|
||||||
|
|
||||||
ui->sourceCB->removeItem(0);
|
ui->sourceCB->removeItem(0);
|
||||||
int limit=GetEepromInterface()->getCapability(OffsetWeight);
|
int limit=GetEepromInterface()->getCapability(OffsetWeight);
|
||||||
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
|
int gvars=0;
|
||||||
int gvars=0;
|
if (GetEepromInterface()->getCapability(HasVariants)) {
|
||||||
if (GetEepromInterface()->getCapability(HasVariants)) {
|
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
|
||||||
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
|
|
||||||
gvars=1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
gvars=1;
|
gvars=1;
|
||||||
}
|
}
|
||||||
if (gvars==0) {
|
} else {
|
||||||
ui->offsetGV->setDisabled(true);
|
gvars=1;
|
||||||
ui->weightGV->setDisabled(true);
|
}
|
||||||
if (md->weight>limit || md->weight<-limit) {
|
if (gvars==0) {
|
||||||
md->weight=100;
|
ui->offsetGV->setDisabled(true);
|
||||||
}
|
ui->weightGV->setDisabled(true);
|
||||||
if (md->sOffset>limit || md->sOffset<-limit) {
|
|
||||||
md->sOffset=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
populateGVCB(ui->offsetCB,md->sOffset);
|
|
||||||
populateGVCB(ui->weightCB,md->weight);
|
|
||||||
ui->weightSB->setMinimum(-limit);
|
|
||||||
ui->weightSB->setMaximum(limit);
|
|
||||||
if (md->weight>limit || md->weight<-limit) {
|
if (md->weight>limit || md->weight<-limit) {
|
||||||
ui->weightGV->setChecked(true);
|
md->weight=100;
|
||||||
ui->weightSB->hide();
|
|
||||||
ui->weightCB->show();
|
|
||||||
} else {
|
|
||||||
ui->weightGV->setChecked(false);
|
|
||||||
ui->weightSB->setValue(md->weight);
|
|
||||||
ui->weightSB->show();
|
|
||||||
ui->weightCB->hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->offsetSB->setMinimum(-limit);
|
|
||||||
ui->offsetSB->setMaximum(limit);
|
|
||||||
if (md->sOffset>limit || md->sOffset<-limit) {
|
if (md->sOffset>limit || md->sOffset<-limit) {
|
||||||
ui->offsetGV->setChecked(true);
|
md->sOffset=0;
|
||||||
ui->offsetSB->hide();
|
|
||||||
ui->offsetCB->show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ui->offsetGV->setChecked(false);
|
|
||||||
ui->offsetSB->setValue(md->sOffset);
|
|
||||||
ui->offsetSB->show();
|
|
||||||
ui->offsetCB->hide();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
populateGVCB(ui->offsetCB,md->sOffset);
|
||||||
ui->offsetGV->hide();
|
populateGVCB(ui->weightCB,md->weight);
|
||||||
ui->weightGV->hide();
|
ui->weightSB->setMinimum(-limit);
|
||||||
ui->offsetSB->setMinimum(-limit);
|
ui->weightSB->setMaximum(limit);
|
||||||
ui->offsetSB->setMaximum(limit);
|
if (md->weight>limit || md->weight<-limit) {
|
||||||
ui->offsetSB->setValue(md->sOffset);
|
ui->weightGV->setChecked(true);
|
||||||
ui->weightSB->setMinimum(-limit);
|
ui->weightSB->hide();
|
||||||
ui->weightSB->setMaximum(limit);
|
ui->weightCB->show();
|
||||||
|
} else {
|
||||||
|
ui->weightGV->setChecked(false);
|
||||||
ui->weightSB->setValue(md->weight);
|
ui->weightSB->setValue(md->weight);
|
||||||
|
ui->weightSB->show();
|
||||||
|
ui->weightCB->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->offsetSB->setMinimum(-limit);
|
||||||
|
ui->offsetSB->setMaximum(limit);
|
||||||
|
if (md->sOffset>limit || md->sOffset<-limit) {
|
||||||
|
ui->offsetGV->setChecked(true);
|
||||||
|
ui->offsetSB->hide();
|
||||||
|
ui->offsetCB->show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->offsetGV->setChecked(false);
|
||||||
|
ui->offsetSB->setValue(md->sOffset);
|
||||||
|
ui->offsetSB->show();
|
||||||
|
ui->offsetCB->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
populateCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve, 0);
|
populateCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve, 0);
|
||||||
|
@ -197,38 +186,43 @@ void MixerDialog::changeEvent(QEvent *e)
|
||||||
|
|
||||||
void MixerDialog::widgetChanged()
|
void MixerDialog::widgetChanged()
|
||||||
{
|
{
|
||||||
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
|
int gvars = 0;
|
||||||
int gvars=0;
|
if (GetEepromInterface()->getCapability(HasVariants)) {
|
||||||
if (GetEepromInterface()->getCapability(HasVariants)) {
|
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
|
||||||
if ((GetCurrentFirmwareVariant() & GVARS_VARIANT)) {
|
gvars = 1;
|
||||||
gvars=1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
gvars=1;
|
|
||||||
}
|
|
||||||
if (gvars==1) {
|
|
||||||
if (ui->weightGV->isChecked()) {
|
|
||||||
ui->weightCB->show();
|
|
||||||
ui->weightSB->hide();
|
|
||||||
} else {
|
|
||||||
ui->weightCB->hide();
|
|
||||||
ui->weightSB->show();
|
|
||||||
}
|
|
||||||
if (ui->offsetGV->isChecked()) {
|
|
||||||
ui->offsetCB->show();
|
|
||||||
ui->offsetSB->hide();
|
|
||||||
} else {
|
|
||||||
ui->offsetCB->hide();
|
|
||||||
ui->offsetSB->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
valuesChanged();
|
|
||||||
QTimer::singleShot(0, this, SLOT(shrink()));
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gvars = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gvars == 1) {
|
||||||
|
if (ui->weightGV->isChecked()) {
|
||||||
|
ui->weightCB->show();
|
||||||
|
ui->weightSB->hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->weightCB->hide();
|
||||||
|
ui->weightSB->show();
|
||||||
|
}
|
||||||
|
if (ui->offsetGV->isChecked()) {
|
||||||
|
ui->offsetCB->show();
|
||||||
|
ui->offsetSB->hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->offsetCB->hide();
|
||||||
|
ui->offsetSB->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
valuesChanged();
|
||||||
|
QTimer::singleShot(0, this, SLOT(shrink()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixerDialog::valuesChanged()
|
void MixerDialog::valuesChanged()
|
||||||
{
|
{
|
||||||
|
if (!lock) {
|
||||||
|
lock = true;
|
||||||
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
|
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
|
||||||
md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt());
|
md->srcRaw = RawSource(ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt());
|
||||||
if ((ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()-65536)<4) {
|
if ((ui->sourceCB->itemData(ui->sourceCB->currentIndex()).toInt()-65536)<4) {
|
||||||
|
@ -256,13 +250,7 @@ void MixerDialog::valuesChanged()
|
||||||
md->carryTrim = -(ui->trimCB->currentIndex()-1);
|
md->carryTrim = -(ui->trimCB->currentIndex()-1);
|
||||||
md->noExpo = ui->MixDR_CB->checkState() ? 0 : 1;
|
md->noExpo = ui->MixDR_CB->checkState() ? 0 : 1;
|
||||||
|
|
||||||
// TODO md->curve = ui->curvesCB->currentIndex()-(numcurves)*GetEepromInterface()->getCapability(HasNegCurves);
|
retrieveCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve, 0);
|
||||||
// TODO if (ui->differentialGV->isChecked()) {
|
|
||||||
// TODO md->differential = ui->differentialCB->itemData(ui->differentialCB->currentIndex()).toInt();
|
|
||||||
// TODO } else {
|
|
||||||
// TODO md->differential = ui->differentialSB->value();
|
|
||||||
// TODO }
|
|
||||||
// populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueCB, CurveReference & curve, unsigned int flags)
|
|
||||||
|
|
||||||
md->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
|
md->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
|
||||||
md->mixWarn = ui->warningCB->currentIndex();
|
md->mixWarn = ui->warningCB->currentIndex();
|
||||||
|
@ -286,6 +274,9 @@ void MixerDialog::valuesChanged()
|
||||||
md->phases<<=1;
|
md->phases<<=1;
|
||||||
}
|
}
|
||||||
md->phases>>=1;
|
md->phases>>=1;
|
||||||
|
|
||||||
|
lock = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixerDialog::shrink() {
|
void MixerDialog::shrink() {
|
||||||
|
|
|
@ -26,6 +26,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
Ui::MixerDialog *ui;
|
Ui::MixerDialog *ui;
|
||||||
MixData *md;
|
MixData *md;
|
||||||
|
bool lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MIXERDIALOG_H
|
#endif // MIXERDIALOG_H
|
||||||
|
|
|
@ -104,8 +104,9 @@ void MixesPanel::update()
|
||||||
default: str += " "; break;
|
default: str += " "; break;
|
||||||
};
|
};
|
||||||
|
|
||||||
str += " " + getGVarString(md->weight, true).rightJustified(6, ' ');
|
|
||||||
str += md->srcRaw.toString();
|
str += md->srcRaw.toString();
|
||||||
|
str += " " + tr("Weight(%1)").arg(getGVarString(md->weight, true));
|
||||||
|
|
||||||
unsigned int fpCount = GetEepromInterface()->getCapability(FlightPhases);
|
unsigned int fpCount = GetEepromInterface()->getCapability(FlightPhases);
|
||||||
if (GetEepromInterface()->getCapability(FlightPhases)) {
|
if (GetEepromInterface()->getCapability(FlightPhases)) {
|
||||||
if(md->phases) {
|
if(md->phases) {
|
||||||
|
@ -149,16 +150,10 @@ void MixesPanel::update()
|
||||||
} else if (md->carryTrim<0) {
|
} else if (md->carryTrim<0) {
|
||||||
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString();
|
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString();
|
||||||
}
|
}
|
||||||
if(md->noExpo) {
|
|
||||||
str += " " +tr("No DR/Expo");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (md->sOffset) str += " " + tr("Offset") + getGVarString(md->sOffset);
|
if (md->noExpo) str += " " + tr("No DR/Expo");
|
||||||
|
if (md->sOffset) str += " " + tr("Offset(%1)").arg(getGVarString(md->sOffset));
|
||||||
QString curveStr = md->curve.toString();
|
if (md->curve.value) str += " " + md->curve.toString();
|
||||||
if (!curveStr.isEmpty()) {
|
|
||||||
str += " " + curveStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int scale=GetEepromInterface()->getCapability(SlowScale);
|
int scale=GetEepromInterface()->getCapability(SlowScale);
|
||||||
if (scale==0)
|
if (scale==0)
|
||||||
|
|
|
@ -101,11 +101,14 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
|
||||||
moduleIdx(moduleIdx),
|
moduleIdx(moduleIdx),
|
||||||
ui(new Ui::Module)
|
ui(new Ui::Module)
|
||||||
{
|
{
|
||||||
|
lock = true;
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
QString label;
|
QString label;
|
||||||
if (moduleIdx < 0) {
|
if (moduleIdx < 0) {
|
||||||
label = tr("Trainer Module");
|
label = tr("Trainer Module");
|
||||||
|
ui->trainerMode->setCurrentIndex(model.trainerMode);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->label_trainerMode->hide();
|
ui->label_trainerMode->hide();
|
||||||
|
@ -122,6 +125,7 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
|
||||||
for (int i=0; i<PROTO_LAST; i++) {
|
for (int i=0; i<PROTO_LAST; i++) {
|
||||||
if (GetEepromInterface()->isAvailable((Protocol)i, moduleIdx)) {
|
if (GetEepromInterface()->isAvailable((Protocol)i, moduleIdx)) {
|
||||||
ui->protocol->addItem(getProtocolStr(i), (QVariant)i);
|
ui->protocol->addItem(getProtocolStr(i), (QVariant)i);
|
||||||
|
if (i == module.protocol) ui->protocol->setCurrentIndex(ui->protocol->count()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +147,8 @@ ModulePanel::ModulePanel(QWidget *parent, ModelData & model, ModuleData & module
|
||||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeChannelChanged(int)));
|
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(onFailsafeChannelChanged(int)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModulePanel::~ModulePanel()
|
ModulePanel::~ModulePanel()
|
||||||
|
@ -150,38 +156,46 @@ ModulePanel::~ModulePanel()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MASK_CHANNELS_COUNT 1
|
#define MASK_PROTOCOL 1
|
||||||
#define MASK_RX_NUMBER 2
|
#define MASK_CHANNELS_COUNT 2
|
||||||
#define MASK_CHANNELS_RANGE 4
|
#define MASK_RX_NUMBER 4
|
||||||
#define MASK_PPM_FIELDS 8
|
#define MASK_CHANNELS_RANGE 8
|
||||||
#define MASK_FAILSAFES 16
|
#define MASK_PPM_FIELDS 16
|
||||||
|
#define MASK_FAILSAFES 32
|
||||||
|
|
||||||
void ModulePanel::update()
|
void ModulePanel::update()
|
||||||
{
|
{
|
||||||
unsigned int mask = 0;
|
unsigned int mask = 0;
|
||||||
Protocol protocol = (Protocol)module.protocol;
|
Protocol protocol = (Protocol)module.protocol;
|
||||||
|
|
||||||
switch (protocol) {
|
if (moduleIdx >= 0 || model.trainerMode != 0) {
|
||||||
case OFF:
|
mask |= MASK_PROTOCOL;
|
||||||
break;
|
switch (protocol) {
|
||||||
case PXX_XJT_X16:
|
case OFF:
|
||||||
case PXX_XJT_D8:
|
break;
|
||||||
case PXX_XJT_LR12:
|
case PXX_XJT_X16:
|
||||||
case PXX_DJT:
|
case PXX_XJT_D8:
|
||||||
mask |= MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT | MASK_RX_NUMBER;
|
case PXX_XJT_LR12:
|
||||||
if (protocol==PXX_XJT_X16) mask |= MASK_FAILSAFES;
|
case PXX_DJT:
|
||||||
break;
|
mask |= MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT | MASK_RX_NUMBER;
|
||||||
case LP45:
|
if (protocol==PXX_XJT_X16) mask |= MASK_FAILSAFES;
|
||||||
case DSM2:
|
break;
|
||||||
case DSMX:
|
case LP45:
|
||||||
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER;
|
case DSM2:
|
||||||
module.channelsCount = 8;
|
case DSMX:
|
||||||
break;
|
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER;
|
||||||
default:
|
module.channelsCount = 8;
|
||||||
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT;
|
break;
|
||||||
break;
|
default:
|
||||||
|
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE| MASK_CHANNELS_COUNT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui->label_protocol->setVisible(mask & MASK_PROTOCOL);
|
||||||
|
ui->protocol->setVisible(mask & MASK_PROTOCOL);
|
||||||
|
ui->label_rxNumber->setVisible(mask & MASK_PROTOCOL);
|
||||||
|
ui->rxNumber->setVisible(mask & MASK_PROTOCOL);
|
||||||
ui->rxNumber->setEnabled(mask & MASK_RX_NUMBER);
|
ui->rxNumber->setEnabled(mask & MASK_RX_NUMBER);
|
||||||
ui->rxNumber->setValue(model.modelId);
|
ui->rxNumber->setValue(model.modelId);
|
||||||
ui->label_channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
|
ui->label_channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
|
||||||
|
@ -220,6 +234,15 @@ void ModulePanel::update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModulePanel::on_trainerMode_currentIndexChanged(int index)
|
||||||
|
{
|
||||||
|
if (!lock) {
|
||||||
|
model.trainerMode = index;
|
||||||
|
update();
|
||||||
|
emit modified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ModulePanel::on_protocol_currentIndexChanged(int index)
|
void ModulePanel::on_protocol_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
|
@ -302,6 +325,8 @@ Setup::Setup(QWidget *parent, ModelData & model):
|
||||||
ModelPanel(parent, model),
|
ModelPanel(parent, model),
|
||||||
ui(new Ui::Setup)
|
ui(new Ui::Setup)
|
||||||
{
|
{
|
||||||
|
lock = true;
|
||||||
|
|
||||||
memset(modules, 0, sizeof(modules));
|
memset(modules, 0, sizeof(modules));
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -325,101 +350,99 @@ Setup::Setup(QWidget *parent, ModelData & model):
|
||||||
ui->modulesLayout->addWidget(modules[C9X_NUM_MODULES]);
|
ui->modulesLayout->addWidget(modules[C9X_NUM_MODULES]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetEepromInterface()->getCapability(ModelImage)) {
|
if (GetEepromInterface()->getCapability(ModelImage)) {
|
||||||
ui->image->hide();
|
QStringList items;
|
||||||
ui->modelImage_label->hide();
|
items.append("");
|
||||||
ui->imagePreview->hide();
|
QSettings settings("companion9x", "companion9x");
|
||||||
|
QString path = settings.value("sdPath", ".").toString();
|
||||||
|
path.append("/BMP/");
|
||||||
|
QDir qd(path);
|
||||||
|
int vml = GetEepromInterface()->getCapability(VoicesMaxLength)+4;
|
||||||
|
if (qd.exists()) {
|
||||||
|
QStringList filters;
|
||||||
|
filters << "*.bmp" << "*.bmp";
|
||||||
|
foreach ( QString file, qd.entryList(filters, QDir::Files) ) {
|
||||||
|
QFileInfo fi(file);
|
||||||
|
QString temp = fi.completeBaseName();
|
||||||
|
if (!items.contains(temp) && temp.length() <= vml) {
|
||||||
|
items.append(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!items.contains(model.bitmap)) {
|
||||||
|
items.append(model.bitmap);
|
||||||
|
}
|
||||||
|
items.sort();
|
||||||
|
foreach ( QString file, items ) {
|
||||||
|
ui->image->addItem(file);
|
||||||
|
if (file == model.bitmap) {
|
||||||
|
ui->image->setCurrentIndex(ui->image->count()-1);
|
||||||
|
QString fileName = path;
|
||||||
|
fileName.append(model.bitmap);
|
||||||
|
fileName.append(".bmp");
|
||||||
|
QImage image(fileName);
|
||||||
|
if (image.isNull()) {
|
||||||
|
fileName = path;
|
||||||
|
fileName.append(model.bitmap);
|
||||||
|
fileName.append(".BMP");
|
||||||
|
image.load(fileName);
|
||||||
|
}
|
||||||
|
if (!image.isNull()) {
|
||||||
|
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->image->hide();
|
||||||
|
ui->modelImage_label->hide();
|
||||||
|
ui->imagePreview->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Beep Center checkboxes
|
||||||
|
int analogs = 4 + GetEepromInterface()->getCapability(Pots);
|
||||||
|
for (int i=0; i<analogs+GetEepromInterface()->getCapability(RotaryEncoders); i++) {
|
||||||
|
QCheckBox * checkbox = new QCheckBox(this);
|
||||||
|
checkbox->setProperty("index", i);
|
||||||
|
checkbox->setText(i<analogs ? AnalogString(i) : RotaryEncoderString(i-analogs));
|
||||||
|
ui->centerBeepLayout->addWidget(checkbox, 0, i+1);
|
||||||
|
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
|
||||||
|
centerBeepCheckboxes << checkbox;
|
||||||
|
}
|
||||||
|
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, analogs+GetEepromInterface()->getCapability(RotaryEncoders));
|
||||||
|
|
||||||
|
// Startup switches warnings
|
||||||
|
ui->switchesStartupWarning->setProperty("index", 0);
|
||||||
|
connect(ui->switchesStartupWarning, SIGNAL(currentIndexChanged(int)), this, SLOT(startupSwitchEdited(int)));
|
||||||
|
for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
|
||||||
|
QLabel * label = new QLabel();
|
||||||
|
QSlider * slider = new QSlider();
|
||||||
|
slider->setProperty("index", i+1);
|
||||||
|
slider->setOrientation(Qt::Vertical);
|
||||||
|
slider->setMinimum(0);
|
||||||
|
slider->setSingleStep(1);
|
||||||
|
slider->setPageStep(1);
|
||||||
|
slider->setInvertedAppearance(true);
|
||||||
|
slider->setTickPosition(QSlider::TicksBothSides);
|
||||||
|
slider->setTickInterval(1);
|
||||||
|
slider->setMinimumSize(QSize(30, 50));
|
||||||
|
slider->setMaximumSize(QSize(50, 50));
|
||||||
|
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||||
|
label->setText(switchesX9D[i]);
|
||||||
|
slider->setMaximum(i==5 ? 1 : 2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
label->setText(switches9X[i]);
|
||||||
QStringList items;
|
slider->setMaximum(i==0 ? 2 : 1);
|
||||||
items.append("");
|
|
||||||
QSettings settings("companion9x", "companion9x");
|
|
||||||
QString path=settings.value("sdPath", ".").toString();
|
|
||||||
path.append("/BMP/");
|
|
||||||
QDir qd(path);
|
|
||||||
int vml= GetEepromInterface()->getCapability(VoicesMaxLength)+4;
|
|
||||||
if (qd.exists()) {
|
|
||||||
QStringList filters;
|
|
||||||
filters << "*.bmp" << "*.bmp";
|
|
||||||
foreach ( QString file, qd.entryList(filters, QDir::Files) ) {
|
|
||||||
QFileInfo fi(file);
|
|
||||||
QString temp=fi.completeBaseName();
|
|
||||||
if (!items.contains(temp) && temp.length()<=vml) {
|
|
||||||
items.append(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!items.contains(model.bitmap)) {
|
|
||||||
items.append(model.bitmap);
|
|
||||||
}
|
|
||||||
items.sort();
|
|
||||||
ui->image->clear();
|
|
||||||
foreach ( QString file, items ) {
|
|
||||||
ui->image->addItem(file);
|
|
||||||
if (file==model.bitmap) {
|
|
||||||
ui->image->setCurrentIndex(ui->image->count()-1);
|
|
||||||
QString fileName=path;
|
|
||||||
fileName.append(model.bitmap);
|
|
||||||
fileName.append(".bmp");
|
|
||||||
QImage image(fileName);
|
|
||||||
if (image.isNull()) {
|
|
||||||
fileName=path;
|
|
||||||
fileName.append(model.bitmap);
|
|
||||||
fileName.append(".BMP");
|
|
||||||
image.load(fileName);
|
|
||||||
}
|
|
||||||
if (!image.isNull()) {
|
|
||||||
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ui->switchesStartupLayout->addWidget(label, 0, i+1);
|
||||||
|
ui->switchesStartupLayout->addWidget(slider, 1, i+1);
|
||||||
|
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
|
||||||
|
startupSwitchesSliders << slider;
|
||||||
|
}
|
||||||
|
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches));
|
||||||
|
|
||||||
// Beep Center checkboxes
|
lock = false;
|
||||||
int analogs = 4 + GetEepromInterface()->getCapability(Pots);
|
|
||||||
for (int i=0; i<analogs+GetEepromInterface()->getCapability(RotaryEncoders); i++) {
|
|
||||||
QCheckBox * checkbox = new QCheckBox(this);
|
|
||||||
checkbox->setProperty("index", i);
|
|
||||||
checkbox->setText(i<analogs ? AnalogString(i) : RotaryEncoderString(i-analogs));
|
|
||||||
ui->centerBeepLayout->addWidget(checkbox, 0, i+1);
|
|
||||||
connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(onBeepCenterToggled(bool)));
|
|
||||||
centerBeepCheckboxes << checkbox;
|
|
||||||
}
|
|
||||||
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, analogs+GetEepromInterface()->getCapability(RotaryEncoders));
|
|
||||||
|
|
||||||
// Startup switches warnings
|
|
||||||
ui->switchesStartupWarning->setProperty("index", 0);
|
|
||||||
connect(ui->switchesStartupWarning, SIGNAL(currentIndexChanged(int)), this, SLOT(startupSwitchEdited(int)));
|
|
||||||
for (int i=0; i<GetEepromInterface()->getCapability(Switches)-1; i++) {
|
|
||||||
QLabel * label = new QLabel();
|
|
||||||
QSlider * slider = new QSlider();
|
|
||||||
slider->setProperty("index", i+1);
|
|
||||||
slider->setOrientation(Qt::Vertical);
|
|
||||||
slider->setMinimum(0);
|
|
||||||
slider->setSingleStep(1);
|
|
||||||
slider->setPageStep(1);
|
|
||||||
slider->setInvertedAppearance(true);
|
|
||||||
slider->setTickPosition(QSlider::TicksBothSides);
|
|
||||||
slider->setTickInterval(1);
|
|
||||||
slider->setMinimumSize(QSize(30, 50));
|
|
||||||
slider->setMaximumSize(QSize(50, 50));
|
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
|
||||||
label->setText(switchesX9D[i]);
|
|
||||||
slider->setMaximum(i==5 ? 1 : 2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
label->setText(switches9X[i]);
|
|
||||||
slider->setMaximum(i==0 ? 2 : 1);
|
|
||||||
}
|
|
||||||
ui->switchesStartupLayout->addWidget(label, 0, i+1);
|
|
||||||
ui->switchesStartupLayout->addWidget(slider, 1, i+1);
|
|
||||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(startupSwitchEdited(int)));
|
|
||||||
startupSwitchesSliders << slider;
|
|
||||||
}
|
|
||||||
ui->switchesStartupLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, GetEepromInterface()->getCapability(Switches));
|
|
||||||
|
|
||||||
lock = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Setup::~Setup()
|
Setup::~Setup()
|
||||||
|
|
|
@ -46,6 +46,7 @@ class ModulePanel : public ModelPanel
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void on_trainerMode_currentIndexChanged(int index);
|
||||||
void on_protocol_currentIndexChanged(int index);
|
void on_protocol_currentIndexChanged(int index);
|
||||||
void on_ppmDelay_editingFinished();
|
void on_ppmDelay_editingFinished();
|
||||||
void on_channelsCount_editingFinished();
|
void on_channelsCount_editingFinished();
|
||||||
|
|
|
@ -178,7 +178,7 @@ PACK(typedef struct {
|
||||||
|
|
||||||
swstate_t switchWarningStates;
|
swstate_t switchWarningStates;
|
||||||
|
|
||||||
char gvar_names[5][LEN_GVAR_NAME];
|
char gvar_names[5][LEN_GVAR_NAME];
|
||||||
|
|
||||||
FrSkyData_v215 frsky;
|
FrSkyData_v215 frsky;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue