mirror of
https://github.com/opentx/opentx.git
synced 2025-07-14 03:49:52 +03:00
Global Functions now integrated inside Companion - Fixes #502
This commit is contained in:
parent
343e395652
commit
ef7bbea285
45 changed files with 685 additions and 687 deletions
|
@ -296,7 +296,7 @@ void CompareDialog::printPhases()
|
||||||
str.append("</b></td><td rowspan=2 align=\"center\" valign=\"bottom\"><b>"+tr("Switch")+"</b></td></tr><tr><td align=center width=\"80\"><b>"+tr("Flight mode name"));
|
str.append("</b></td><td rowspan=2 align=\"center\" valign=\"bottom\"><b>"+tr("Switch")+"</b></td></tr><tr><td align=center width=\"80\"><b>"+tr("Flight mode name"));
|
||||||
str.append("</b></td><td align=center width=\"30\"><b>"+tr("IN")+"</b></td><td align=center width=\"30\"><b>"+tr("OUT")+"</b></td>");
|
str.append("</b></td><td align=center width=\"30\"><b>"+tr("IN")+"</b></td><td align=center width=\"30\"><b>"+tr("OUT")+"</b></td>");
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
str.append(QString("<td width=\"40\" align=\"center\"><b>%1</b></td>").arg(getInputStr(*g_model1, i)));
|
str.append(QString("<td width=\"40\" align=\"center\"><b>%1</b></td>").arg(getInputStr(g_model1, i)));
|
||||||
}
|
}
|
||||||
str.append("</tr>");
|
str.append("</tr>");
|
||||||
for (i=0; i<GetCurrentFirmware()->getCapability(FlightModes); i++) {
|
for (i=0; i<GetCurrentFirmware()->getCapability(FlightModes); i++) {
|
||||||
|
@ -385,7 +385,7 @@ void CompareDialog::printPhases()
|
||||||
str.append("</b></td><td rowspan=2 align=\"center\" valign=\"bottom\"><b>"+tr("Switch")+"</b></td></tr><tr><td align=center width=\"80\"><b>"+tr("Flight mode name"));
|
str.append("</b></td><td rowspan=2 align=\"center\" valign=\"bottom\"><b>"+tr("Switch")+"</b></td></tr><tr><td align=center width=\"80\"><b>"+tr("Flight mode name"));
|
||||||
str.append("</b></td><td align=center width=\"30\"><b>"+tr("IN")+"</b></td><td align=center width=\"30\"><b>"+tr("OUT")+"</b></td>");
|
str.append("</b></td><td align=center width=\"30\"><b>"+tr("IN")+"</b></td><td align=center width=\"30\"><b>"+tr("OUT")+"</b></td>");
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
str.append(QString("<td width=\"40\" align=\"center\"><b>%1</b></td>").arg(getInputStr(*g_model1, i)));
|
str.append(QString("<td width=\"40\" align=\"center\"><b>%1</b></td>").arg(getInputStr(g_model1, i)));
|
||||||
}
|
}
|
||||||
str.append("</tr>");
|
str.append("</tr>");
|
||||||
for (i=0; i<GetCurrentFirmware()->getCapability(FlightModes); i++) {
|
for (i=0; i<GetCurrentFirmware()->getCapability(FlightModes); i++) {
|
||||||
|
@ -668,7 +668,7 @@ void CompareDialog::printExpos()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str.append("</table></td>");
|
str.append("</table></td>");
|
||||||
str.append("<td width=\"10%\" align=\"center\" valign=\"middle\"><b>"+getInputStr(*g_model2, i)+"</b></td>");
|
str.append("<td width=\"10%\" align=\"center\" valign=\"middle\"><b>"+getInputStr(g_model2, i)+"</b></td>");
|
||||||
str.append("<td width=\"45%\">");
|
str.append("<td width=\"45%\">");
|
||||||
str.append("<table border=0 cellspacing=0 cellpadding=0>");
|
str.append("<table border=0 cellspacing=0 cellpadding=0>");
|
||||||
for (int j=0; j<C9X_MAX_EXPOS; j++) {
|
for (int j=0; j<C9X_MAX_EXPOS; j++) {
|
||||||
|
@ -793,7 +793,7 @@ void CompareDialog::printMixers()
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
str += QString(" %1").arg(getGVarString(md->weight)).rightJustified(6, ' ');
|
str += QString(" %1").arg(getGVarString(md->weight)).rightJustified(6, ' ');
|
||||||
str += md->srcRaw.toString(*g_model1);
|
str += md->srcRaw.toString(g_model1);
|
||||||
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
|
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
|
||||||
if (md->carryTrim) str += " " + tr("noTrim");
|
if (md->carryTrim) str += " " + tr("noTrim");
|
||||||
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
|
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
|
||||||
|
@ -871,7 +871,7 @@ void CompareDialog::printMixers()
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
str += QString(" %1").arg(getGVarString(md->weight)).rightJustified(6, ' ');
|
str += QString(" %1").arg(getGVarString(md->weight)).rightJustified(6, ' ');
|
||||||
str += md->srcRaw.toString(*g_model2);
|
str += md->srcRaw.toString(g_model2);
|
||||||
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
|
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
|
||||||
if (md->carryTrim) str += " " + tr("noTrim");
|
if (md->carryTrim) str += " " + tr("noTrim");
|
||||||
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
|
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
|
||||||
|
|
|
@ -92,7 +92,7 @@ QString getGVarString(int16_t val, bool sign)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RawSourceRange RawSource::getRange(const ModelData & model, const GeneralSettings & settings, unsigned int flags) const
|
RawSourceRange RawSource::getRange(const ModelData * model, const GeneralSettings & settings, unsigned int flags) const
|
||||||
{
|
{
|
||||||
RawSourceRange result;
|
RawSourceRange result;
|
||||||
|
|
||||||
|
@ -137,13 +137,13 @@ RawSourceRange RawSource::getRange(const ModelData & model, const GeneralSetting
|
||||||
case TELEMETRY_SOURCE_A2_MIN:
|
case TELEMETRY_SOURCE_A2_MIN:
|
||||||
case TELEMETRY_SOURCE_A3_MIN:
|
case TELEMETRY_SOURCE_A3_MIN:
|
||||||
case TELEMETRY_SOURCE_A4_MIN:
|
case TELEMETRY_SOURCE_A4_MIN:
|
||||||
result = model.frsky.channels[index-TELEMETRY_SOURCE_A1_MIN].getRange();
|
if (model) result = model->frsky.channels[index-TELEMETRY_SOURCE_A1_MIN].getRange();
|
||||||
break;
|
break;
|
||||||
case TELEMETRY_SOURCE_A1:
|
case TELEMETRY_SOURCE_A1:
|
||||||
case TELEMETRY_SOURCE_A2:
|
case TELEMETRY_SOURCE_A2:
|
||||||
case TELEMETRY_SOURCE_A3:
|
case TELEMETRY_SOURCE_A3:
|
||||||
case TELEMETRY_SOURCE_A4:
|
case TELEMETRY_SOURCE_A4:
|
||||||
result = model.frsky.channels[index-TELEMETRY_SOURCE_A1].getRange();
|
if (model) result = model->frsky.channels[index-TELEMETRY_SOURCE_A1].getRange();
|
||||||
break;
|
break;
|
||||||
case TELEMETRY_SOURCE_ALT:
|
case TELEMETRY_SOURCE_ALT:
|
||||||
case TELEMETRY_SOURCE_ALT_MIN:
|
case TELEMETRY_SOURCE_ALT_MIN:
|
||||||
|
@ -302,8 +302,10 @@ RawSourceRange RawSource::getRange(const ModelData & model, const GeneralSetting
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
result.max = model.getChannelsMax(true);
|
if (model) {
|
||||||
|
result.max = model->getChannelsMax(true);
|
||||||
result.min = -result.max;
|
result.min = -result.max;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +334,7 @@ QString RotaryEncoderString(int index)
|
||||||
return CHECK_IN_ARRAY(rotary, index);
|
return CHECK_IN_ARRAY(rotary, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RawSource::toString(const ModelData & model)
|
QString RawSource::toString(const ModelData * model)
|
||||||
{
|
{
|
||||||
static const QString trims[] = {
|
static const QString trims[] = {
|
||||||
QObject::tr("TrmR"), QObject::tr("TrmE"), QObject::tr("TrmT"), QObject::tr("TrmA")
|
QObject::tr("TrmR"), QObject::tr("TrmE"), QObject::tr("TrmT"), QObject::tr("TrmA")
|
||||||
|
@ -367,8 +369,8 @@ QString RawSource::toString(const ModelData & model)
|
||||||
case SOURCE_TYPE_VIRTUAL_INPUT:
|
case SOURCE_TYPE_VIRTUAL_INPUT:
|
||||||
{
|
{
|
||||||
QString result = QObject::tr("[I%1]").arg(index+1);
|
QString result = QObject::tr("[I%1]").arg(index+1);
|
||||||
if (strlen(model.inputNames[index]) > 0) {
|
if (model && strlen(model->inputNames[index]) > 0) {
|
||||||
result += QString(model.inputNames[index]);
|
result += QString(model->inputNames[index]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -618,10 +620,10 @@ QString LogicalSwitchData::toString(const ModelData & model, const GeneralSettin
|
||||||
break;
|
break;
|
||||||
case LS_FAMILY_VOFS: {
|
case LS_FAMILY_VOFS: {
|
||||||
RawSource source = RawSource(val1);
|
RawSource source = RawSource(val1);
|
||||||
RawSourceRange range = source.getRange(model, settings);
|
RawSourceRange range = source.getRange(&model, settings);
|
||||||
QString res;
|
QString res;
|
||||||
if (val1)
|
if (val1)
|
||||||
res += source.toString(model);
|
res += source.toString(&model);
|
||||||
else
|
else
|
||||||
res += "0";
|
res += "0";
|
||||||
res.remove(" ");
|
res.remove(" ");
|
||||||
|
@ -664,7 +666,7 @@ QString LogicalSwitchData::toString(const ModelData & model, const GeneralSettin
|
||||||
|
|
||||||
case LS_FAMILY_VCOMP:
|
case LS_FAMILY_VCOMP:
|
||||||
if (val1)
|
if (val1)
|
||||||
result += RawSource(val1).toString(model);
|
result += RawSource(val1).toString(&model);
|
||||||
else
|
else
|
||||||
result += "0";
|
result += "0";
|
||||||
switch (func) {
|
switch (func) {
|
||||||
|
@ -692,7 +694,7 @@ QString LogicalSwitchData::toString(const ModelData & model, const GeneralSettin
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (val2)
|
if (val2)
|
||||||
result += RawSource(val2).toString(model);
|
result += RawSource(val2).toString(&model);
|
||||||
else
|
else
|
||||||
result += "0";
|
result += "0";
|
||||||
break;
|
break;
|
||||||
|
@ -723,9 +725,8 @@ void CustomFunctionData::clear()
|
||||||
|
|
||||||
QString CustomFunctionData::funcToString()
|
QString CustomFunctionData::funcToString()
|
||||||
{
|
{
|
||||||
ModelData model;
|
|
||||||
if (func >= FuncOverrideCH1 && func <= FuncOverrideCH32)
|
if (func >= FuncOverrideCH1 && func <= FuncOverrideCH32)
|
||||||
return QObject::tr("Override %1").arg(RawSource(SOURCE_TYPE_CH, func).toString(model));
|
return QObject::tr("Override %1").arg(RawSource(SOURCE_TYPE_CH, func).toString());
|
||||||
else if (func == FuncTrainer)
|
else if (func == FuncTrainer)
|
||||||
return QObject::tr("Trainer");
|
return QObject::tr("Trainer");
|
||||||
else if (func == FuncTrainerRUD)
|
else if (func == FuncTrainerRUD)
|
||||||
|
@ -805,27 +806,26 @@ QString CustomFunctionData::paramToString()
|
||||||
}
|
}
|
||||||
else if ((func==FuncVolume)|| (func==FuncPlayValue)) {
|
else if ((func==FuncVolume)|| (func==FuncPlayValue)) {
|
||||||
RawSource item(param);
|
RawSource item(param);
|
||||||
ModelData model;
|
return item.toString();
|
||||||
return item.toString(model);
|
|
||||||
}
|
}
|
||||||
else if ((func==FuncPlayPrompt) || (func==FuncPlayBoth)) {
|
else if ((func==FuncPlayPrompt) || (func==FuncPlayBoth)) {
|
||||||
if ( GetCurrentFirmware()->getCapability(VoicesAsNumbers)) {
|
if ( GetCurrentFirmware()->getCapability(VoicesAsNumbers)) {
|
||||||
return QString("%1").arg(param);
|
return QString("%1").arg(param);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return paramarm;
|
return paramarm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((func>FuncBackgroundMusicPause) && (func<FuncCount)) {
|
else if ((func>FuncBackgroundMusicPause) && (func<FuncCount)) {
|
||||||
ModelData model;
|
|
||||||
switch (adjustMode) {
|
switch (adjustMode) {
|
||||||
case 0:
|
case 0:
|
||||||
return QObject::tr("Value ")+QString("%1").arg(param);
|
return QObject::tr("Value ")+QString("%1").arg(param);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
return RawSource(param).toString(model);
|
return RawSource(param).toString();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
return RawSource(param).toString(model);
|
return RawSource(param).toString();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (param==0) {
|
if (param==0) {
|
||||||
|
@ -1184,7 +1184,7 @@ void ModelData::setDefaultInputs(const GeneralSettings & settings)
|
||||||
expo->mode = INPUT_MODE_BOTH;
|
expo->mode = INPUT_MODE_BOTH;
|
||||||
expo->srcRaw = settings.getDefaultSource(i);
|
expo->srcRaw = settings.getDefaultSource(i);
|
||||||
expo->weight = 100;
|
expo->weight = 100;
|
||||||
strncpy(inputNames[i], expo->srcRaw.toString(*this).toLatin1().constData(), sizeof(inputNames[i])-1);
|
strncpy(inputNames[i], expo->srcRaw.toString(this).toLatin1().constData(), sizeof(inputNames[i])-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,6 +208,9 @@ extern const char rightArrow[];
|
||||||
extern const char upArrow[];
|
extern const char upArrow[];
|
||||||
extern const char downArrow[];
|
extern const char downArrow[];
|
||||||
|
|
||||||
|
class ModelData;
|
||||||
|
class GeneralSettings;
|
||||||
|
|
||||||
enum ThrottleSource {
|
enum ThrottleSource {
|
||||||
THROTTLE_SOURCE_THR,
|
THROTTLE_SOURCE_THR,
|
||||||
THROTTLE_SOURCE_P1,
|
THROTTLE_SOURCE_P1,
|
||||||
|
@ -302,8 +305,6 @@ enum RawSourceType {
|
||||||
MAX_SOURCE_TYPE
|
MAX_SOURCE_TYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
class ModelData;
|
|
||||||
|
|
||||||
QString AnalogString(int index);
|
QString AnalogString(int index);
|
||||||
QString RotaryEncoderString(int index);
|
QString RotaryEncoderString(int index);
|
||||||
|
|
||||||
|
@ -335,7 +336,6 @@ class RawSourceRange
|
||||||
#define RANGE_DELTA_FUNCTION 2
|
#define RANGE_DELTA_FUNCTION 2
|
||||||
#define RANGE_DELTA_ABS_FUNCTION 4
|
#define RANGE_DELTA_ABS_FUNCTION 4
|
||||||
|
|
||||||
class GeneralSettings;
|
|
||||||
class RawSource {
|
class RawSource {
|
||||||
public:
|
public:
|
||||||
RawSource():
|
RawSource():
|
||||||
|
@ -361,9 +361,9 @@ class RawSource {
|
||||||
return index >= 0 ? (type * 65536 + index) : -(type * 65536 - index);
|
return index >= 0 ? (type * 65536 + index) : -(type * 65536 - index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString toString(const ModelData & model);
|
QString toString(const ModelData * model = NULL);
|
||||||
|
|
||||||
RawSourceRange getRange(const ModelData & model, const GeneralSettings & settings, unsigned int flags=0) const;
|
RawSourceRange getRange(const ModelData * model, const GeneralSettings & settings, unsigned int flags=0) const;
|
||||||
|
|
||||||
bool operator == ( const RawSource & other) {
|
bool operator == ( const RawSource & other) {
|
||||||
return (this->type == other.type) && (this->index == other.index);
|
return (this->type == other.type) && (this->index == other.index);
|
||||||
|
@ -434,121 +434,6 @@ class RawSwitch {
|
||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TrainerMix {
|
|
||||||
public:
|
|
||||||
TrainerMix() { clear(); }
|
|
||||||
unsigned int src; // 0-7 = ch1-8
|
|
||||||
RawSwitch swtch;
|
|
||||||
int weight;
|
|
||||||
unsigned int mode; // off, add-mode, subst-mode
|
|
||||||
void clear() { memset(this, 0, sizeof(TrainerMix)); }
|
|
||||||
};
|
|
||||||
|
|
||||||
class TrainerData {
|
|
||||||
public:
|
|
||||||
TrainerData() { clear(); }
|
|
||||||
int calib[4];
|
|
||||||
TrainerMix mix[4];
|
|
||||||
void clear() { memset(this, 0, sizeof(TrainerData)); }
|
|
||||||
};
|
|
||||||
|
|
||||||
enum BeeperMode {
|
|
||||||
e_quiet = -2,
|
|
||||||
e_alarms_only = -1,
|
|
||||||
e_no_keys = 0,
|
|
||||||
e_all = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
class GeneralSettings {
|
|
||||||
public:
|
|
||||||
GeneralSettings();
|
|
||||||
|
|
||||||
int getDefaultStick(unsigned int channel) const;
|
|
||||||
RawSource getDefaultSource(unsigned int channel) const;
|
|
||||||
int getDefaultChannel(unsigned int stick) const;
|
|
||||||
|
|
||||||
unsigned int version;
|
|
||||||
unsigned int variant;
|
|
||||||
int calibMid[NUM_STICKS+C9X_NUM_POTS];
|
|
||||||
int calibSpanNeg[NUM_STICKS+C9X_NUM_POTS];
|
|
||||||
int calibSpanPos[NUM_STICKS+C9X_NUM_POTS];
|
|
||||||
unsigned int currModel; // 0..15
|
|
||||||
unsigned int contrast;
|
|
||||||
unsigned int vBatWarn;
|
|
||||||
int vBatCalib;
|
|
||||||
int vBatMin;
|
|
||||||
int vBatMax;
|
|
||||||
int backlightMode;
|
|
||||||
TrainerData trainer;
|
|
||||||
unsigned int view; // main screen view // TODO enum
|
|
||||||
bool disableThrottleWarning;
|
|
||||||
bool fai;
|
|
||||||
int switchWarning; // -1=down, 0=off, 1=up
|
|
||||||
bool disableMemoryWarning;
|
|
||||||
BeeperMode beeperMode;
|
|
||||||
bool disableAlarmWarning;
|
|
||||||
bool enableTelemetryAlarm;
|
|
||||||
BeeperMode hapticMode;
|
|
||||||
unsigned int stickMode; // TODO enum
|
|
||||||
int timezone;
|
|
||||||
bool optrexDisplay;
|
|
||||||
unsigned int inactivityTimer;
|
|
||||||
bool minuteBeep;
|
|
||||||
bool preBeep;
|
|
||||||
bool flashBeep;
|
|
||||||
bool disablePotScroll;
|
|
||||||
bool frskyinternalalarm;
|
|
||||||
bool disableBG;
|
|
||||||
unsigned int splashMode;
|
|
||||||
int splashDuration;
|
|
||||||
unsigned int backlightDelay;
|
|
||||||
bool blightinv;
|
|
||||||
bool stickScroll;
|
|
||||||
unsigned int templateSetup; //RETA order according to chout_ar array
|
|
||||||
int PPM_Multiplier;
|
|
||||||
int hapticLength;
|
|
||||||
unsigned int reNavigation;
|
|
||||||
unsigned int stickReverse;
|
|
||||||
bool hideNameOnSplash;
|
|
||||||
bool enablePpmsim;
|
|
||||||
unsigned int speakerPitch;
|
|
||||||
int hapticStrength;
|
|
||||||
unsigned int speakerMode;
|
|
||||||
unsigned int lightOnStickMove; /* er9x / ersky9x only */
|
|
||||||
char ownerName[10+1];
|
|
||||||
unsigned int switchWarningStates;
|
|
||||||
int beeperLength;
|
|
||||||
unsigned int gpsFormat;
|
|
||||||
int speakerVolume;
|
|
||||||
unsigned int backlightBright;
|
|
||||||
int switchesDelay;
|
|
||||||
int currentCalib;
|
|
||||||
int temperatureCalib;
|
|
||||||
int temperatureWarn;
|
|
||||||
unsigned int mAhWarn;
|
|
||||||
unsigned int mAhUsed;
|
|
||||||
unsigned int globalTimer;
|
|
||||||
unsigned int btBaudrate;
|
|
||||||
unsigned int sticksGain;
|
|
||||||
unsigned int rotarySteps;
|
|
||||||
unsigned int countryCode;
|
|
||||||
unsigned int imperial;
|
|
||||||
bool crosstrim;
|
|
||||||
char ttsLanguage[2+1];
|
|
||||||
int beepVolume;
|
|
||||||
int wavVolume;
|
|
||||||
int varioVolume;
|
|
||||||
int varioPitch;
|
|
||||||
int varioRange;
|
|
||||||
int varioRepeat;
|
|
||||||
int backgroundVolume;
|
|
||||||
unsigned int mavbaud;
|
|
||||||
unsigned int switchUnlockStates;
|
|
||||||
unsigned int hw_uartMode;
|
|
||||||
unsigned int potsType[8];
|
|
||||||
unsigned int backlightColor;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CurveReference {
|
class CurveReference {
|
||||||
public:
|
public:
|
||||||
enum CurveRefType {
|
enum CurveRefType {
|
||||||
|
@ -1067,6 +952,123 @@ class ModelData {
|
||||||
void removeGlobalVar(int & var);
|
void removeGlobalVar(int & var);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TrainerMix {
|
||||||
|
public:
|
||||||
|
TrainerMix() { clear(); }
|
||||||
|
unsigned int src; // 0-7 = ch1-8
|
||||||
|
RawSwitch swtch;
|
||||||
|
int weight;
|
||||||
|
unsigned int mode; // off, add-mode, subst-mode
|
||||||
|
void clear() { memset(this, 0, sizeof(TrainerMix)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
class TrainerData {
|
||||||
|
public:
|
||||||
|
TrainerData() { clear(); }
|
||||||
|
int calib[4];
|
||||||
|
TrainerMix mix[4];
|
||||||
|
void clear() { memset(this, 0, sizeof(TrainerData)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
enum BeeperMode {
|
||||||
|
e_quiet = -2,
|
||||||
|
e_alarms_only = -1,
|
||||||
|
e_no_keys = 0,
|
||||||
|
e_all = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
class GeneralSettings {
|
||||||
|
public:
|
||||||
|
GeneralSettings();
|
||||||
|
|
||||||
|
int getDefaultStick(unsigned int channel) const;
|
||||||
|
RawSource getDefaultSource(unsigned int channel) const;
|
||||||
|
int getDefaultChannel(unsigned int stick) const;
|
||||||
|
|
||||||
|
unsigned int version;
|
||||||
|
unsigned int variant;
|
||||||
|
int calibMid[NUM_STICKS+C9X_NUM_POTS];
|
||||||
|
int calibSpanNeg[NUM_STICKS+C9X_NUM_POTS];
|
||||||
|
int calibSpanPos[NUM_STICKS+C9X_NUM_POTS];
|
||||||
|
unsigned int currModel; // 0..15
|
||||||
|
unsigned int contrast;
|
||||||
|
unsigned int vBatWarn;
|
||||||
|
int vBatCalib;
|
||||||
|
int vBatMin;
|
||||||
|
int vBatMax;
|
||||||
|
int backlightMode;
|
||||||
|
TrainerData trainer;
|
||||||
|
unsigned int view; // main screen view // TODO enum
|
||||||
|
bool disableThrottleWarning;
|
||||||
|
bool fai;
|
||||||
|
int switchWarning; // -1=down, 0=off, 1=up
|
||||||
|
bool disableMemoryWarning;
|
||||||
|
BeeperMode beeperMode;
|
||||||
|
bool disableAlarmWarning;
|
||||||
|
bool enableTelemetryAlarm;
|
||||||
|
BeeperMode hapticMode;
|
||||||
|
unsigned int stickMode; // TODO enum
|
||||||
|
int timezone;
|
||||||
|
bool optrexDisplay;
|
||||||
|
unsigned int inactivityTimer;
|
||||||
|
bool minuteBeep;
|
||||||
|
bool preBeep;
|
||||||
|
bool flashBeep;
|
||||||
|
bool disablePotScroll;
|
||||||
|
bool frskyinternalalarm;
|
||||||
|
bool disableBG;
|
||||||
|
unsigned int splashMode;
|
||||||
|
int splashDuration;
|
||||||
|
unsigned int backlightDelay;
|
||||||
|
bool blightinv;
|
||||||
|
bool stickScroll;
|
||||||
|
unsigned int templateSetup; //RETA order according to chout_ar array
|
||||||
|
int PPM_Multiplier;
|
||||||
|
int hapticLength;
|
||||||
|
unsigned int reNavigation;
|
||||||
|
unsigned int stickReverse;
|
||||||
|
bool hideNameOnSplash;
|
||||||
|
bool enablePpmsim;
|
||||||
|
unsigned int speakerPitch;
|
||||||
|
int hapticStrength;
|
||||||
|
unsigned int speakerMode;
|
||||||
|
unsigned int lightOnStickMove; /* er9x / ersky9x only */
|
||||||
|
char ownerName[10+1];
|
||||||
|
unsigned int switchWarningStates;
|
||||||
|
int beeperLength;
|
||||||
|
unsigned int gpsFormat;
|
||||||
|
int speakerVolume;
|
||||||
|
unsigned int backlightBright;
|
||||||
|
int switchesDelay;
|
||||||
|
int currentCalib;
|
||||||
|
int temperatureCalib;
|
||||||
|
int temperatureWarn;
|
||||||
|
unsigned int mAhWarn;
|
||||||
|
unsigned int mAhUsed;
|
||||||
|
unsigned int globalTimer;
|
||||||
|
unsigned int btBaudrate;
|
||||||
|
unsigned int sticksGain;
|
||||||
|
unsigned int rotarySteps;
|
||||||
|
unsigned int countryCode;
|
||||||
|
unsigned int imperial;
|
||||||
|
bool crosstrim;
|
||||||
|
char ttsLanguage[2+1];
|
||||||
|
int beepVolume;
|
||||||
|
int wavVolume;
|
||||||
|
int varioVolume;
|
||||||
|
int varioPitch;
|
||||||
|
int varioRange;
|
||||||
|
int varioRepeat;
|
||||||
|
int backgroundVolume;
|
||||||
|
unsigned int mavbaud;
|
||||||
|
unsigned int switchUnlockStates;
|
||||||
|
unsigned int hw_uartMode;
|
||||||
|
unsigned int potsType[8];
|
||||||
|
unsigned int backlightColor;
|
||||||
|
CustomFunctionData customFn[C9X_MAX_CUSTOM_FUNCTIONS];
|
||||||
|
};
|
||||||
|
|
||||||
class RadioData {
|
class RadioData {
|
||||||
public:
|
public:
|
||||||
GeneralSettings generalSettings;
|
GeneralSettings generalSettings;
|
||||||
|
|
|
@ -524,7 +524,7 @@ class SourceField: public ConversionField< UnsignedField<N> > {
|
||||||
public:
|
public:
|
||||||
SourceField(RawSource & source, BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags=0):
|
SourceField(RawSource & source, BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags=0):
|
||||||
ConversionField< UnsignedField<N> >(_source, SourcesConversionTable::getInstance(board, version, variant, flags),
|
ConversionField< UnsignedField<N> >(_source, SourcesConversionTable::getInstance(board, version, variant, flags),
|
||||||
"Source", "Source "+ source.toString(ModelData())+" cannot be exported on this board!"),
|
"Source", "Source "+ source.toString()+" cannot be exported on this board!"),
|
||||||
source(source),
|
source(source),
|
||||||
_source(0)
|
_source(0)
|
||||||
{
|
{
|
||||||
|
@ -1888,12 +1888,14 @@ class ArmCustomFunctionField: public TransformedField {
|
||||||
variant(variant),
|
variant(variant),
|
||||||
functionsConversionTable(board, version),
|
functionsConversionTable(board, version),
|
||||||
sourcesConversionTable(SourcesConversionTable::getInstance(board, version, variant, version >= 216 ? 0 : FLAG_NONONE)),
|
sourcesConversionTable(SourcesConversionTable::getInstance(board, version, variant, version >= 216 ? 0 : FLAG_NONONE)),
|
||||||
_active(0)
|
_func(0),
|
||||||
|
_active(0),
|
||||||
|
_mode(0)
|
||||||
{
|
{
|
||||||
memset(_param, 0, sizeof(_param));
|
memset(_param, 0, sizeof(_param));
|
||||||
|
|
||||||
internalField.Append(new SwitchField<8>(fn.swtch, board, version));
|
internalField.Append(new SwitchField<8>(fn.swtch, board, version));
|
||||||
internalField.Append(new ConversionField< UnsignedField<8> >((unsigned int &)fn.func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function")));
|
internalField.Append(new ConversionField< UnsignedField<8> >(_func, &functionsConversionTable, "Function", ::QObject::tr("OpenTX on this board doesn't accept this function")));
|
||||||
|
|
||||||
if (IS_TARANIS(board) && version >= 216)
|
if (IS_TARANIS(board) && version >= 216)
|
||||||
internalField.Append(new CharField<8>(_param, false));
|
internalField.Append(new CharField<8>(_param, false));
|
||||||
|
@ -1917,7 +1919,8 @@ class ArmCustomFunctionField: public TransformedField {
|
||||||
|
|
||||||
virtual void beforeExport()
|
virtual void beforeExport()
|
||||||
{
|
{
|
||||||
_mode = 0;
|
if (fn.swtch.type != SWITCH_TYPE_NONE) {
|
||||||
|
_func = fn.func;
|
||||||
|
|
||||||
if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue || fn.func == FuncPlayHaptic)
|
if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue || fn.func == FuncPlayHaptic)
|
||||||
_active = (version >= 216 ? fn.repeatParam : (fn.repeatParam/5));
|
_active = (version >= 216 ? fn.repeatParam : (fn.repeatParam/5));
|
||||||
|
@ -1994,9 +1997,12 @@ class ArmCustomFunctionField: public TransformedField {
|
||||||
*((uint32_t *)_param) = fn.param;
|
*((uint32_t *)_param) = fn.param;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual void afterImport()
|
virtual void afterImport()
|
||||||
{
|
{
|
||||||
|
fn.func = (AssignFunc)_func;
|
||||||
|
|
||||||
if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue || fn.func == FuncPlayHaptic)
|
if (fn.func == FuncPlaySound || fn.func == FuncPlayPrompt || fn.func == FuncPlayValue || fn.func == FuncPlayHaptic)
|
||||||
fn.repeatParam = (version >= 216 ? _active : (_active*5));
|
fn.repeatParam = (version >= 216 ? _active : (_active*5));
|
||||||
else
|
else
|
||||||
|
@ -2079,6 +2085,7 @@ class ArmCustomFunctionField: public TransformedField {
|
||||||
unsigned int variant;
|
unsigned int variant;
|
||||||
CustomFunctionsConversionTable functionsConversionTable;
|
CustomFunctionsConversionTable functionsConversionTable;
|
||||||
SourcesConversionTable * sourcesConversionTable;
|
SourcesConversionTable * sourcesConversionTable;
|
||||||
|
unsigned int _func;
|
||||||
char _param[10];
|
char _param[10];
|
||||||
int _active;
|
int _active;
|
||||||
unsigned int _mode;
|
unsigned int _mode;
|
||||||
|
@ -2978,6 +2985,14 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, BoardEnum bo
|
||||||
}
|
}
|
||||||
internalField.Append(new UnsignedField<8>(generalData.backlightColor));
|
internalField.Append(new UnsignedField<8>(generalData.backlightColor));
|
||||||
}
|
}
|
||||||
|
if (version >= 216) {
|
||||||
|
internalField.Append(new SpareBitsField<16>());
|
||||||
|
}
|
||||||
|
if (version >= 217) {
|
||||||
|
for (int i=0; i<MAX_CUSTOM_FUNCTIONS(board, version); i++) {
|
||||||
|
internalField.Append(new ArmCustomFunctionField(generalData.customFn[i], board, version, variant));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
set(generaledit_NAMES
|
set(generaledit_NAMES
|
||||||
generaledit
|
generaledit
|
||||||
setup
|
generalsetup
|
||||||
trainer
|
trainer
|
||||||
calibration
|
calibration
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,20 +5,10 @@
|
||||||
#include "ui_generaledit.h"
|
#include "ui_generaledit.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
#include "setup.h"
|
#include "generalsetup.h"
|
||||||
#include "trainer.h"
|
#include "trainer.h"
|
||||||
#include "calibration.h"
|
#include "calibration.h"
|
||||||
|
#include "../modeledit/customfunctions.h"
|
||||||
GeneralPanel::GeneralPanel(QWidget * parent, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
|
||||||
GenericPanel(parent),
|
|
||||||
generalSettings(generalSettings),
|
|
||||||
firmware(firmware)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GeneralPanel::~GeneralPanel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, FirmwareInterface * firmware) :
|
GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, FirmwareInterface * firmware) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -48,6 +38,9 @@ GeneralEdit::GeneralEdit(QWidget * parent, RadioData & radioData, FirmwareInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup"));
|
addTab(new GeneralSetupPanel(this, generalSettings, firmware), tr("Setup"));
|
||||||
|
if (IS_ARM(firmware->getBoard())) {
|
||||||
|
addTab(new CustomFunctionsPanel(this, NULL, generalSettings, firmware), tr("Global Functions"));
|
||||||
|
}
|
||||||
addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer"));
|
addTab(new TrainerPanel(this, generalSettings, firmware), tr("Trainer"));
|
||||||
addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration"));
|
addTab(new CalibrationPanel(this, generalSettings, firmware), tr("Calibration"));
|
||||||
}
|
}
|
||||||
|
@ -57,7 +50,7 @@ GeneralEdit::~GeneralEdit()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralEdit::addTab(GeneralPanel *panel, QString text)
|
void GeneralEdit::addTab(GenericPanel *panel, QString text)
|
||||||
{
|
{
|
||||||
panels << panel;
|
panels << panel;
|
||||||
QWidget * widget = new QWidget(ui->tabWidget);
|
QWidget * widget = new QWidget(ui->tabWidget);
|
||||||
|
@ -75,6 +68,7 @@ void GeneralEdit::onTabModified()
|
||||||
|
|
||||||
void GeneralEdit::on_tabWidget_currentChanged(int index)
|
void GeneralEdit::on_tabWidget_currentChanged(int index)
|
||||||
{
|
{
|
||||||
|
panels[index]->update();
|
||||||
g.generalEditTab(index);
|
g.generalEditTab(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,15 +11,11 @@ namespace Ui {
|
||||||
|
|
||||||
class GeneralPanel : public GenericPanel
|
class GeneralPanel : public GenericPanel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GeneralPanel(QWidget *parent, GeneralSettings & generalSettings, FirmwareInterface * firmware);
|
GeneralPanel(QWidget *parent, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
||||||
virtual ~GeneralPanel();
|
GenericPanel(parent, NULL, generalSettings, firmware)
|
||||||
|
{
|
||||||
protected:
|
}
|
||||||
GeneralSettings & generalSettings;
|
|
||||||
FirmwareInterface * firmware;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GeneralEdit : public QDialog
|
class GeneralEdit : public QDialog
|
||||||
|
@ -52,8 +48,8 @@ class GeneralEdit : public QDialog
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FirmwareInterface * firmware;
|
FirmwareInterface * firmware;
|
||||||
QVector<GeneralPanel *> panels;
|
QVector<GenericPanel *> panels;
|
||||||
void addTab(GeneralPanel *panel, QString text);
|
void addTab(GenericPanel *panel, QString text);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include "setup.h"
|
#include "generalsetup.h"
|
||||||
#include "ui_setup.h"
|
#include "ui_generalsetup.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
GeneralSetupPanel::GeneralSetupPanel(QWidget * parent, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
||||||
GeneralPanel(parent, generalSettings, firmware),
|
GeneralPanel(parent, generalSettings, firmware),
|
||||||
ui(new Ui::Setup)
|
ui(new Ui::GeneralSetup)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef SETUP_H
|
#ifndef GENERALSETUP_H
|
||||||
#define SETUP_H
|
#define GENERALSETUP_H
|
||||||
|
|
||||||
#include "generaledit.h"
|
#include "generaledit.h"
|
||||||
#include "eeprominterface.h"
|
#include "eeprominterface.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Setup;
|
class GeneralSetup;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GeneralSetupPanel : public GeneralPanel
|
class GeneralSetupPanel : public GeneralPanel
|
||||||
|
@ -63,7 +63,7 @@ class GeneralSetupPanel : public GeneralPanel
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Setup *ui;
|
Ui::GeneralSetup *ui;
|
||||||
|
|
||||||
void setValues();
|
void setValues();
|
||||||
void populateBacklightCB();
|
void populateBacklightCB();
|
||||||
|
@ -72,4 +72,4 @@ class GeneralSetupPanel : public GeneralPanel
|
||||||
void updateVarioPitchRange();
|
void updateVarioPitchRange();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETUP_H
|
#endif // GENERALSETUP_H
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>Setup</class>
|
<class>GeneralSetup</class>
|
||||||
<widget class="QWidget" name="Setup">
|
<widget class="QWidget" name="GeneralSetup">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
|
@ -65,14 +65,14 @@ QString getPhaseName(int val, const char * phasename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getInputStr(ModelData & model, int index)
|
QString getInputStr(ModelData * model, int index)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
if (GetCurrentFirmware()->getCapability(VirtualInputs)) {
|
if (GetCurrentFirmware()->getCapability(VirtualInputs)) {
|
||||||
if (strlen(model.inputNames[index]) > 0) {
|
if (strlen(model->inputNames[index]) > 0) {
|
||||||
result = QObject::tr("[I%1]").arg(index+1);
|
result = QObject::tr("[I%1]").arg(index+1);
|
||||||
result += QString(model.inputNames[index]);
|
result += QString(model->inputNames[index]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = QObject::tr("Input%1").arg(index+1, 2, 10, QChar('0'));
|
result = QObject::tr("Input%1").arg(index+1, 2, 10, QChar('0'));
|
||||||
|
@ -516,7 +516,7 @@ void populateGVCB(QComboBox *b, int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData & model, unsigned int flags)
|
void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData * model, unsigned int flags)
|
||||||
{
|
{
|
||||||
BoardEnum board = GetCurrentFirmware()->getBoard();
|
BoardEnum board = GetCurrentFirmware()->getBoard();
|
||||||
RawSource item;
|
RawSource item;
|
||||||
|
@ -539,10 +539,10 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & POPULATE_VIRTUAL_INPUTS) {
|
if (model && (flags & POPULATE_VIRTUAL_INPUTS)) {
|
||||||
int virtualInputs = GetCurrentFirmware()->getCapability(VirtualInputs);
|
int virtualInputs = GetCurrentFirmware()->getCapability(VirtualInputs);
|
||||||
for (int i=0; i<virtualInputs; i++) {
|
for (int i=0; i<virtualInputs; i++) {
|
||||||
if (model.isInputValid(i)) {
|
if (model->isInputValid(i)) {
|
||||||
item = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i);
|
item = RawSource(SOURCE_TYPE_VIRTUAL_INPUT, i);
|
||||||
b->addItem(item.toString(model), item.toValue());
|
b->addItem(item.toString(model), item.toValue());
|
||||||
if (item == source) b->setCurrentIndex(b->count()-1);
|
if (item == source) b->setCurrentIndex(b->count()-1);
|
||||||
|
@ -761,8 +761,7 @@ QString getFrSkyMeasure(int units)
|
||||||
|
|
||||||
QString getFrSkySrc(int index)
|
QString getFrSkySrc(int index)
|
||||||
{
|
{
|
||||||
ModelData model;
|
return RawSource(SOURCE_TYPE_TELEMETRY, index-1).toString();
|
||||||
return RawSource(SOURCE_TYPE_TELEMETRY, index-1).toString(model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getTrimInc(ModelData * g_model)
|
QString getTrimInc(ModelData * g_model)
|
||||||
|
@ -808,7 +807,7 @@ QString getProtocol(ModelData * g_model)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getPhasesStr(unsigned int phases, ModelData & model)
|
QString getPhasesStr(unsigned int phases, ModelData * model)
|
||||||
{
|
{
|
||||||
int numphases = GetCurrentFirmware()->getCapability(FlightModes);
|
int numphases = GetCurrentFirmware()->getCapability(FlightModes);
|
||||||
|
|
||||||
|
@ -822,7 +821,7 @@ QString getPhasesStr(unsigned int phases, ModelData & model)
|
||||||
for (int i=0; i<numphases;i++) {
|
for (int i=0; i<numphases;i++) {
|
||||||
if (!(phases & (1<<i))) {
|
if (!(phases & (1<<i))) {
|
||||||
if (count++ > 0) str += QString(", ");
|
if (count++ > 0) str += QString(", ");
|
||||||
str += getPhaseName(i+1, model.flightModeData[i].name);
|
str += getPhaseName(i+1, model->flightModeData[i].name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -998,8 +997,11 @@ QString generateProcessUniqueTempFileName(const QString & fileName)
|
||||||
return QDir::tempPath() + QString("/%1-").arg(QCoreApplication::applicationPid()) + sanitizedFileName;
|
return QDir::tempPath() + QString("/%1-").arg(QCoreApplication::applicationPid()) + sanitizedFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericPanel::GenericPanel(QWidget * parent):
|
GenericPanel::GenericPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
model(model),
|
||||||
|
generalSettings(generalSettings),
|
||||||
|
firmware(firmware),
|
||||||
lock(false)
|
lock(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, const GeneralSettin
|
||||||
void populatePhasesCB(QComboBox *b, int value);
|
void populatePhasesCB(QComboBox *b, int value);
|
||||||
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
void populateGvarUseCB(QComboBox *b, unsigned int phase);
|
||||||
QString getProtocolStr(const int proto);
|
QString getProtocolStr(const int proto);
|
||||||
QString getPhasesStr(unsigned int phases, ModelData & model);
|
QString getPhasesStr(unsigned int phases, ModelData * model);
|
||||||
|
|
||||||
#define POPULATE_SOURCES (1<<0)
|
#define POPULATE_SOURCES (1<<0)
|
||||||
#define POPULATE_TRIMS (1<<1)
|
#define POPULATE_TRIMS (1<<1)
|
||||||
|
@ -110,9 +110,9 @@ QString getPhasesStr(unsigned int phases, ModelData & model);
|
||||||
|
|
||||||
// void populateGVarCB(QComboBox *b, int value, int min, int max,int pgvars=5); //TODO: Clean Up
|
// void populateGVarCB(QComboBox *b, int value, int min, int max,int pgvars=5); //TODO: Clean Up
|
||||||
void populateGVCB(QComboBox *b, int value);
|
void populateGVCB(QComboBox *b, int value);
|
||||||
void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags);
|
void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData * model, unsigned int flags);
|
||||||
QString getPhaseName(int val, const char * phasename=NULL);
|
QString getPhaseName(int val, const char * phasename=NULL);
|
||||||
QString getInputStr(ModelData & model, int index);
|
QString getInputStr(ModelData * model, int index);
|
||||||
QString image2qstring(QImage image);
|
QString image2qstring(QImage image);
|
||||||
QImage qstring2image(QString imagestr);
|
QImage qstring2image(QString imagestr);
|
||||||
int findmult(float value, float base);
|
int findmult(float value, float base);
|
||||||
|
@ -157,7 +157,7 @@ class GenericPanel : public QWidget
|
||||||
friend class QUnsignedAutoComboBox;
|
friend class QUnsignedAutoComboBox;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GenericPanel(QWidget *parent);
|
GenericPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, FirmwareInterface * firmware);
|
||||||
virtual ~GenericPanel();
|
virtual ~GenericPanel();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -167,6 +167,9 @@ class GenericPanel : public QWidget
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
ModelData * model;
|
||||||
|
GeneralSettings & generalSettings;
|
||||||
|
FirmwareInterface * firmware;
|
||||||
bool lock;
|
bool lock;
|
||||||
void addLabel(QGridLayout * gridLayout, QString text, int col, bool mimimize=false);
|
void addLabel(QGridLayout * gridLayout, QString text, int col, bool mimimize=false);
|
||||||
void addEmptyLabel(QGridLayout * gridLayout, int col);
|
void addEmptyLabel(QGridLayout * gridLayout, int col);
|
||||||
|
|
|
@ -11,7 +11,6 @@ set(modeledit_NAMES
|
||||||
)
|
)
|
||||||
|
|
||||||
set(modeledit_SRCS
|
set(modeledit_SRCS
|
||||||
modelpanel.cpp
|
|
||||||
flightmodes.cpp
|
flightmodes.cpp
|
||||||
inputs.cpp
|
inputs.cpp
|
||||||
mixes.cpp
|
mixes.cpp
|
||||||
|
@ -25,7 +24,6 @@ set(modeledit_SRCS
|
||||||
)
|
)
|
||||||
|
|
||||||
set(modeledit_HDRS
|
set(modeledit_HDRS
|
||||||
modelpanel.h
|
|
||||||
flightmodes.h
|
flightmodes.h
|
||||||
inputs.h
|
inputs.h
|
||||||
mixes.h
|
mixes.h
|
||||||
|
|
|
@ -187,7 +187,7 @@ void Channels::symlimitsEdited()
|
||||||
{
|
{
|
||||||
QCheckBox * ckb = qobject_cast<QCheckBox*>(sender());
|
QCheckBox * ckb = qobject_cast<QCheckBox*>(sender());
|
||||||
int index = ckb->property("index").toInt();
|
int index = ckb->property("index").toInt();
|
||||||
model.limitData[index].symetrical = (ckb->checkState() ? 1 : 0);
|
model->limitData[index].symetrical = (ckb->checkState() ? 1 : 0);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ void Channels::nameEdited()
|
||||||
lock = true;
|
lock = true;
|
||||||
QLineEdit *le = qobject_cast<QLineEdit*>(sender());
|
QLineEdit *le = qobject_cast<QLineEdit*>(sender());
|
||||||
int index = le->property("index").toInt();
|
int index = le->property("index").toInt();
|
||||||
strcpy(model.limitData[index].name, le->text().toAscii());
|
strcpy(model->limitData[index].name, le->text().toAscii());
|
||||||
lock = false;
|
lock = false;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ void Channels::nameEdited()
|
||||||
|
|
||||||
void Channels::refreshExtendedLimits()
|
void Channels::refreshExtendedLimits()
|
||||||
{
|
{
|
||||||
int channelMax = model.getChannelsMax();
|
int channelMax = model->getChannelsMax();
|
||||||
|
|
||||||
foreach(LimitsGroup *group, limitsGroups) {
|
foreach(LimitsGroup *group, limitsGroups) {
|
||||||
group->updateMinMax(10*channelMax);
|
group->updateMinMax(10*channelMax);
|
||||||
|
@ -218,7 +218,7 @@ void Channels::invEdited()
|
||||||
{
|
{
|
||||||
QComboBox *cb = qobject_cast<QComboBox*>(sender());
|
QComboBox *cb = qobject_cast<QComboBox*>(sender());
|
||||||
int index = cb->property("index").toInt();
|
int index = cb->property("index").toInt();
|
||||||
model.limitData[index].revert = cb->currentIndex();
|
model->limitData[index].revert = cb->currentIndex();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ void Channels::curveEdited()
|
||||||
{
|
{
|
||||||
QComboBox *cb = qobject_cast<QComboBox*>(sender());
|
QComboBox *cb = qobject_cast<QComboBox*>(sender());
|
||||||
int index = cb->property("index").toInt();
|
int index = cb->property("index").toInt();
|
||||||
model.limitData[index].curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, cb->itemData(cb->currentIndex()).toInt());
|
model->limitData[index].curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, cb->itemData(cb->currentIndex()).toInt());
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ void Channels::ppmcenterEdited()
|
||||||
{
|
{
|
||||||
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());
|
QSpinBox *sb = qobject_cast<QSpinBox*>(sender());
|
||||||
int index = sb->property("index").toInt();
|
int index = sb->property("index").toInt();
|
||||||
model.limitData[index].ppmCenter = sb->value() - 1500;
|
model->limitData[index].ppmCenter = sb->value() - 1500;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef CHANNELS_H
|
#ifndef CHANNELS_H
|
||||||
#define CHANNELS_H
|
#define CHANNELS_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
|
||||||
class GVarGroup;
|
class GVarGroup;
|
||||||
|
|
|
@ -204,7 +204,7 @@ void Curves::resetCurve()
|
||||||
int index = button->property("index").toInt();
|
int index = button->property("index").toInt();
|
||||||
int res = QMessageBox::question(this, "companion", tr("Are you sure you want to reset curve %1 ?").arg(index+1), QMessageBox::Yes | QMessageBox::No);
|
int res = QMessageBox::question(this, "companion", tr("Are you sure you want to reset curve %1 ?").arg(index+1), QMessageBox::Yes | QMessageBox::No);
|
||||||
if (res == QMessageBox::Yes) {
|
if (res == QMessageBox::Yes) {
|
||||||
model.curves[index].clear(5);
|
model->curves[index].clear(5);
|
||||||
update();
|
update();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ void Curves::update()
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
if (firmware->getCapability(HasCvNames)) {
|
if (firmware->getCapability(HasCvNames)) {
|
||||||
ui->curveName->setText(model.curves[currentCurve].name);
|
ui->curveName->setText(model->curves[currentCurve].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCurveType();
|
updateCurveType();
|
||||||
|
@ -245,21 +245,21 @@ void Curves::updateCurveType()
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
if (firmware->getCapability(EnhancedCurves)) {
|
if (firmware->getCapability(EnhancedCurves)) {
|
||||||
index = model.curves[currentCurve].count - 2;
|
index = model->curves[currentCurve].count - 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->curveSmooth->hide();
|
ui->curveSmooth->hide();
|
||||||
if (model.curves[currentCurve].count == 5)
|
if (model->curves[currentCurve].count == 5)
|
||||||
index = 1;
|
index = 1;
|
||||||
else if (model.curves[currentCurve].count == 9)
|
else if (model->curves[currentCurve].count == 9)
|
||||||
index = 2;
|
index = 2;
|
||||||
else if (model.curves[currentCurve].count == 17)
|
else if (model->curves[currentCurve].count == 17)
|
||||||
index = 3;
|
index = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->curvePoints->setCurrentIndex(index);
|
ui->curvePoints->setCurrentIndex(index);
|
||||||
ui->curveCustom->setCurrentIndex(model.curves[currentCurve].type);
|
ui->curveCustom->setCurrentIndex(model->curves[currentCurve].type);
|
||||||
ui->curveSmooth->setCurrentIndex(model.curves[currentCurve].smooth);
|
ui->curveSmooth->setCurrentIndex(model->curves[currentCurve].smooth);
|
||||||
|
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
@ -295,36 +295,36 @@ void Curves::updateCurve()
|
||||||
for (int k=0; k<numcurves; k++) {
|
for (int k=0; k<numcurves; k++) {
|
||||||
pen.setColor(colors[k]);
|
pen.setColor(colors[k]);
|
||||||
if (currentCurve!=k && visibleCurves[k]) {
|
if (currentCurve!=k && visibleCurves[k]) {
|
||||||
int numpoints = model.curves[k].count;
|
int numpoints = model->curves[k].count;
|
||||||
for (int i=0; i<numpoints-1; i++) {
|
for (int i=0; i<numpoints-1; i++) {
|
||||||
if (model.curves[k].type == CurveData::CURVE_TYPE_CUSTOM)
|
if (model->curves[k].type == CurveData::CURVE_TYPE_CUSTOM)
|
||||||
scene->addLine(centerX + (qreal)model.curves[k].points[i].x*width/200,centerY - (qreal)model.curves[k].points[i].y*height/200,centerX + (qreal)model.curves[k].points[i+1].x*width/200,centerY - (qreal)model.curves[k].points[i+1].y*height/200, pen);
|
scene->addLine(centerX + (qreal)model->curves[k].points[i].x*width/200,centerY - (qreal)model->curves[k].points[i].y*height/200,centerX + (qreal)model->curves[k].points[i+1].x*width/200,centerY - (qreal)model->curves[k].points[i+1].y*height/200, pen);
|
||||||
else
|
else
|
||||||
scene->addLine(GFX_MARGIN + i*width/(numpoints-1),centerY - (qreal)model.curves[k].points[i].y*height/200,GFX_MARGIN + (i+1)*width/(numpoints-1),centerY - (qreal)model.curves[k].points[i+1].y*height/200, pen);
|
scene->addLine(GFX_MARGIN + i*width/(numpoints-1),centerY - (qreal)model->curves[k].points[i].y*height/200,GFX_MARGIN + (i+1)*width/(numpoints-1),centerY - (qreal)model->curves[k].points[i+1].y*height/200, pen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int numpoints = model.curves[currentCurve].count;
|
int numpoints = model->curves[currentCurve].count;
|
||||||
for (int i=0; i<numpoints; i++) {
|
for (int i=0; i<numpoints; i++) {
|
||||||
nodel = nodex;
|
nodel = nodex;
|
||||||
nodex = new Node();
|
nodex = new Node();
|
||||||
nodex->setProperty("index", i);
|
nodex->setProperty("index", i);
|
||||||
nodex->setColor(colors[currentCurve]);
|
nodex->setColor(colors[currentCurve]);
|
||||||
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
|
if (model->curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
|
||||||
if (i>0 && i<numpoints-1) {
|
if (i>0 && i<numpoints-1) {
|
||||||
nodex->setFixedX(false);
|
nodex->setFixedX(false);
|
||||||
nodex->setMinX(model.curves[currentCurve].points[i-1].x);
|
nodex->setMinX(model->curves[currentCurve].points[i-1].x);
|
||||||
nodex->setMaxX(model.curves[currentCurve].points[i+1].x);
|
nodex->setMaxX(model->curves[currentCurve].points[i+1].x);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nodex->setFixedX(true);
|
nodex->setFixedX(true);
|
||||||
}
|
}
|
||||||
nodex->setPos(centerX + (qreal)model.curves[currentCurve].points[i].x*width/200,centerY - (qreal)model.curves[currentCurve].points[i].y*height/200);
|
nodex->setPos(centerX + (qreal)model->curves[currentCurve].points[i].x*width/200,centerY - (qreal)model->curves[currentCurve].points[i].y*height/200);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nodex->setFixedX(true);
|
nodex->setFixedX(true);
|
||||||
nodex->setPos(GFX_MARGIN + i*width/(numpoints-1), centerY - (qreal)model.curves[currentCurve].points[i].y*height/200);
|
nodex->setPos(GFX_MARGIN + i*width/(numpoints-1), centerY - (qreal)model->curves[currentCurve].points[i].y*height/200);
|
||||||
}
|
}
|
||||||
connect(nodex, SIGNAL(moved(int, int)), this, SLOT(onNodeMoved(int, int)));
|
connect(nodex, SIGNAL(moved(int, int)), this, SLOT(onNodeMoved(int, int)));
|
||||||
connect(nodex, SIGNAL(focus()), this, SLOT(onNodeFocus()));
|
connect(nodex, SIGNAL(focus()), this, SLOT(onNodeFocus()));
|
||||||
|
@ -340,23 +340,23 @@ void Curves::updateCurvePoints()
|
||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
int count = model.curves[currentCurve].count;
|
int count = model->curves[currentCurve].count;
|
||||||
for (int i=0; i<count; i++) {
|
for (int i=0; i<count; i++) {
|
||||||
spny[i]->show();
|
spny[i]->show();
|
||||||
spny[i]->setValue(model.curves[currentCurve].points[i].y);
|
spny[i]->setValue(model->curves[currentCurve].points[i].y);
|
||||||
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
|
if (model->curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
|
||||||
spnx[i]->show();
|
spnx[i]->show();
|
||||||
if (i==0 || i==model.curves[currentCurve].count-1) {
|
if (i==0 || i==model->curves[currentCurve].count-1) {
|
||||||
spnx[i]->setDisabled(true);
|
spnx[i]->setDisabled(true);
|
||||||
spnx[i]->setMaximum(+100);
|
spnx[i]->setMaximum(+100);
|
||||||
spnx[i]->setMinimum(-100);
|
spnx[i]->setMinimum(-100);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
spnx[i]->setDisabled(false);
|
spnx[i]->setDisabled(false);
|
||||||
spnx[i]->setMaximum(model.curves[currentCurve].points[i+1].x);
|
spnx[i]->setMaximum(model->curves[currentCurve].points[i+1].x);
|
||||||
spnx[i]->setMinimum(model.curves[currentCurve].points[i-1].x);
|
spnx[i]->setMinimum(model->curves[currentCurve].points[i-1].x);
|
||||||
}
|
}
|
||||||
spnx[i]->setValue(model.curves[currentCurve].points[i].x);
|
spnx[i]->setValue(model->curves[currentCurve].points[i].x);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
spnx[i]->hide();
|
spnx[i]->hide();
|
||||||
|
@ -374,8 +374,8 @@ void Curves::onPointEdited()
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int index = sender()->property("index").toInt();
|
int index = sender()->property("index").toInt();
|
||||||
model.curves[currentCurve].points[index].x = spnx[index]->value();
|
model->curves[currentCurve].points[index].x = spnx[index]->value();
|
||||||
model.curves[currentCurve].points[index].y = spny[index]->value();
|
model->curves[currentCurve].points[index].y = spny[index]->value();
|
||||||
updateCurve();
|
updateCurve();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
@ -386,13 +386,13 @@ void Curves::onNodeMoved(int x, int y)
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
lock = true;
|
lock = true;
|
||||||
int index = sender()->property("index").toInt();
|
int index = sender()->property("index").toInt();
|
||||||
model.curves[currentCurve].points[index].x = x;
|
model->curves[currentCurve].points[index].x = x;
|
||||||
model.curves[currentCurve].points[index].y = y;
|
model->curves[currentCurve].points[index].y = y;
|
||||||
spnx[index]->setValue(x);
|
spnx[index]->setValue(x);
|
||||||
spny[index]->setValue(y);
|
spny[index]->setValue(y);
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
spnx[index-1]->setMaximum(x);
|
spnx[index-1]->setMaximum(x);
|
||||||
if (index < model.curves[currentCurve].count-1)
|
if (index < model->curves[currentCurve].count-1)
|
||||||
spnx[index+1]->setMinimum(x);
|
spnx[index+1]->setMinimum(x);
|
||||||
emit modified();
|
emit modified();
|
||||||
lock = false;
|
lock = false;
|
||||||
|
@ -418,8 +418,8 @@ bool Curves::allowCurveType(int points, CurveData::CurveType type)
|
||||||
|
|
||||||
int totalpoints = 0;
|
int totalpoints = 0;
|
||||||
for (int i=0; i<numcurves; i++) {
|
for (int i=0; i<numcurves; i++) {
|
||||||
int cvPoints = (i==currentCurve ? points : model.curves[i].count);
|
int cvPoints = (i==currentCurve ? points : model->curves[i].count);
|
||||||
CurveData::CurveType cvType = (i==currentCurve ? type : model.curves[i].type);
|
CurveData::CurveType cvType = (i==currentCurve ? type : model->curves[i].type);
|
||||||
totalpoints += cvPoints + (cvType==CurveData::CURVE_TYPE_CUSTOM ? cvPoints-2 : 0);
|
totalpoints += cvPoints + (cvType==CurveData::CURVE_TYPE_CUSTOM ? cvPoints-2 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,13 +438,13 @@ void Curves::on_curvePoints_currentIndexChanged(int index)
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int numpoints = ((QComboBox *)sender())->itemData(index).toInt();
|
int numpoints = ((QComboBox *)sender())->itemData(index).toInt();
|
||||||
|
|
||||||
if (allowCurveType(numpoints, model.curves[currentCurve].type)) {
|
if (allowCurveType(numpoints, model->curves[currentCurve].type)) {
|
||||||
model.curves[currentCurve].count = numpoints;
|
model->curves[currentCurve].count = numpoints;
|
||||||
|
|
||||||
// TODO something better + reuse!
|
// TODO something better + reuse!
|
||||||
for (int i=0; i<C9X_MAX_POINTS; i++) {
|
for (int i=0; i<C9X_MAX_POINTS; i++) {
|
||||||
model.curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
|
model->curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
|
||||||
model.curves[currentCurve].points[i].y = 0;
|
model->curves[currentCurve].points[i].y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
@ -461,13 +461,13 @@ void Curves::on_curveCustom_currentIndexChanged(int index)
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
CurveData::CurveType type = (CurveData::CurveType)index;
|
CurveData::CurveType type = (CurveData::CurveType)index;
|
||||||
int numpoints = ui->curvePoints->itemData(ui->curvePoints->currentIndex()).toInt();
|
int numpoints = ui->curvePoints->itemData(ui->curvePoints->currentIndex()).toInt();
|
||||||
if (allowCurveType(model.curves[currentCurve].count, type)) {
|
if (allowCurveType(model->curves[currentCurve].count, type)) {
|
||||||
model.curves[currentCurve].type = type;
|
model->curves[currentCurve].type = type;
|
||||||
|
|
||||||
// TODO something better + reuse!
|
// TODO something better + reuse!
|
||||||
for (int i=0; i<C9X_MAX_POINTS; i++) {
|
for (int i=0; i<C9X_MAX_POINTS; i++) {
|
||||||
model.curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
|
model->curves[currentCurve].points[i].x = (i >= numpoints-1 ? +100 : -100 + (200*i)/(numpoints-1));
|
||||||
model.curves[currentCurve].points[i].y = 0;
|
model->curves[currentCurve].points[i].y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
@ -481,14 +481,14 @@ void Curves::on_curveCustom_currentIndexChanged(int index)
|
||||||
|
|
||||||
void Curves::on_curveSmooth_currentIndexChanged(int index)
|
void Curves::on_curveSmooth_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
model.curves[currentCurve].smooth = index;
|
model->curves[currentCurve].smooth = index;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Curves::on_curveName_editingFinished()
|
void Curves::on_curveName_editingFinished()
|
||||||
{
|
{
|
||||||
memset(model.curves[currentCurve].name, 0, sizeof(model.curves[currentCurve].name));
|
memset(model->curves[currentCurve].name, 0, sizeof(model->curves[currentCurve].name));
|
||||||
strcpy(model.curves[currentCurve].name, ui->curveName->text().toAscii());
|
strcpy(model->curves[currentCurve].name, ui->curveName->text().toAscii());
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,12 +528,12 @@ void Curves::addTemplate(QString name, unsigned int flags, curveFunction functio
|
||||||
void Curves::on_curveApply_clicked()
|
void Curves::on_curveApply_clicked()
|
||||||
{
|
{
|
||||||
int index = ui->curveType->currentIndex();
|
int index = ui->curveType->currentIndex();
|
||||||
int numpoints = model.curves[currentCurve].count;
|
int numpoints = model->curves[currentCurve].count;
|
||||||
|
|
||||||
for (int i=0; i<numpoints; i++) {
|
for (int i=0; i<numpoints; i++) {
|
||||||
float x;
|
float x;
|
||||||
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM)
|
if (model->curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM)
|
||||||
x = model.curves[currentCurve].points[i].x;
|
x = model->curves[currentCurve].points[i].x;
|
||||||
else
|
else
|
||||||
x = -100.0 + (200.0/(numpoints-1))*i;
|
x = -100.0 + (200.0/(numpoints-1))*i;
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ void Curves::on_curveApply_clicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apply) {
|
if (apply) {
|
||||||
model.curves[currentCurve].points[i].y = templates[index].function(x, ui->curveCoeff->value(), ui->yMin->value(), ui->yMid->value(), ui->yMax->value());
|
model->curves[currentCurve].points[i].y = templates[index].function(x, ui->curveCoeff->value(), ui->yMin->value(), ui->yMid->value(), ui->yMax->value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,12 +571,12 @@ void ModelEdit::clearCurves(bool ask)
|
||||||
}
|
}
|
||||||
curvesLock=true;
|
curvesLock=true;
|
||||||
for (int j=0; j<16; j++) {
|
for (int j=0; j<16; j++) {
|
||||||
model.curves[j].count = 5;
|
model->curves[j].count = 5;
|
||||||
model.curves[j].custom = false;
|
model->curves[j].custom = false;
|
||||||
memset(model.curves[j].name, 0, sizeof(model.curves[j].name));
|
memset(model->curves[j].name, 0, sizeof(model->curves[j].name));
|
||||||
for (int i=0; i<17; i++) {
|
for (int i=0; i<17; i++) {
|
||||||
model.curves[j].points[i].x = 0;
|
model->curves[j].points[i].x = 0;
|
||||||
model.curves[j].points[i].y = 0;
|
model->curves[j].points[i].y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i=0; i<17; i++) {
|
for (int i=0; i<17; i++) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef CURVES_H
|
#ifndef CURVES_H
|
||||||
#define CURVES_H
|
#define CURVES_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
|
@ -47,8 +47,9 @@ void RepeatComboBox::update()
|
||||||
setCurrentIndex(value);
|
setCurrentIndex(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData * model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
||||||
ModelPanel(parent, model, generalSettings, firmware),
|
GenericPanel(parent, model, generalSettings, firmware),
|
||||||
|
functions(model ? model->customFn : generalSettings.customFn),
|
||||||
initialized(false)
|
initialized(false)
|
||||||
#if defined(PHONON)
|
#if defined(PHONON)
|
||||||
,
|
,
|
||||||
|
@ -70,8 +71,8 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
||||||
|
|
||||||
if (!firmware->getCapability(VoicesAsNumbers)) {
|
if (!firmware->getCapability(VoicesAsNumbers)) {
|
||||||
for (int i=0; i<num_fsw; i++) {
|
for (int i=0; i<num_fsw; i++) {
|
||||||
if (model.customFn[i].func==FuncPlayPrompt || model.customFn[i].func==FuncBackgroundMusic) {
|
if (functions[i].func==FuncPlayPrompt || functions[i].func==FuncBackgroundMusic) {
|
||||||
QString temp = model.customFn[i].paramarm;
|
QString temp = functions[i].paramarm;
|
||||||
if (!temp.isEmpty()) {
|
if (!temp.isEmpty()) {
|
||||||
if (!paramarmList.contains(temp)) {
|
if (!paramarmList.contains(temp)) {
|
||||||
paramarmList.append(temp);
|
paramarmList.append(temp);
|
||||||
|
@ -118,6 +119,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
||||||
fswtchSwtch[i] = new QComboBox(this);
|
fswtchSwtch[i] = new QComboBox(this);
|
||||||
fswtchSwtch[i]->setProperty("index", i);
|
fswtchSwtch[i]->setProperty("index", i);
|
||||||
fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
fswtchSwtch[i]->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
|
||||||
|
fswtchSwtch[i]->setMaxVisibleItems(10);
|
||||||
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
|
||||||
gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
|
gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
|
||||||
|
|
||||||
|
@ -181,7 +183,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
|
||||||
|
|
||||||
QHBoxLayout *repeatLayout = new QHBoxLayout();
|
QHBoxLayout *repeatLayout = new QHBoxLayout();
|
||||||
gridLayout->addLayout(repeatLayout, i+1, 4);
|
gridLayout->addLayout(repeatLayout, i+1, 4);
|
||||||
fswtchRepeat[i] = new RepeatComboBox(this, model.customFn[i].repeatParam);
|
fswtchRepeat[i] = new RepeatComboBox(this, functions[i].repeatParam);
|
||||||
repeatLayout->addWidget(fswtchRepeat[i], i+1);
|
repeatLayout->addWidget(fswtchRepeat[i], i+1);
|
||||||
connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified()));
|
connect(fswtchRepeat[i], SIGNAL(modified()), this, SLOT(onChildModified()));
|
||||||
|
|
||||||
|
@ -308,20 +310,20 @@ void CustomFunctionsPanel::onChildModified()
|
||||||
|
|
||||||
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
{
|
{
|
||||||
CustomFunctionData & cfn = model.customFn[i];
|
CustomFunctionData & cfn = functions[i];
|
||||||
|
AssignFunc func = (AssignFunc)fswtchFunc[i]->itemData(fswtchFunc[i]->currentIndex()).toInt();
|
||||||
|
|
||||||
unsigned int widgetsMask = 0;
|
unsigned int widgetsMask = 0;
|
||||||
if (modified) {
|
if (modified) {
|
||||||
cfn.swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt());
|
cfn.swtch = RawSwitch(fswtchSwtch[i]->itemData(fswtchSwtch[i]->currentIndex()).toInt());
|
||||||
cfn.func = (AssignFunc)fswtchFunc[i]->currentIndex();
|
cfn.func = func;
|
||||||
cfn.enabled = fswtchEnable[i]->isChecked();
|
cfn.enabled = fswtchEnable[i]->isChecked();
|
||||||
cfn.adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex();
|
cfn.adjustMode = (AssignFunc)fswtchGVmode[i]->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = fswtchFunc[i]->currentIndex();
|
if (func>=FuncOverrideCH1 && func<=FuncOverrideCH32) {
|
||||||
|
if (model) {
|
||||||
if (index>=FuncOverrideCH1 && index<=FuncOverrideCH32) {
|
int channelsMax = model->getChannelsMax(true);
|
||||||
int channelsMax = model.getChannelsMax(true);
|
|
||||||
fswtchParam[i]->setDecimals(0);
|
fswtchParam[i]->setDecimals(0);
|
||||||
fswtchParam[i]->setSingleStep(1);
|
fswtchParam[i]->setSingleStep(1);
|
||||||
fswtchParam[i]->setMinimum(-channelsMax);
|
fswtchParam[i]->setMinimum(-channelsMax);
|
||||||
|
@ -332,7 +334,8 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
fswtchParam[i]->setValue(cfn.param);
|
fswtchParam[i]->setValue(cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
|
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
|
||||||
}
|
}
|
||||||
else if (index==FuncLogs) {
|
}
|
||||||
|
else if (func==FuncLogs) {
|
||||||
fswtchParam[i]->setDecimals(1);
|
fswtchParam[i]->setDecimals(1);
|
||||||
fswtchParam[i]->setMinimum(0);
|
fswtchParam[i]->setMinimum(0);
|
||||||
fswtchParam[i]->setMaximum(25.5);
|
fswtchParam[i]->setMaximum(25.5);
|
||||||
|
@ -341,7 +344,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
fswtchParam[i]->setValue(cfn.param/10.0);
|
fswtchParam[i]->setValue(cfn.param/10.0);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM;
|
||||||
}
|
}
|
||||||
else if (index>=FuncAdjustGV1 && index<=FuncAdjustGVLast) {
|
else if (func>=FuncAdjustGV1 && func<=FuncAdjustGVLast) {
|
||||||
if (modified) cfn.adjustMode = fswtchGVmode[i]->currentIndex();
|
if (modified) cfn.adjustMode = fswtchGVmode[i]->currentIndex();
|
||||||
widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE;
|
widgetsMask |= CUSTOM_FUNCTION_GV_MODE + CUSTOM_FUNCTION_ENABLE;
|
||||||
if (cfn.adjustMode==0) {
|
if (cfn.adjustMode==0) {
|
||||||
|
@ -361,16 +364,16 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
|
if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
|
||||||
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param, cfn.adjustMode);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param, cfn.adjustMode);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (index==FuncReset) {
|
else if (func==FuncReset) {
|
||||||
if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
||||||
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM | CUSTOM_FUNCTION_ENABLE;
|
||||||
}
|
}
|
||||||
else if (index>=FuncSetTimer1 && index<=FuncSetTimer2) {
|
else if (func>=FuncSetTimer1 && func<=FuncSetTimer2) {
|
||||||
if (modified) cfn.param = fswtchParam[i]->value();
|
if (modified) cfn.param = fswtchParam[i]->value();
|
||||||
fswtchParam[i]->setDecimals(0);
|
fswtchParam[i]->setDecimals(0);
|
||||||
fswtchParam[i]->setSingleStep(1);
|
fswtchParam[i]->setSingleStep(1);
|
||||||
|
@ -379,34 +382,34 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
fswtchParam[i]->setValue(cfn.param);
|
fswtchParam[i]->setValue(cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
|
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_ENABLE;
|
||||||
}
|
}
|
||||||
else if (index==FuncVolume) {
|
else if (func==FuncVolume) {
|
||||||
if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
|
if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
|
||||||
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_ENABLE;
|
||||||
}
|
}
|
||||||
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
|
else if (func==FuncPlaySound || func==FuncPlayHaptic || func==FuncPlayValue || func==FuncPlayPrompt || func==FuncPlayBoth || func==FuncBackgroundMusic) {
|
||||||
if (index != FuncBackgroundMusic) {
|
if (func != FuncBackgroundMusic) {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
|
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
|
||||||
fswtchRepeat[i]->update();
|
fswtchRepeat[i]->update();
|
||||||
}
|
}
|
||||||
if (index==FuncPlayValue) {
|
if (func==FuncPlayValue) {
|
||||||
if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
|
if (modified) cfn.param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
|
||||||
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM + CUSTOM_FUNCTION_REPEAT;
|
||||||
}
|
}
|
||||||
else if (index==FuncPlayPrompt || index==FuncPlayBoth) {
|
else if (func==FuncPlayPrompt || func==FuncPlayBoth) {
|
||||||
if (firmware->getCapability(VoicesAsNumbers)) {
|
if (firmware->getCapability(VoicesAsNumbers)) {
|
||||||
fswtchParam[i]->setDecimals(0);
|
fswtchParam[i]->setDecimals(0);
|
||||||
fswtchParam[i]->setSingleStep(1);
|
fswtchParam[i]->setSingleStep(1);
|
||||||
fswtchParam[i]->setMinimum(0);
|
fswtchParam[i]->setMinimum(0);
|
||||||
if (index==FuncPlayPrompt) {
|
if (func==FuncPlayPrompt) {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT + CUSTOM_FUNCTION_GV_TOOGLE;
|
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT + CUSTOM_FUNCTION_GV_TOOGLE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT;
|
widgetsMask |= CUSTOM_FUNCTION_NUMERIC_PARAM + CUSTOM_FUNCTION_REPEAT;
|
||||||
fswtchParamGV[i]->setChecked(false);
|
fswtchParamGV[i]->setChecked(false);
|
||||||
}
|
}
|
||||||
fswtchParam[i]->setMaximum(index==FuncPlayBoth ? 254 : 255);
|
fswtchParam[i]->setMaximum(func==FuncPlayBoth ? 254 : 255);
|
||||||
if (modified) {
|
if (modified) {
|
||||||
if (fswtchParamGV[i]->isChecked()) {
|
if (fswtchParamGV[i]->isChecked()) {
|
||||||
fswtchParam[i]->setMinimum(1);
|
fswtchParam[i]->setMinimum(1);
|
||||||
|
@ -416,7 +419,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
cfn.param = fswtchParam[i]->value();
|
cfn.param = fswtchParam[i]->value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cfn.param>250 && (index!=FuncPlayBoth)) {
|
if (cfn.param>250 && (func!=FuncPlayBoth)) {
|
||||||
fswtchParamGV[i]->setChecked(true);
|
fswtchParamGV[i]->setChecked(true);
|
||||||
fswtchParam[i]->setValue(cfn.param-250);
|
fswtchParam[i]->setValue(cfn.param-250);
|
||||||
fswtchParam[i]->setMaximum(5);
|
fswtchParam[i]->setMaximum(5);
|
||||||
|
@ -448,7 +451,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (index==FuncBackgroundMusic) {
|
else if (func==FuncBackgroundMusic) {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
|
||||||
if (modified) {
|
if (modified) {
|
||||||
memset(cfn.paramarm, 0, sizeof(cfn.paramarm));
|
memset(cfn.paramarm, 0, sizeof(cfn.paramarm));
|
||||||
|
@ -461,18 +464,18 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (index==FuncPlaySound) {
|
else if (func==FuncPlaySound) {
|
||||||
if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
||||||
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
||||||
}
|
}
|
||||||
else if (index==FuncPlayHaptic) {
|
else if (func==FuncPlayHaptic) {
|
||||||
if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
if (modified) cfn.param = (uint8_t)fswtchParamT[i]->currentIndex();
|
||||||
populateFuncParamCB(fswtchParamT[i], model, index, cfn.param);
|
populateFuncParamCB(fswtchParamT[i], func, cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
widgetsMask |= CUSTOM_FUNCTION_SOURCE_PARAM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (index==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) {
|
else if (func==FuncBacklight && IS_TARANIS_PLUS(GetEepromInterface()->getBoard())) {
|
||||||
if (modified) cfn.param = (uint8_t)fswtchBLcolor[i]->value();
|
if (modified) cfn.param = (uint8_t)fswtchBLcolor[i]->value();
|
||||||
fswtchBLcolor[i]->setValue(cfn.param);
|
fswtchBLcolor[i]->setValue(cfn.param);
|
||||||
widgetsMask |= CUSTOM_FUNCTION_BL_COLOR;
|
widgetsMask |= CUSTOM_FUNCTION_BL_COLOR;
|
||||||
|
@ -482,7 +485,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
|
||||||
fswtchParam[i]->setDecimals(0);
|
fswtchParam[i]->setDecimals(0);
|
||||||
fswtchParam[i]->setSingleStep(1);
|
fswtchParam[i]->setSingleStep(1);
|
||||||
fswtchParam[i]->setValue(cfn.param);
|
fswtchParam[i]->setValue(cfn.param);
|
||||||
if (index <= FuncInstantTrim) {
|
if (func <= FuncInstantTrim) {
|
||||||
widgetsMask |= CUSTOM_FUNCTION_ENABLE;
|
widgetsMask |= CUSTOM_FUNCTION_ENABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -509,11 +512,11 @@ void CustomFunctionsPanel::update()
|
||||||
lock = true;
|
lock = true;
|
||||||
for (int i=0; i<firmware->getCapability(CustomFunctions); i++) {
|
for (int i=0; i<firmware->getCapability(CustomFunctions); i++) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
populateSwitchCB(fswtchSwtch[i], model.customFn[i].swtch, generalSettings, CustomFunctionsContext);
|
populateSwitchCB(fswtchSwtch[i], functions[i].swtch, generalSettings, CustomFunctionsContext);
|
||||||
populateFuncCB(fswtchFunc[i], model.customFn[i].func);
|
populateFuncCB(fswtchFunc[i], functions[i].func);
|
||||||
populateGVmodeCB(fswtchGVmode[i], model.customFn[i].adjustMode);
|
populateGVmodeCB(fswtchGVmode[i], functions[i].adjustMode);
|
||||||
populateFuncParamCB(fswtchParamT[i], model, model.customFn[i].func, model.customFn[i].param, model.customFn[i].adjustMode);
|
populateFuncParamCB(fswtchParamT[i], functions[i].func, functions[i].param, functions[i].adjustMode);
|
||||||
populateFuncParamArmTCB(fswtchParamArmT[i], model.customFn[i].paramarm, paramarmList);
|
populateFuncParamArmTCB(fswtchParamArmT[i], functions[i].paramarm, paramarmList);
|
||||||
}
|
}
|
||||||
refreshCustomFunction(i);
|
refreshCustomFunction(i);
|
||||||
}
|
}
|
||||||
|
@ -527,14 +530,14 @@ void CustomFunctionsPanel::fswPaste()
|
||||||
const QMimeData *mimeData = clipboard->mimeData();
|
const QMimeData *mimeData = clipboard->mimeData();
|
||||||
if (mimeData->hasFormat("application/x-companion-fsw")) {
|
if (mimeData->hasFormat("application/x-companion-fsw")) {
|
||||||
QByteArray fswData = mimeData->data("application/x-companion-fsw");
|
QByteArray fswData = mimeData->data("application/x-companion-fsw");
|
||||||
CustomFunctionData *fsw = &model.customFn[selectedFunction];
|
CustomFunctionData *fsw = &functions[selectedFunction];
|
||||||
memcpy(fsw, fswData.mid(0, sizeof(CustomFunctionData)).constData(), sizeof(CustomFunctionData));
|
memcpy(fsw, fswData.mid(0, sizeof(CustomFunctionData)).constData(), sizeof(CustomFunctionData));
|
||||||
lock = true;
|
lock = true;
|
||||||
populateSwitchCB(fswtchSwtch[selectedFunction], model.customFn[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
|
populateSwitchCB(fswtchSwtch[selectedFunction], functions[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
|
||||||
populateFuncCB(fswtchFunc[selectedFunction], model.customFn[selectedFunction].func);
|
populateFuncCB(fswtchFunc[selectedFunction], functions[selectedFunction].func);
|
||||||
populateGVmodeCB(fswtchGVmode[selectedFunction], model.customFn[selectedFunction].adjustMode);
|
populateGVmodeCB(fswtchGVmode[selectedFunction], functions[selectedFunction].adjustMode);
|
||||||
populateFuncParamCB(fswtchParamT[selectedFunction], model, model.customFn[selectedFunction].func, model.customFn[selectedFunction].param, model.customFn[selectedFunction].adjustMode);
|
populateFuncParamCB(fswtchParamT[selectedFunction], functions[selectedFunction].func, functions[selectedFunction].param, functions[selectedFunction].adjustMode);
|
||||||
populateFuncParamArmTCB(fswtchParamArmT[selectedFunction], model.customFn[selectedFunction].paramarm, paramarmList);
|
populateFuncParamArmTCB(fswtchParamArmT[selectedFunction], functions[selectedFunction].paramarm, paramarmList);
|
||||||
refreshCustomFunction(selectedFunction);
|
refreshCustomFunction(selectedFunction);
|
||||||
lock = false;
|
lock = false;
|
||||||
emit modified();
|
emit modified();
|
||||||
|
@ -543,11 +546,11 @@ void CustomFunctionsPanel::fswPaste()
|
||||||
|
|
||||||
void CustomFunctionsPanel::fswDelete()
|
void CustomFunctionsPanel::fswDelete()
|
||||||
{
|
{
|
||||||
model.customFn[selectedFunction].clear();
|
functions[selectedFunction].clear();
|
||||||
// TODO update switch and func
|
// TODO update switch and func
|
||||||
lock = true;
|
lock = true;
|
||||||
populateSwitchCB(fswtchSwtch[selectedFunction], model.customFn[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
|
populateSwitchCB(fswtchSwtch[selectedFunction], functions[selectedFunction].swtch, generalSettings, CustomFunctionsContext);
|
||||||
populateFuncCB(fswtchFunc[selectedFunction], model.customFn[selectedFunction].func);
|
populateFuncCB(fswtchFunc[selectedFunction], functions[selectedFunction].func);
|
||||||
refreshCustomFunction(selectedFunction);
|
refreshCustomFunction(selectedFunction);
|
||||||
lock = false;
|
lock = false;
|
||||||
emit modified();
|
emit modified();
|
||||||
|
@ -556,7 +559,7 @@ void CustomFunctionsPanel::fswDelete()
|
||||||
void CustomFunctionsPanel::fswCopy()
|
void CustomFunctionsPanel::fswCopy()
|
||||||
{
|
{
|
||||||
QByteArray fswData;
|
QByteArray fswData;
|
||||||
fswData.append((char*)&model.customFn[selectedFunction], sizeof(CustomFunctionData));
|
fswData.append((char*)&functions[selectedFunction], sizeof(CustomFunctionData));
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setData("application/x-companion-fsw", fswData);
|
mimeData->setData("application/x-companion-fsw", fswData);
|
||||||
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
|
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
|
||||||
|
@ -592,21 +595,26 @@ void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
|
||||||
{
|
{
|
||||||
b->clear();
|
b->clear();
|
||||||
for (unsigned int i=0; i<FuncCount; i++) {
|
for (unsigned int i=0; i<FuncCount; i++) {
|
||||||
b->addItem(CustomFunctionData(AssignFunc(i)).funcToString());
|
if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && (!model || !firmware->getCapability(SafetyChannelCustomFunction))) ||
|
||||||
if (((i>=FuncOverrideCH1 && i<=FuncOverrideCH32) && !firmware->getCapability(SafetyChannelCustomFunction)) ||
|
|
||||||
((i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) ||
|
((i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) && !firmware->getCapability(HasVolume)) ||
|
||||||
((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) ||
|
((i==FuncPlayHaptic) && !firmware->getCapability(Haptic)) ||
|
||||||
((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) ||
|
((i==FuncPlayBoth) && !firmware->getCapability(HasBeeper)) ||
|
||||||
((i==FuncLogs) && !firmware->getCapability(HasSDLogs)) ||
|
((i==FuncLogs) && !firmware->getCapability(HasSDLogs)) ||
|
||||||
((i>=FuncAdjustGV1 && i<=FuncAdjustGVLast) && !firmware->getCapability(Gvars))
|
((i>=FuncAdjustGV1 && i<=FuncAdjustGVLast) && !firmware->getCapability(Gvars))
|
||||||
) {
|
) {
|
||||||
QModelIndex index = b->model()->index(i, 0);
|
// skipped
|
||||||
QVariant v(0);
|
// b->addItem(CustomFunctionData(AssignFunc(i)).funcToString(), i);
|
||||||
b->model()->setData(index, v, Qt::UserRole - 1);
|
// QModelIndex index = b->model()->index(i, 0);
|
||||||
|
// QVariant v(0);
|
||||||
|
// b->model()->setData(index, v, Qt::UserRole - 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
b->addItem(CustomFunctionData(AssignFunc(i)).funcToString(), i);
|
||||||
|
if (i == value) {
|
||||||
|
b->setCurrentIndex(b->count()-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b->setCurrentIndex(value);
|
|
||||||
b->setMaxVisibleItems(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomFunctionsPanel::populateGVmodeCB(QComboBox *b, unsigned int value)
|
void CustomFunctionsPanel::populateGVmodeCB(QComboBox *b, unsigned int value)
|
||||||
|
@ -640,7 +648,7 @@ void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, char * value, Q
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
|
void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode)
|
||||||
{
|
{
|
||||||
QStringList qs;
|
QStringList qs;
|
||||||
b->clear();
|
b->clear();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef CUSTOMFUNCTIONS_H
|
#ifndef CUSTOMFUNCTIONS_H
|
||||||
#define CUSTOMFUNCTIONS_H
|
#define CUSTOMFUNCTIONS_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
@ -31,16 +31,19 @@ class RepeatComboBox: public QComboBox
|
||||||
int & repeatParam;
|
int & repeatParam;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CustomFunctionsPanel : public ModelPanel
|
class CustomFunctionsPanel : public GenericPanel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CustomFunctionsPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware);
|
CustomFunctionsPanel(QWidget *parent, ModelData * mode, GeneralSettings & generalSettings, FirmwareInterface * firmware);
|
||||||
~CustomFunctionsPanel();
|
~CustomFunctionsPanel();
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CustomFunctionData * functions;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void customFunctionEdited();
|
void customFunctionEdited();
|
||||||
void fsw_customContextMenuRequested(QPoint pos);
|
void fsw_customContextMenuRequested(QPoint pos);
|
||||||
|
@ -58,7 +61,7 @@ class CustomFunctionsPanel : public ModelPanel
|
||||||
private:
|
private:
|
||||||
void populateFuncCB(QComboBox *b, unsigned int value);
|
void populateFuncCB(QComboBox *b, unsigned int value);
|
||||||
void populateGVmodeCB(QComboBox *b, unsigned int value);
|
void populateGVmodeCB(QComboBox *b, unsigned int value);
|
||||||
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
|
void populateFuncParamCB(QComboBox *b, uint function, unsigned int value, unsigned int adjustmode=0);
|
||||||
void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList);
|
void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList);
|
||||||
|
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
|
|
@ -15,7 +15,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||||
QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 };
|
QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_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 };
|
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 };
|
||||||
|
|
||||||
setWindowTitle(tr("Edit %1").arg(getInputStr(model, ed->chn)));
|
setWindowTitle(tr("Edit %1").arg(getInputStr(&model, ed->chn)));
|
||||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||||
|
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||||
|
@ -60,7 +60,7 @@ ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, G
|
||||||
|
|
||||||
if (firmware->getCapability(VirtualInputs)) {
|
if (firmware->getCapability(VirtualInputs)) {
|
||||||
ui->inputName->setMaxLength(4);
|
ui->inputName->setMaxLength(4);
|
||||||
populateSourceCB(ui->sourceCB, ed->srcRaw, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
|
populateSourceCB(ui->sourceCB, ed->srcRaw, &model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
|
||||||
ui->sourceCB->removeItem(0);
|
ui->sourceCB->removeItem(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -122,7 +122,7 @@ ExpoDialog::~ExpoDialog()
|
||||||
void ExpoDialog::updateScale()
|
void ExpoDialog::updateScale()
|
||||||
{
|
{
|
||||||
if (firmware->getCapability(VirtualInputs) && ed->srcRaw.type == SOURCE_TYPE_TELEMETRY) {
|
if (firmware->getCapability(VirtualInputs) && ed->srcRaw.type == SOURCE_TYPE_TELEMETRY) {
|
||||||
RawSourceRange range = ed->srcRaw.getRange(model, generalSettings);
|
RawSourceRange range = ed->srcRaw.getRange(&model, generalSettings);
|
||||||
ui->scaleLabel->show();
|
ui->scaleLabel->show();
|
||||||
ui->scale->show();
|
ui->scale->show();
|
||||||
ui->scale->setDecimals(range.decimals);
|
ui->scale->setDecimals(range.decimals);
|
||||||
|
@ -146,7 +146,7 @@ void ExpoDialog::valuesChanged()
|
||||||
updateScale();
|
updateScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
RawSourceRange range = srcRaw.getRange(model, generalSettings);
|
RawSourceRange range = srcRaw.getRange(&model, generalSettings);
|
||||||
ed->scale = round(float(ui->scale->value()) / range.step);
|
ed->scale = round(float(ui->scale->value()) / range.step);
|
||||||
ed->carryTrim = 1 - ui->trimCB->currentIndex();
|
ed->carryTrim = 1 - ui->trimCB->currentIndex();
|
||||||
ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
|
ed->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
|
||||||
|
|
|
@ -196,24 +196,24 @@ void FlightModePanel::update()
|
||||||
|
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
int trimsMax = firmware->getCapability(ExtendedTrims);
|
int trimsMax = firmware->getCapability(ExtendedTrims);
|
||||||
if (trimsMax == 0 || !model.extendedTrims) {
|
if (trimsMax == 0 || !model->extendedTrims) {
|
||||||
trimsMax = 125;
|
trimsMax = 125;
|
||||||
}
|
}
|
||||||
trimsSlider[i]->setRange(-trimsMax, +trimsMax);
|
trimsSlider[i]->setRange(-trimsMax, +trimsMax);
|
||||||
trimsValue[i]->setRange(-trimsMax, +trimsMax);
|
trimsValue[i]->setRange(-trimsMax, +trimsMax);
|
||||||
int chn = CONVERT_MODE(i+1)-1;
|
int chn = CONVERT_MODE(i+1)-1;
|
||||||
if (chn == 2/*TODO constant*/ && model.throttleReversed)
|
if (chn == 2/*TODO constant*/ && model->throttleReversed)
|
||||||
trimsSlider[i]->setInvertedAppearance(true);
|
trimsSlider[i]->setInvertedAppearance(true);
|
||||||
trimUpdate(i);
|
trimUpdate(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ui->gvGB->isVisible()) {
|
if (ui->gvGB->isVisible()) {
|
||||||
for (int i=0; i<gvCount; i++) {
|
for (int i=0; i<gvCount; i++) {
|
||||||
gvNames[i]->setText(model.gvars_names[i]);
|
gvNames[i]->setText(model->gvars_names[i]);
|
||||||
gvValues[i]->setDisabled(model.isGVarLinked(phaseIdx, i));
|
gvValues[i]->setDisabled(model->isGVarLinked(phaseIdx, i));
|
||||||
gvValues[i]->setValue(model.getGVarValue(phaseIdx, i));
|
gvValues[i]->setValue(model->getGVarValue(phaseIdx, i));
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard()) && phaseIdx == 0) {
|
if (IS_TARANIS(GetEepromInterface()->getBoard()) && phaseIdx == 0) {
|
||||||
gvPopups[i]->setChecked(model.gvars_popups[i]);
|
gvPopups[i]->setChecked(model->gvars_popups[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ void FlightModePanel::update()
|
||||||
FlightModeData *phasere = &phase;
|
FlightModeData *phasere = &phase;
|
||||||
while (idx > 1024) {
|
while (idx > 1024) {
|
||||||
idx -= 1025;
|
idx -= 1025;
|
||||||
phasere = &model.flightModeData[idx];
|
phasere = &model->flightModeData[idx];
|
||||||
idx = phasere->rotaryEncoders[i];
|
idx = phasere->rotaryEncoders[i];
|
||||||
reValues[i]->setDisabled(true);
|
reValues[i]->setDisabled(true);
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ void FlightModePanel::trimUpdate(unsigned int trim)
|
||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
int chn = CONVERT_MODE(trim+1)-1;
|
int chn = CONVERT_MODE(trim+1)-1;
|
||||||
int value = model.getTrimValue(phaseIdx, chn);
|
int value = model->getTrimValue(phaseIdx, chn);
|
||||||
trimsSlider[trim]->setValue(value);
|
trimsSlider[trim]->setValue(value);
|
||||||
trimsValue[trim]->setValue(value);
|
trimsValue[trim]->setValue(value);
|
||||||
if (phase.trimMode[chn] < 0) {
|
if (phase.trimMode[chn] < 0) {
|
||||||
|
@ -302,8 +302,8 @@ void FlightModePanel::GVName_editingFinished()
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
QLineEdit *lineedit = qobject_cast<QLineEdit*>(sender());
|
QLineEdit *lineedit = qobject_cast<QLineEdit*>(sender());
|
||||||
int gvar = lineedit->property("index").toInt();
|
int gvar = lineedit->property("index").toInt();
|
||||||
memset(&model.gvars_names[gvar], 0, sizeof(model.gvars_names[gvar]));
|
memset(&model->gvars_names[gvar], 0, sizeof(model->gvars_names[gvar]));
|
||||||
strcpy(model.gvars_names[gvar], lineedit->text().toAscii());
|
strcpy(model->gvars_names[gvar], lineedit->text().toAscii());
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ void FlightModePanel::phaseGVPopupToggled(bool checked)
|
||||||
{
|
{
|
||||||
QCheckBox *cb = qobject_cast<QCheckBox*>(sender());
|
QCheckBox *cb = qobject_cast<QCheckBox*>(sender());
|
||||||
int gvar = cb->property("index").toInt();
|
int gvar = cb->property("index").toInt();
|
||||||
model.gvars_popups[gvar] = checked;
|
model->gvars_popups[gvar] = checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlightModePanel::phaseREValue_editingFinished()
|
void FlightModePanel::phaseREValue_editingFinished()
|
||||||
|
@ -397,7 +397,7 @@ void FlightModePanel::phaseTrim_valueChanged()
|
||||||
int trim = spinBox->property("index").toInt();
|
int trim = spinBox->property("index").toInt();
|
||||||
int chn = CONVERT_MODE(trim+1)-1;
|
int chn = CONVERT_MODE(trim+1)-1;
|
||||||
int value = spinBox->value();
|
int value = spinBox->value();
|
||||||
model.setTrimValue(phaseIdx, chn, value);
|
model->setTrimValue(phaseIdx, chn, value);
|
||||||
lock = true;
|
lock = true;
|
||||||
trimsSlider[trim]->setValue(value);
|
trimsSlider[trim]->setValue(value);
|
||||||
lock = false;
|
lock = false;
|
||||||
|
@ -412,7 +412,7 @@ void FlightModePanel::phaseTrimSlider_valueChanged()
|
||||||
int trim = slider->property("index").toInt();
|
int trim = slider->property("index").toInt();
|
||||||
int chn = CONVERT_MODE(trim+1)-1;
|
int chn = CONVERT_MODE(trim+1)-1;
|
||||||
int value = slider->value();
|
int value = slider->value();
|
||||||
model.setTrimValue(phaseIdx, chn, value);
|
model->setTrimValue(phaseIdx, chn, value);
|
||||||
lock = true;
|
lock = true;
|
||||||
trimsValue[trim]->setValue(value);
|
trimsValue[trim]->setValue(value);
|
||||||
lock = false;
|
lock = false;
|
||||||
|
@ -452,7 +452,7 @@ void FlightModesPanel::onPhaseModified()
|
||||||
QString FlightModesPanel::getTabName(int index)
|
QString FlightModesPanel::getTabName(int index)
|
||||||
{
|
{
|
||||||
QString result = tr("Flight Mode %1").arg(index);
|
QString result = tr("Flight Mode %1").arg(index);
|
||||||
const char *name = model.flightModeData[index].name;
|
const char *name = model->flightModeData[index].name;
|
||||||
if (firmware->getCapability(FlightModesName) && strlen(name) > 0) {
|
if (firmware->getCapability(FlightModesName) && strlen(name) > 0) {
|
||||||
result += tr(" (%1)").arg(name);
|
result += tr(" (%1)").arg(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef FLIGHTMODES_H
|
#ifndef FLIGHTMODES_H
|
||||||
#define FLIGHTMODES_H
|
#define FLIGHTMODES_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
|
|
|
@ -27,12 +27,12 @@ void HeliPanel::update()
|
||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
ui->swashTypeCB->setCurrentIndex(model.swashRingData.type);
|
ui->swashTypeCB->setCurrentIndex(model->swashRingData.type);
|
||||||
populateSourceCB(ui->swashCollectiveCB, model.swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS);
|
populateSourceCB(ui->swashCollectiveCB, model->swashRingData.collectiveSource, model, POPULATE_SOURCES | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||||
ui->swashRingValSB->setValue(model.swashRingData.value);
|
ui->swashRingValSB->setValue(model->swashRingData.value);
|
||||||
ui->swashInvertELE->setChecked(model.swashRingData.invertELE);
|
ui->swashInvertELE->setChecked(model->swashRingData.invertELE);
|
||||||
ui->swashInvertAIL->setChecked(model.swashRingData.invertAIL);
|
ui->swashInvertAIL->setChecked(model->swashRingData.invertAIL);
|
||||||
ui->swashInvertCOL->setChecked(model.swashRingData.invertCOL);
|
ui->swashInvertCOL->setChecked(model->swashRingData.invertCOL);
|
||||||
|
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
@ -40,12 +40,12 @@ void HeliPanel::update()
|
||||||
void HeliPanel::edited()
|
void HeliPanel::edited()
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
model.swashRingData.type = ui->swashTypeCB->currentIndex();
|
model->swashRingData.type = ui->swashTypeCB->currentIndex();
|
||||||
model.swashRingData.collectiveSource = ui->swashCollectiveCB->itemData(ui->swashCollectiveCB->currentIndex()).toInt();
|
model->swashRingData.collectiveSource = ui->swashCollectiveCB->itemData(ui->swashCollectiveCB->currentIndex()).toInt();
|
||||||
model.swashRingData.value = ui->swashRingValSB->value();
|
model->swashRingData.value = ui->swashRingValSB->value();
|
||||||
model.swashRingData.invertELE = ui->swashInvertELE->isChecked();
|
model->swashRingData.invertELE = ui->swashInvertELE->isChecked();
|
||||||
model.swashRingData.invertAIL = ui->swashInvertAIL->isChecked();
|
model->swashRingData.invertAIL = ui->swashInvertAIL->isChecked();
|
||||||
model.swashRingData.invertCOL = ui->swashInvertCOL->isChecked();
|
model->swashRingData.invertCOL = ui->swashInvertCOL->isChecked();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef HELI_H
|
#ifndef HELI_H
|
||||||
#define HELI_H
|
#define HELI_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Heli;
|
class Heli;
|
||||||
|
|
|
@ -59,7 +59,7 @@ void InputsPanel::update()
|
||||||
int curDest = -1;
|
int curDest = -1;
|
||||||
|
|
||||||
for (int i=0; i<C9X_MAX_EXPOS; i++) {
|
for (int i=0; i<C9X_MAX_EXPOS; i++) {
|
||||||
ExpoData *md = &model.expoData[i];
|
ExpoData *md = &model->expoData[i];
|
||||||
|
|
||||||
if (md->mode==0) break;
|
if (md->mode==0) break;
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ bool InputsPanel::AddInputLine(int dest)
|
||||||
QByteArray qba(1, (quint8)dest);
|
QByteArray qba(1, (quint8)dest);
|
||||||
if (dest >= 0) {
|
if (dest >= 0) {
|
||||||
//add input data
|
//add input data
|
||||||
ExpoData *md = &model.expoData[dest];
|
ExpoData *md = &model->expoData[dest];
|
||||||
qba.append((const char*)md, sizeof(ExpoData));
|
qba.append((const char*)md, sizeof(ExpoData));
|
||||||
}
|
}
|
||||||
itm->setData(Qt::UserRole, qba);
|
itm->setData(Qt::UserRole, qba);
|
||||||
|
@ -139,9 +139,9 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
|
||||||
if (new_ch) *new_ch = 1;
|
if (new_ch) *new_ch = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ExpoData *md = &model.expoData[dest];
|
ExpoData *md = &model->expoData[dest];
|
||||||
|
|
||||||
if ((dest == 0) || (model.expoData[dest-1].chn != md->chn)) {
|
if ((dest == 0) || (model->expoData[dest-1].chn != md->chn)) {
|
||||||
if (new_ch) *new_ch = 1;
|
if (new_ch) *new_ch = 1;
|
||||||
if (firmware->getCapability(VirtualInputs))
|
if (firmware->getCapability(VirtualInputs))
|
||||||
str = QString("%1").arg(getInputStr(model, md->chn), -10, ' ');
|
str = QString("%1").arg(getInputStr(model, md->chn), -10, ' ');
|
||||||
|
@ -191,14 +191,14 @@ QString InputsPanel::getInputText(int dest, bool * new_ch)
|
||||||
|
|
||||||
bool InputsPanel::gm_insertExpo(int idx)
|
bool InputsPanel::gm_insertExpo(int idx)
|
||||||
{
|
{
|
||||||
if (idx<0 || idx>=C9X_MAX_EXPOS || model.expoData[C9X_MAX_EXPOS-1].mode > 0) {
|
if (idx<0 || idx>=C9X_MAX_EXPOS || model->expoData[C9X_MAX_EXPOS-1].mode > 0) {
|
||||||
QMessageBox::information(this, "Companion", tr("Not enough available inputs!"));
|
QMessageBox::information(this, "Companion", tr("Not enough available inputs!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int chn = model.expoData[idx].chn;
|
int chn = model->expoData[idx].chn;
|
||||||
|
|
||||||
ExpoData * newExpo = model.insertInput(idx);
|
ExpoData * newExpo = model->insertInput(idx);
|
||||||
newExpo->chn = chn;
|
newExpo->chn = chn;
|
||||||
newExpo->weight = 100;
|
newExpo->weight = 100;
|
||||||
newExpo->mode = INPUT_MODE_BOTH;
|
newExpo->mode = INPUT_MODE_BOTH;
|
||||||
|
@ -208,26 +208,27 @@ bool InputsPanel::gm_insertExpo(int idx)
|
||||||
|
|
||||||
void InputsPanel::gm_deleteExpo(int index)
|
void InputsPanel::gm_deleteExpo(int index)
|
||||||
{
|
{
|
||||||
model.removeInput(index);
|
model->removeInput(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputsPanel::gm_openExpo(int index)
|
void InputsPanel::gm_openExpo(int index)
|
||||||
{
|
{
|
||||||
if(index<0 || index>=C9X_MAX_EXPOS) return;
|
if(index<0 || index>=C9X_MAX_EXPOS) return;
|
||||||
|
|
||||||
ExpoData mixd(model.expoData[index]);
|
ExpoData mixd(model->expoData[index]);
|
||||||
char inputName[4+1];
|
char inputName[4+1];
|
||||||
emit modified();
|
emit modified();
|
||||||
update();
|
update();
|
||||||
|
|
||||||
if (firmware->getCapability(VirtualInputs))
|
if (firmware->getCapability(VirtualInputs)) {
|
||||||
strcpy(inputName, model.inputNames[mixd.chn]);
|
strcpy(inputName, model->inputNames[mixd.chn]);
|
||||||
|
}
|
||||||
|
|
||||||
ExpoDialog *g = new ExpoDialog(this, model, &mixd, generalSettings, firmware, inputName);
|
ExpoDialog *g = new ExpoDialog(this, *model, &mixd, generalSettings, firmware, inputName);
|
||||||
if (g->exec()) {
|
if (g->exec()) {
|
||||||
model.expoData[index] = mixd;
|
model->expoData[index] = mixd;
|
||||||
if (firmware->getCapability(VirtualInputs))
|
if (firmware->getCapability(VirtualInputs))
|
||||||
strcpy(model.inputNames[mixd.chn], inputName);
|
strcpy(model->inputNames[mixd.chn], inputName);
|
||||||
emit modified();
|
emit modified();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
@ -244,7 +245,7 @@ void InputsPanel::gm_openExpo(int index)
|
||||||
int InputsPanel::getExpoIndex(unsigned int dch)
|
int InputsPanel::getExpoIndex(unsigned int dch)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
while (model.expoData[i].chn<=dch && model.expoData[i].mode && i<C9X_MAX_EXPOS) i++;
|
while (model->expoData[i].chn<=dch && model->expoData[i].mode && i<C9X_MAX_EXPOS) i++;
|
||||||
if(i==C9X_MAX_EXPOS) return -1;
|
if(i==C9X_MAX_EXPOS) return -1;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +303,7 @@ void InputsPanel::exposCopy()
|
||||||
|
|
||||||
QByteArray mxData;
|
QByteArray mxData;
|
||||||
foreach(int idx, list) {
|
foreach(int idx, list) {
|
||||||
mxData.append((char*)&model.expoData[idx],sizeof(ExpoData));
|
mxData.append((char*)&model->expoData[idx], sizeof(ExpoData));
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
|
@ -329,7 +330,7 @@ void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx)
|
||||||
idx = getExpoIndex(dch) - 1; //get expo index to insert
|
idx = getExpoIndex(dch) - 1; //get expo index to insert
|
||||||
} else {
|
} else {
|
||||||
idx = destIdx;
|
idx = destIdx;
|
||||||
dch = model.expoData[idx].chn;
|
dch = model->expoData[idx].chn;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray mxData = mimeData->data("application/x-companion-expo");
|
QByteArray mxData = mimeData->data("application/x-companion-expo");
|
||||||
|
@ -339,7 +340,7 @@ void InputsPanel::pasteExpoMimeData(const QMimeData * mimeData, int destIdx)
|
||||||
idx++;
|
idx++;
|
||||||
if (!gm_insertExpo(idx))
|
if (!gm_insertExpo(idx))
|
||||||
break;
|
break;
|
||||||
ExpoData *md = &model.expoData[idx];
|
ExpoData *md = &model->expoData[idx];
|
||||||
memcpy(md, mxData.mid(i, sizeof(ExpoData)).constData(), sizeof(ExpoData));
|
memcpy(md, mxData.mid(i, sizeof(ExpoData)).constData(), sizeof(ExpoData));
|
||||||
md->chn = dch;
|
md->chn = dch;
|
||||||
i += sizeof(ExpoData);
|
i += sizeof(ExpoData);
|
||||||
|
@ -378,7 +379,7 @@ void InputsPanel::expoOpen(QListWidgetItem *item)
|
||||||
idx = getExpoIndex(ch); // get expo index to insert
|
idx = getExpoIndex(ch); // get expo index to insert
|
||||||
if (!gm_insertExpo(idx))
|
if (!gm_insertExpo(idx))
|
||||||
return;
|
return;
|
||||||
model.expoData[idx].chn = ch;
|
model->expoData[idx].chn = ch;
|
||||||
expoInserted=true;
|
expoInserted=true;
|
||||||
} else {
|
} else {
|
||||||
expoInserted=false;
|
expoInserted=false;
|
||||||
|
@ -396,7 +397,7 @@ void InputsPanel::expoAdd()
|
||||||
index++;
|
index++;
|
||||||
if (!gm_insertExpo(index))
|
if (!gm_insertExpo(index))
|
||||||
return;
|
return;
|
||||||
model.expoData[index].chn = model.expoData[index-1].chn;
|
model->expoData[index].chn = model->expoData[index-1].chn;
|
||||||
}
|
}
|
||||||
gm_openExpo(index);
|
gm_openExpo(index);
|
||||||
}
|
}
|
||||||
|
@ -452,8 +453,8 @@ int InputsPanel::gm_moveExpo(int idx, bool dir) //true=inc=down false=dec=up
|
||||||
int tdx = dir ? idx+1 : idx-1;
|
int tdx = dir ? idx+1 : idx-1;
|
||||||
ExpoData temp;
|
ExpoData temp;
|
||||||
temp.clear();
|
temp.clear();
|
||||||
ExpoData &src=model.expoData[idx];
|
ExpoData &src=model->expoData[idx];
|
||||||
ExpoData &tgt=model.expoData[tdx];
|
ExpoData &tgt=model->expoData[tdx];
|
||||||
if (!dir && tdx<0 && src.chn>0) {
|
if (!dir && tdx<0 && src.chn>0) {
|
||||||
src.chn--;
|
src.chn--;
|
||||||
return idx;
|
return idx;
|
||||||
|
@ -524,7 +525,7 @@ void InputsPanel::exposDeleteList(QList<int> list)
|
||||||
void InputsPanel::clearExpos()
|
void InputsPanel::clearExpos()
|
||||||
{
|
{
|
||||||
if (QMessageBox::question(this, tr("Clear Inputs?"), tr("Really clear all the inputs?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
if (QMessageBox::question(this, tr("Clear Inputs?"), tr("Really clear all the inputs?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||||
model.clearInputs();
|
model->clearInputs();
|
||||||
emit modified();
|
emit modified();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef INPUTS_H
|
#ifndef INPUTS_H
|
||||||
#define INPUTS_H
|
#define INPUTS_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
#include "mixerslist.h"
|
#include "mixerslist.h"
|
||||||
|
|
||||||
class InputsPanel : public ModelPanel
|
class InputsPanel : public ModelPanel
|
||||||
|
|
|
@ -138,11 +138,11 @@ void LogicalSwitchesPanel::v1Edited(int value)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int i = sender()->property("index").toInt();
|
int i = sender()->property("index").toInt();
|
||||||
model.logicalSw[i].val1 = cswitchSource1[i]->itemData(value).toInt();
|
model->logicalSw[i].val1 = cswitchSource1[i]->itemData(value).toInt();
|
||||||
if (model.logicalSw[i].getFunctionFamily() == LS_FAMILY_VOFS) {
|
if (model->logicalSw[i].getFunctionFamily() == LS_FAMILY_VOFS) {
|
||||||
RawSource source = RawSource(model.logicalSw[i].val1);
|
RawSource source = RawSource(model->logicalSw[i].val1);
|
||||||
RawSourceRange range = source.getRange(model, generalSettings, model.logicalSw[i].getRangeFlags());
|
RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags());
|
||||||
model.logicalSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step;
|
model->logicalSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step;
|
||||||
setSwitchWidgetVisibility(i);
|
setSwitchWidgetVisibility(i);
|
||||||
}
|
}
|
||||||
emit modified();
|
emit modified();
|
||||||
|
@ -153,7 +153,7 @@ void LogicalSwitchesPanel::v2Edited(int value)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int i = sender()->property("index").toInt();
|
int i = sender()->property("index").toInt();
|
||||||
model.logicalSw[i].val2 = cswitchSource2[i]->itemData(value).toInt();
|
model->logicalSw[i].val2 = cswitchSource2[i]->itemData(value).toInt();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ void LogicalSwitchesPanel::andEdited(int value)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int index = sender()->property("index").toInt();
|
int index = sender()->property("index").toInt();
|
||||||
model.logicalSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
|
model->logicalSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ void LogicalSwitchesPanel::durationEdited(double duration)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int index = sender()->property("index").toInt();
|
int index = sender()->property("index").toInt();
|
||||||
model.logicalSw[index].duration = (uint8_t)round(duration*10);
|
model->logicalSw[index].duration = (uint8_t)round(duration*10);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ void LogicalSwitchesPanel::delayEdited(double delay)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int index = sender()->property("index").toInt();
|
int index = sender()->property("index").toInt();
|
||||||
model.logicalSw[index].delay = (uint8_t)round(delay*10);
|
model->logicalSw[index].delay = (uint8_t)round(delay*10);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,30 +190,30 @@ void LogicalSwitchesPanel::edited()
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
lock = true;
|
lock = true;
|
||||||
int i = sender()->property("index").toInt();
|
int i = sender()->property("index").toInt();
|
||||||
CSFunctionFamily oldFuncFamily = model.logicalSw[i].getFunctionFamily();
|
CSFunctionFamily oldFuncFamily = model->logicalSw[i].getFunctionFamily();
|
||||||
model.logicalSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt();
|
model->logicalSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt();
|
||||||
CSFunctionFamily newFuncFamily = model.logicalSw[i].getFunctionFamily();
|
CSFunctionFamily newFuncFamily = model->logicalSw[i].getFunctionFamily();
|
||||||
|
|
||||||
if (oldFuncFamily != newFuncFamily) {
|
if (oldFuncFamily != newFuncFamily) {
|
||||||
if (newFuncFamily == LS_FAMILY_TIMER) {
|
if (newFuncFamily == LS_FAMILY_TIMER) {
|
||||||
model.logicalSw[i].val1 = -119;
|
model->logicalSw[i].val1 = -119;
|
||||||
model.logicalSw[i].val2 = -119;
|
model->logicalSw[i].val2 = -119;
|
||||||
}
|
}
|
||||||
else if (newFuncFamily == LS_FAMILY_EDGE) {
|
else if (newFuncFamily == LS_FAMILY_EDGE) {
|
||||||
model.logicalSw[i].val1 = 0;
|
model->logicalSw[i].val1 = 0;
|
||||||
model.logicalSw[i].val2 = -129;
|
model->logicalSw[i].val2 = -129;
|
||||||
model.logicalSw[i].val3 = 0;
|
model->logicalSw[i].val3 = 0;
|
||||||
}
|
}
|
||||||
else if (newFuncFamily == LS_FAMILY_STICKY) {
|
else if (newFuncFamily == LS_FAMILY_STICKY) {
|
||||||
model.logicalSw[i].val1 = 0;
|
model->logicalSw[i].val1 = 0;
|
||||||
model.logicalSw[i].val2 = 0;
|
model->logicalSw[i].val2 = 0;
|
||||||
model.logicalSw[i].delay = 0;
|
model->logicalSw[i].delay = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
model.logicalSw[i].val1 = 0;
|
model->logicalSw[i].val1 = 0;
|
||||||
model.logicalSw[i].val2 = 0;
|
model->logicalSw[i].val2 = 0;
|
||||||
}
|
}
|
||||||
model.logicalSw[i].andsw = 0;
|
model->logicalSw[i].andsw = 0;
|
||||||
setSwitchWidgetVisibility(i);
|
setSwitchWidgetVisibility(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,11 +223,11 @@ void LogicalSwitchesPanel::edited()
|
||||||
{
|
{
|
||||||
case LS_FAMILY_VOFS:
|
case LS_FAMILY_VOFS:
|
||||||
{
|
{
|
||||||
source = RawSource(model.logicalSw[i].val1);
|
source = RawSource(model->logicalSw[i].val1);
|
||||||
RawSourceRange range = source.getRange(model, generalSettings, model.logicalSw[i].getRangeFlags());
|
RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags());
|
||||||
double value = source.isTimeBased() ? QTimeS(cswitchTOffset[i]->time()).seconds() : cswitchOffset[i]->value();
|
double value = source.isTimeBased() ? QTimeS(cswitchTOffset[i]->time()).seconds() : cswitchOffset[i]->value();
|
||||||
model.logicalSw[i].val2 = round((value-range.offset)/range.step);;
|
model->logicalSw[i].val2 = round((value-range.offset)/range.step);;
|
||||||
value = model.logicalSw[i].val2*range.step + range.offset;
|
value = model->logicalSw[i].val2*range.step + range.offset;
|
||||||
if (source.isTimeBased())
|
if (source.isTimeBased())
|
||||||
cswitchTOffset[i]->setTime(QTimeS(round(value)));
|
cswitchTOffset[i]->setTime(QTimeS(round(value)));
|
||||||
else
|
else
|
||||||
|
@ -235,22 +235,22 @@ void LogicalSwitchesPanel::edited()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LS_FAMILY_TIMER:
|
case LS_FAMILY_TIMER:
|
||||||
model.logicalSw[i].val1 = TimToVal(cswitchValue[i]->value());
|
model->logicalSw[i].val1 = TimToVal(cswitchValue[i]->value());
|
||||||
model.logicalSw[i].val2 = TimToVal(cswitchOffset[i]->value());
|
model->logicalSw[i].val2 = TimToVal(cswitchOffset[i]->value());
|
||||||
updateTimerParam(cswitchValue[i], model.logicalSw[i].val1, 0.1);
|
updateTimerParam(cswitchValue[i], model->logicalSw[i].val1, 0.1);
|
||||||
updateTimerParam(cswitchOffset[i], model.logicalSw[i].val2, 0.1);
|
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.1);
|
||||||
break;
|
break;
|
||||||
case LS_FAMILY_EDGE:
|
case LS_FAMILY_EDGE:
|
||||||
cswitchOffset2[i]->setSpecialValueText(tr("(no release)"));
|
cswitchOffset2[i]->setSpecialValueText(tr("(no release)"));
|
||||||
if (sender() == cswitchOffset[i]) {
|
if (sender() == cswitchOffset[i]) {
|
||||||
model.logicalSw[i].val2 = TimToVal(cswitchOffset[i]->value());
|
model->logicalSw[i].val2 = TimToVal(cswitchOffset[i]->value());
|
||||||
updateTimerParam(cswitchOffset[i], model.logicalSw[i].val2, 0.0);
|
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
model.logicalSw[i].val3 = TimToVal(cswitchOffset2[i]->value()) - model.logicalSw[i].val2;
|
model->logicalSw[i].val3 = TimToVal(cswitchOffset2[i]->value()) - model->logicalSw[i].val2;
|
||||||
}
|
}
|
||||||
updateTimerParam(cswitchOffset2[i], model.logicalSw[i].val2+model.logicalSw[i].val3, cswitchOffset[i]->value()-0.1);
|
updateTimerParam(cswitchOffset2[i], model->logicalSw[i].val2+model->logicalSw[i].val3, cswitchOffset[i]->value()-0.1);
|
||||||
if (model.logicalSw[i].val3 == 0) {
|
if (model->logicalSw[i].val3 == 0) {
|
||||||
cswitchOffset2[i]->setSuffix("(infinite)");
|
cswitchOffset2[i]->setSuffix("(infinite)");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -294,10 +294,10 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
unsigned int mask = DELAY_ENABLED;
|
unsigned int mask = DELAY_ENABLED;
|
||||||
RawSource source = RawSource(model.logicalSw[i].val1);
|
RawSource source = RawSource(model->logicalSw[i].val1);
|
||||||
RawSourceRange range = source.getRange(model, generalSettings, model.logicalSw[i].getRangeFlags());
|
RawSourceRange range = source.getRange(model, generalSettings, model->logicalSw[i].getRangeFlags());
|
||||||
|
|
||||||
switch (model.logicalSw[i].getFunctionFamily())
|
switch (model->logicalSw[i].getFunctionFamily())
|
||||||
{
|
{
|
||||||
case LS_FAMILY_VOFS:
|
case LS_FAMILY_VOFS:
|
||||||
mask |= SOURCE1_VISIBLE;
|
mask |= SOURCE1_VISIBLE;
|
||||||
|
@ -307,7 +307,7 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||||
if (source.isTimeBased()) {
|
if (source.isTimeBased()) {
|
||||||
mask |= VALUE_TO_VISIBLE;
|
mask |= VALUE_TO_VISIBLE;
|
||||||
int maxTime = round(range.max);
|
int maxTime = round(range.max);
|
||||||
int value = round(range.step*model.logicalSw[i].val2 + range.offset);
|
int value = round(range.step*model->logicalSw[i].val2 + range.offset);
|
||||||
cswitchTOffset[i]->setMaximumTime(QTimeS(maxTime));
|
cswitchTOffset[i]->setMaximumTime(QTimeS(maxTime));
|
||||||
cswitchTOffset[i]->setDisplayFormat((maxTime>=3600)?"hh:mm:ss":"mm:ss");
|
cswitchTOffset[i]->setDisplayFormat((maxTime>=3600)?"hh:mm:ss":"mm:ss");
|
||||||
cswitchTOffset[i]->setTime(QTimeS(value));
|
cswitchTOffset[i]->setTime(QTimeS(value));
|
||||||
|
@ -320,24 +320,24 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||||
cswitchOffset[i]->setSuffix(" " + range.unit);
|
cswitchOffset[i]->setSuffix(" " + range.unit);
|
||||||
cswitchOffset[i]->setMinimum(range.min);
|
cswitchOffset[i]->setMinimum(range.min);
|
||||||
cswitchOffset[i]->setMaximum(range.max);
|
cswitchOffset[i]->setMaximum(range.max);
|
||||||
cswitchOffset[i]->setValue(range.step*(model.logicalSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
|
cswitchOffset[i]->setValue(range.step*(model->logicalSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LS_FAMILY_STICKY:
|
case LS_FAMILY_STICKY:
|
||||||
// no break
|
// no break
|
||||||
case LS_FAMILY_VBOOL:
|
case LS_FAMILY_VBOOL:
|
||||||
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
|
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
|
||||||
populateSwitchCB(cswitchSource1[i], RawSwitch(model.logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
|
populateSwitchCB(cswitchSource1[i], RawSwitch(model->logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
|
||||||
populateSwitchCB(cswitchSource2[i], RawSwitch(model.logicalSw[i].val2), generalSettings, LogicalSwitchesContext);
|
populateSwitchCB(cswitchSource2[i], RawSwitch(model->logicalSw[i].val2), generalSettings, LogicalSwitchesContext);
|
||||||
break;
|
break;
|
||||||
case LS_FAMILY_EDGE:
|
case LS_FAMILY_EDGE:
|
||||||
mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE | VALUE3_VISIBLE;
|
mask |= SOURCE1_VISIBLE | VALUE2_VISIBLE | VALUE3_VISIBLE;
|
||||||
mask &= ~DELAY_ENABLED;
|
mask &= ~DELAY_ENABLED;
|
||||||
populateSwitchCB(cswitchSource1[i], RawSwitch(model.logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
|
populateSwitchCB(cswitchSource1[i], RawSwitch(model->logicalSw[i].val1), generalSettings, LogicalSwitchesContext);
|
||||||
updateTimerParam(cswitchOffset[i], model.logicalSw[i].val2, 0.0);
|
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.0);
|
||||||
updateTimerParam(cswitchOffset2[i], model.logicalSw[i].val2+model.logicalSw[i].val3, cswitchOffset[i]->value()-0.1);
|
updateTimerParam(cswitchOffset2[i], model->logicalSw[i].val2+model->logicalSw[i].val3, cswitchOffset[i]->value()-0.1);
|
||||||
cswitchOffset2[i]->setSpecialValueText(tr("(no release)"));
|
cswitchOffset2[i]->setSpecialValueText(tr("(no release)"));
|
||||||
if (model.logicalSw[i].val3 == 0) {
|
if (model->logicalSw[i].val3 == 0) {
|
||||||
cswitchOffset2[i]->setSuffix(tr("(infinite)"));
|
cswitchOffset2[i]->setSuffix(tr("(infinite)"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -346,14 +346,13 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||||
break;
|
break;
|
||||||
case LS_FAMILY_VCOMP:
|
case LS_FAMILY_VCOMP:
|
||||||
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
|
mask |= SOURCE1_VISIBLE | SOURCE2_VISIBLE;
|
||||||
populateSourceCB(cswitchSource1[i], RawSource(model.logicalSw[i].val1), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
|
populateSourceCB(cswitchSource1[i], RawSource(model->logicalSw[i].val1), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
|
||||||
populateSourceCB(cswitchSource2[i], RawSource(model.logicalSw[i].val2), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
|
populateSourceCB(cswitchSource2[i], RawSource(model->logicalSw[i].val2), model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (firmware->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
|
||||||
break;
|
break;
|
||||||
case LS_FAMILY_TIMER:
|
case LS_FAMILY_TIMER:
|
||||||
mask |= VALUE1_VISIBLE | VALUE2_VISIBLE;
|
mask |= VALUE1_VISIBLE | VALUE2_VISIBLE;
|
||||||
updateTimerParam(cswitchValue[i], model.logicalSw[i].val1, 0.1);
|
updateTimerParam(cswitchValue[i], model->logicalSw[i].val1, 0.1);
|
||||||
updateTimerParam(cswitchOffset[i], model.logicalSw[i].val2, 0.1);
|
updateTimerParam(cswitchOffset[i], model->logicalSw[i].val2, 0.1);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cswitchSource1[i]->setVisible(mask & SOURCE1_VISIBLE);
|
cswitchSource1[i]->setVisible(mask & SOURCE1_VISIBLE);
|
||||||
|
@ -364,8 +363,8 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||||
cswitchTOffset[i]->setVisible(mask & VALUE_TO_VISIBLE);
|
cswitchTOffset[i]->setVisible(mask & VALUE_TO_VISIBLE);
|
||||||
if (firmware->getCapability(LogicalSwitchesExt)) {
|
if (firmware->getCapability(LogicalSwitchesExt)) {
|
||||||
cswitchDelay[i]->setEnabled(mask & DELAY_ENABLED);
|
cswitchDelay[i]->setEnabled(mask & DELAY_ENABLED);
|
||||||
cswitchDuration[i]->setValue(model.logicalSw[i].duration/10.0);
|
cswitchDuration[i]->setValue(model->logicalSw[i].duration/10.0);
|
||||||
cswitchDelay[i]->setValue(model.logicalSw[i].delay/10.0);
|
cswitchDelay[i]->setValue(model->logicalSw[i].delay/10.0);
|
||||||
}
|
}
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
@ -445,11 +444,11 @@ void LogicalSwitchesPanel::populateAndSwitchCB(QComboBox *b, const RawSwitch & v
|
||||||
void LogicalSwitchesPanel::updateLine(int i)
|
void LogicalSwitchesPanel::updateLine(int i)
|
||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
populateCSWCB(csw[i], model.logicalSw[i].func);
|
populateCSWCB(csw[i], model->logicalSw[i].func);
|
||||||
lock = true;
|
lock = true;
|
||||||
setSwitchWidgetVisibility(i);
|
setSwitchWidgetVisibility(i);
|
||||||
lock = true;
|
lock = true;
|
||||||
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.logicalSw[i].andsw));
|
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model->logicalSw[i].andsw));
|
||||||
lock = false;
|
lock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,7 +465,7 @@ void LogicalSwitchesPanel::cswPaste()
|
||||||
const QMimeData *mimeData = clipboard->mimeData();
|
const QMimeData *mimeData = clipboard->mimeData();
|
||||||
if (mimeData->hasFormat("application/x-companion-csw")) {
|
if (mimeData->hasFormat("application/x-companion-csw")) {
|
||||||
QByteArray cswData = mimeData->data("application/x-companion-csw");
|
QByteArray cswData = mimeData->data("application/x-companion-csw");
|
||||||
LogicalSwitchData *csw = &model.logicalSw[selectedSwitch];
|
LogicalSwitchData *csw = &model->logicalSw[selectedSwitch];
|
||||||
memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData));
|
memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData));
|
||||||
emit modified();
|
emit modified();
|
||||||
updateLine(selectedSwitch);
|
updateLine(selectedSwitch);
|
||||||
|
@ -475,7 +474,7 @@ void LogicalSwitchesPanel::cswPaste()
|
||||||
|
|
||||||
void LogicalSwitchesPanel::cswDelete()
|
void LogicalSwitchesPanel::cswDelete()
|
||||||
{
|
{
|
||||||
model.logicalSw[selectedSwitch].clear();
|
model->logicalSw[selectedSwitch].clear();
|
||||||
emit modified();
|
emit modified();
|
||||||
updateLine(selectedSwitch);
|
updateLine(selectedSwitch);
|
||||||
}
|
}
|
||||||
|
@ -483,7 +482,7 @@ void LogicalSwitchesPanel::cswDelete()
|
||||||
void LogicalSwitchesPanel::cswCopy()
|
void LogicalSwitchesPanel::cswCopy()
|
||||||
{
|
{
|
||||||
QByteArray cswData;
|
QByteArray cswData;
|
||||||
cswData.append((char*)&model.logicalSw[selectedSwitch],sizeof(LogicalSwitchData));
|
cswData.append((char*)&model->logicalSw[selectedSwitch],sizeof(LogicalSwitchData));
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
mimeData->setData("application/x-companion-csw", cswData);
|
mimeData->setData("application/x-companion-csw", cswData);
|
||||||
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
|
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef CUSTOMSWITCHES_H
|
#ifndef CUSTOMSWITCHES_H
|
||||||
#define CUSTOMSWITCHES_H
|
#define CUSTOMSWITCHES_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QTimeEdit>
|
#include <QTimeEdit>
|
||||||
|
|
|
@ -19,7 +19,7 @@ MixerDialog::MixerDialog(QWidget *parent, ModelData & model, MixData *mixdata, G
|
||||||
|
|
||||||
this->setWindowTitle(tr("DEST -> CH%1").arg(md->destCh));
|
this->setWindowTitle(tr("DEST -> CH%1").arg(md->destCh));
|
||||||
|
|
||||||
populateSourceCB(ui->sourceCB, md->srcRaw, model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
populateSourceCB(ui->sourceCB, md->srcRaw, &model, POPULATE_SOURCES | POPULATE_SCRIPT_OUTPUTS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TRIMS);
|
||||||
ui->sourceCB->removeItem(0);
|
ui->sourceCB->removeItem(0);
|
||||||
|
|
||||||
int limit = firmware->getCapability(OffsetWeight);
|
int limit = firmware->getCapability(OffsetWeight);
|
||||||
|
|
|
@ -50,7 +50,7 @@ QString MixesPanel::getChannelLabel(int curDest)
|
||||||
// TODO not nice, Qt brings a function for that, I don't remember right now
|
// TODO not nice, Qt brings a function for that, I don't remember right now
|
||||||
(str.length() < 4) ? str.append(" ") : str.append(" ");
|
(str.length() < 4) ? str.append(" ") : str.append(" ");
|
||||||
if (firmware->getCapability(HasChNames)) {
|
if (firmware->getCapability(HasChNames)) {
|
||||||
QString name = model.limitData[curDest-1].name;
|
QString name = model->limitData[curDest-1].name;
|
||||||
if (!name.isEmpty()) {
|
if (!name.isEmpty()) {
|
||||||
name = QString("(") + name + QString(")");
|
name = QString("(") + name + QString(")");
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ void MixesPanel::update()
|
||||||
unsigned int outputs = firmware->getCapability(Outputs);
|
unsigned int outputs = firmware->getCapability(Outputs);
|
||||||
|
|
||||||
for (i=0; i<firmware->getCapability(Mixes); i++) {
|
for (i=0; i<firmware->getCapability(Mixes); i++) {
|
||||||
MixData *md = &model.mixData[i];
|
MixData *md = &model->mixData[i];
|
||||||
// qDebug() << "md->destCh: " << md->destCh;
|
// qDebug() << "md->destCh: " << md->destCh;
|
||||||
if (md->destCh==0 || md->destCh>outputs) continue;
|
if (md->destCh==0 || md->destCh>outputs) continue;
|
||||||
QString str = "";
|
QString str = "";
|
||||||
|
@ -111,7 +111,7 @@ bool MixesPanel::AddMixerLine(int dest)
|
||||||
QByteArray qba(1, (quint8)dest);
|
QByteArray qba(1, (quint8)dest);
|
||||||
if (dest >= 0) {
|
if (dest >= 0) {
|
||||||
//add mix data
|
//add mix data
|
||||||
MixData *md = &model.mixData[dest];
|
MixData *md = &model->mixData[dest];
|
||||||
qba.append((const char*)md, sizeof(MixData));
|
qba.append((const char*)md, sizeof(MixData));
|
||||||
}
|
}
|
||||||
itm->setData(Qt::UserRole, qba);
|
itm->setData(Qt::UserRole, qba);
|
||||||
|
@ -149,11 +149,11 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
|
||||||
if (new_ch) *new_ch = 1;
|
if (new_ch) *new_ch = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MixData *md = &model.mixData[dest];
|
MixData *md = &model->mixData[dest];
|
||||||
//md->destCh from 1 to 32
|
//md->destCh from 1 to 32
|
||||||
str = getChannelLabel(md->destCh);
|
str = getChannelLabel(md->destCh);
|
||||||
|
|
||||||
if ((dest == 0) || (model.mixData[dest-1].destCh != md->destCh)) {
|
if ((dest == 0) || (model->mixData[dest-1].destCh != md->destCh)) {
|
||||||
if (new_ch) *new_ch = 1;
|
if (new_ch) *new_ch = 1;
|
||||||
//highlight channell if needed
|
//highlight channell if needed
|
||||||
if (md->destCh == highlightedSource) {
|
if (md->destCh == highlightedSource) {
|
||||||
|
@ -187,8 +187,10 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
|
||||||
str += " " + Qt::escape(tr("Switch(%1)").arg(md->swtch.toString()));
|
str += " " + Qt::escape(tr("Switch(%1)").arg(md->swtch.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (md->carryTrim>0) str += " " + Qt::escape(tr("NoTrim"));
|
if (md->carryTrim > 0)
|
||||||
else if (md->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(model);
|
str += " " + Qt::escape(tr("NoTrim"));
|
||||||
|
else if (md->carryTrim<0)
|
||||||
|
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(model);
|
||||||
|
|
||||||
if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo"));
|
if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo"));
|
||||||
if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset)));
|
if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset)));
|
||||||
|
@ -215,39 +217,39 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
|
||||||
|
|
||||||
bool MixesPanel::gm_insertMix(int idx)
|
bool MixesPanel::gm_insertMix(int idx)
|
||||||
{
|
{
|
||||||
if (idx<0 || idx>=firmware->getCapability(Mixes) || model.mixData[firmware->getCapability(Mixes)-1].destCh > 0) {
|
if (idx<0 || idx>=firmware->getCapability(Mixes) || model->mixData[firmware->getCapability(Mixes)-1].destCh > 0) {
|
||||||
QMessageBox::information(this, "companion", tr("Not enough available mixers!"));
|
QMessageBox::information(this, "companion", tr("Not enough available mixers!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = model.mixData[idx].destCh;
|
int i = model->mixData[idx].destCh;
|
||||||
memmove(&model.mixData[idx+1],&model.mixData[idx],
|
memmove(&model->mixData[idx+1],&model->mixData[idx],
|
||||||
(firmware->getCapability(Mixes)-(idx+1))*sizeof(MixData) );
|
(firmware->getCapability(Mixes)-(idx+1))*sizeof(MixData) );
|
||||||
memset(&model.mixData[idx],0,sizeof(MixData));
|
memset(&model->mixData[idx],0,sizeof(MixData));
|
||||||
model.mixData[idx].srcRaw = RawSource(SOURCE_TYPE_NONE);
|
model->mixData[idx].srcRaw = RawSource(SOURCE_TYPE_NONE);
|
||||||
model.mixData[idx].destCh = i;
|
model->mixData[idx].destCh = i;
|
||||||
model.mixData[idx].weight = 100;
|
model->mixData[idx].weight = 100;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixesPanel::gm_deleteMix(int index)
|
void MixesPanel::gm_deleteMix(int index)
|
||||||
{
|
{
|
||||||
memmove(&model.mixData[index],&model.mixData[index+1],
|
memmove(&model->mixData[index],&model->mixData[index+1],
|
||||||
(firmware->getCapability(Mixes)-(index+1))*sizeof(MixData));
|
(firmware->getCapability(Mixes)-(index+1))*sizeof(MixData));
|
||||||
memset(&model.mixData[firmware->getCapability(Mixes)-1],0,sizeof(MixData));
|
memset(&model->mixData[firmware->getCapability(Mixes)-1],0,sizeof(MixData));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixesPanel::gm_openMix(int index)
|
void MixesPanel::gm_openMix(int index)
|
||||||
{
|
{
|
||||||
if(index<0 || index>=firmware->getCapability(Mixes)) return;
|
if(index<0 || index>=firmware->getCapability(Mixes)) return;
|
||||||
|
|
||||||
MixData mixd(model.mixData[index]);
|
MixData mixd(model->mixData[index]);
|
||||||
emit modified();
|
emit modified();
|
||||||
update();
|
update();
|
||||||
|
|
||||||
MixerDialog *g = new MixerDialog(this, model, &mixd, generalSettings, firmware);
|
MixerDialog *g = new MixerDialog(this, *model, &mixd, generalSettings, firmware);
|
||||||
if(g->exec()) {
|
if(g->exec()) {
|
||||||
model.mixData[index] = mixd;
|
model->mixData[index] = mixd;
|
||||||
emit modified();
|
emit modified();
|
||||||
update();
|
update();
|
||||||
} else {
|
} else {
|
||||||
|
@ -263,7 +265,7 @@ void MixesPanel::gm_openMix(int index)
|
||||||
int MixesPanel::getMixerIndex(unsigned int dch)
|
int MixesPanel::getMixerIndex(unsigned int dch)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ((model.mixData[i].destCh<=dch) && (model.mixData[i].destCh) && (i<firmware->getCapability(Mixes))) i++;
|
while ((model->mixData[i].destCh<=dch) && (model->mixData[i].destCh) && (i<firmware->getCapability(Mixes))) i++;
|
||||||
if(i==firmware->getCapability(Mixes)) return -1;
|
if(i==firmware->getCapability(Mixes)) return -1;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +278,7 @@ void MixesPanel::mixerlistWidget_doubleClicked(QModelIndex index)
|
||||||
idx = getMixerIndex(i); //get mixer index to insert
|
idx = getMixerIndex(i); //get mixer index to insert
|
||||||
if (!gm_insertMix(idx))
|
if (!gm_insertMix(idx))
|
||||||
return;
|
return;
|
||||||
model.mixData[idx].destCh = i;
|
model->mixData[idx].destCh = i;
|
||||||
mixInserted=true;
|
mixInserted=true;
|
||||||
} else {
|
} else {
|
||||||
mixInserted=false;
|
mixInserted=false;
|
||||||
|
@ -349,7 +351,7 @@ void MixesPanel::mixersCopy()
|
||||||
|
|
||||||
QByteArray mxData;
|
QByteArray mxData;
|
||||||
foreach(int idx, list) {
|
foreach(int idx, list) {
|
||||||
mxData.append((char*)&model.mixData[idx],sizeof(MixData));
|
mxData.append((char*)&model->mixData[idx],sizeof(MixData));
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData *mimeData = new QMimeData;
|
QMimeData *mimeData = new QMimeData;
|
||||||
|
@ -368,7 +370,7 @@ void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
|
||||||
idx = getMixerIndex(dch) - 1; //get mixer index to insert
|
idx = getMixerIndex(dch) - 1; //get mixer index to insert
|
||||||
} else {
|
} else {
|
||||||
idx = destIdx;
|
idx = destIdx;
|
||||||
dch = model.mixData[idx].destCh;
|
dch = model->mixData[idx].destCh;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray mxData = mimeData->data("application/x-companion-mix");
|
QByteArray mxData = mimeData->data("application/x-companion-mix");
|
||||||
|
@ -380,7 +382,7 @@ void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
|
||||||
|
|
||||||
if (!gm_insertMix(idx))
|
if (!gm_insertMix(idx))
|
||||||
break;
|
break;
|
||||||
MixData *md = &model.mixData[idx];
|
MixData *md = &model->mixData[idx];
|
||||||
memcpy(md,mxData.mid(i,sizeof(MixData)).constData(),sizeof(MixData));
|
memcpy(md,mxData.mid(i,sizeof(MixData)).constData(),sizeof(MixData));
|
||||||
md->destCh = dch;
|
md->destCh = dch;
|
||||||
i += sizeof(MixData);
|
i += sizeof(MixData);
|
||||||
|
@ -415,7 +417,7 @@ void MixesPanel::mixerOpen()
|
||||||
idx = getMixerIndex(i); //get mixer index to insert
|
idx = getMixerIndex(i); //get mixer index to insert
|
||||||
if (!gm_insertMix(idx))
|
if (!gm_insertMix(idx))
|
||||||
return;
|
return;
|
||||||
model.mixData[idx].destCh = i;
|
model->mixData[idx].destCh = i;
|
||||||
mixInserted=true;
|
mixInserted=true;
|
||||||
} else {
|
} else {
|
||||||
mixInserted=false;
|
mixInserted=false;
|
||||||
|
@ -432,7 +434,7 @@ void MixesPanel::mixerHighlight()
|
||||||
dest = -idx;
|
dest = -idx;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dest = model.mixData[idx].destCh;
|
dest = model->mixData[idx].destCh;
|
||||||
}
|
}
|
||||||
highlightedSource = ( (int)highlightedSource == dest) ? 0 : dest;
|
highlightedSource = ( (int)highlightedSource == dest) ? 0 : dest;
|
||||||
// qDebug() << "MixesPanel::mixerHighlight(): " << highlightedSource ;
|
// qDebug() << "MixesPanel::mixerHighlight(): " << highlightedSource ;
|
||||||
|
@ -453,13 +455,13 @@ void MixesPanel::mixerAdd()
|
||||||
index = getMixerIndex(i); //get mixer index to insert
|
index = getMixerIndex(i); //get mixer index to insert
|
||||||
if (!gm_insertMix(index))
|
if (!gm_insertMix(index))
|
||||||
return;
|
return;
|
||||||
model.mixData[index].destCh = i;
|
model->mixData[index].destCh = i;
|
||||||
mixInserted=true;
|
mixInserted=true;
|
||||||
} else {
|
} else {
|
||||||
index++;
|
index++;
|
||||||
if (!gm_insertMix(index))
|
if (!gm_insertMix(index))
|
||||||
return;
|
return;
|
||||||
model.mixData[index].destCh = model.mixData[index-1].destCh;
|
model->mixData[index].destCh = model->mixData[index-1].destCh;
|
||||||
mixInserted=true;
|
mixInserted=true;
|
||||||
}
|
}
|
||||||
gm_openMix(index);
|
gm_openMix(index);
|
||||||
|
@ -523,7 +525,7 @@ int MixesPanel::gm_moveMix(int idx, bool dir) //true=inc=down false=dec=up
|
||||||
{
|
{
|
||||||
if(idx>firmware->getCapability(Mixes) || (idx==firmware->getCapability(Mixes) && dir)) return idx;
|
if(idx>firmware->getCapability(Mixes) || (idx==firmware->getCapability(Mixes) && dir)) return idx;
|
||||||
|
|
||||||
MixData &src=model.mixData[idx];
|
MixData &src=model->mixData[idx];
|
||||||
|
|
||||||
if (idx==0 && !dir) {
|
if (idx==0 && !dir) {
|
||||||
//special case: topmost mixer moving up
|
//special case: topmost mixer moving up
|
||||||
|
@ -532,7 +534,7 @@ int MixesPanel::gm_moveMix(int idx, bool dir) //true=inc=down false=dec=up
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdx = dir ? idx+1 : idx-1;
|
int tdx = dir ? idx+1 : idx-1;
|
||||||
MixData &tgt=model.mixData[tdx];
|
MixData &tgt=model->mixData[tdx];
|
||||||
|
|
||||||
unsigned int outputs = firmware->getCapability(Outputs);
|
unsigned int outputs = firmware->getCapability(Outputs);
|
||||||
if((src.destCh==0) || (src.destCh>outputs) || (tgt.destCh>outputs)) return idx;
|
if((src.destCh==0) || (src.destCh>outputs) || (tgt.destCh>outputs)) return idx;
|
||||||
|
@ -578,7 +580,7 @@ void MixesPanel::moveMixDown()
|
||||||
void MixesPanel::clearMixes()
|
void MixesPanel::clearMixes()
|
||||||
{
|
{
|
||||||
if (QMessageBox::question(this, tr("Clear Mixes?"), tr("Really clear all the mixes?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
if (QMessageBox::question(this, tr("Clear Mixes?"), tr("Really clear all the mixes?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||||
model.clearMixes();
|
model->clearMixes();
|
||||||
emit modified();
|
emit modified();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef MIXES_H
|
#ifndef MIXES_H
|
||||||
#define MIXES_H
|
#define MIXES_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
#include "mixerslist.h"
|
#include "mixerslist.h"
|
||||||
#include "mixerdialog.h"
|
#include "mixerdialog.h"
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,7 @@ ModelEdit::ModelEdit(QWidget * parent, RadioData & radioData, int modelId, Firmw
|
||||||
addTab(chnPanel, tr("Servos"));
|
addTab(chnPanel, tr("Servos"));
|
||||||
addTab(new Curves(this, model, generalSettings, firmware), tr("Curves"));
|
addTab(new Curves(this, model, generalSettings, firmware), tr("Curves"));
|
||||||
addTab(new LogicalSwitchesPanel(this, model, generalSettings, firmware), tr("Logical Switches"));
|
addTab(new LogicalSwitchesPanel(this, model, generalSettings, firmware), tr("Logical Switches"));
|
||||||
if (firmware->getCapability(CustomFunctions))
|
addTab(new CustomFunctionsPanel(this, &model, generalSettings, firmware), tr("Special Functions"));
|
||||||
addTab(new CustomFunctionsPanel(this, model, generalSettings, firmware), tr("Special Functions"));
|
|
||||||
if (firmware->getCapability(Telemetry) & TM_HASTELEMETRY)
|
if (firmware->getCapability(Telemetry) & TM_HASTELEMETRY)
|
||||||
addTab(new TelemetryPanel(this, model, generalSettings, firmware), tr("Telemetry"));
|
addTab(new TelemetryPanel(this, model, generalSettings, firmware), tr("Telemetry"));
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ void ModelEdit::closeEvent(QCloseEvent *event)
|
||||||
g.modelEditGeo( saveGeometry() );
|
g.modelEditGeo( saveGeometry() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEdit::addTab(ModelPanel *panel, QString text)
|
void ModelEdit::addTab(GenericPanel *panel, QString text)
|
||||||
{
|
{
|
||||||
panels << panel;
|
panels << panel;
|
||||||
QWidget * widget = new QWidget(ui->tabWidget);
|
QWidget * widget = new QWidget(ui->tabWidget);
|
||||||
|
|
|
@ -2,12 +2,21 @@
|
||||||
#define MODELEDIT_H
|
#define MODELEDIT_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "modelpanel.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ModelEdit;
|
class ModelEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ModelPanel : public GenericPanel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ModelPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
||||||
|
GenericPanel(parent, &model, generalSettings, firmware)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class ModelEdit : public QDialog
|
class ModelEdit : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -33,9 +42,9 @@ class ModelEdit : public QDialog
|
||||||
ModelData & model;
|
ModelData & model;
|
||||||
GeneralSettings & generalSettings;
|
GeneralSettings & generalSettings;
|
||||||
FirmwareInterface * firmware;
|
FirmwareInterface * firmware;
|
||||||
QVector<ModelPanel *> panels;
|
QVector<GenericPanel *> panels;
|
||||||
|
|
||||||
void addTab(ModelPanel *panel, QString text);
|
void addTab(GenericPanel *panel, QString text);
|
||||||
void launchSimulation();
|
void launchSimulation();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
#include "modelpanel.h"
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QSpinBox>
|
|
||||||
|
|
||||||
ModelPanel::ModelPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware):
|
|
||||||
GenericPanel(parent),
|
|
||||||
model(model),
|
|
||||||
generalSettings(generalSettings),
|
|
||||||
firmware(firmware)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ModelPanel::~ModelPanel()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
#ifndef MODELPANEL_H
|
|
||||||
#define MODELPANEL_H
|
|
||||||
|
|
||||||
#include "eeprominterface.h"
|
|
||||||
#include "helpers.h"
|
|
||||||
|
|
||||||
class ModelPanel : public GenericPanel
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ModelPanel(QWidget *parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware);
|
|
||||||
virtual ~ModelPanel();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ModelData & model;
|
|
||||||
GeneralSettings & generalSettings;
|
|
||||||
FirmwareInterface * firmware;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CHANNELS_H
|
|
|
@ -223,7 +223,7 @@ void ModulePanel::update()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!IS_TARANIS(firmware->getBoard()) || model.trainerMode != 0) {
|
else if (!IS_TARANIS(firmware->getBoard()) || model->trainerMode != 0) {
|
||||||
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT;
|
mask |= MASK_PPM_FIELDS | MASK_CHANNELS_RANGE | MASK_CHANNELS_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ void ModulePanel::update()
|
||||||
ui->protocol->setVisible(mask & MASK_PROTOCOL);
|
ui->protocol->setVisible(mask & MASK_PROTOCOL);
|
||||||
ui->label_rxNumber->setVisible(mask & MASK_FAILSAFES);
|
ui->label_rxNumber->setVisible(mask & MASK_FAILSAFES);
|
||||||
ui->rxNumber->setVisible(mask & MASK_FAILSAFES);
|
ui->rxNumber->setVisible(mask & MASK_FAILSAFES);
|
||||||
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);
|
||||||
ui->channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
|
ui->channelsStart->setVisible(mask & MASK_CHANNELS_RANGE);
|
||||||
ui->channelsStart->setValue(module.channelsStart+1);
|
ui->channelsStart->setValue(module.channelsStart+1);
|
||||||
|
@ -250,7 +250,7 @@ void ModulePanel::update()
|
||||||
ui->ppmDelay->setValue(module.ppmDelay);
|
ui->ppmDelay->setValue(module.ppmDelay);
|
||||||
ui->label_ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS);
|
ui->label_ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS);
|
||||||
ui->ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS);
|
ui->ppmFrameLength->setVisible(mask & MASK_PPM_FIELDS);
|
||||||
ui->ppmFrameLength->setMinimum(module.channelsCount*(model.extendedLimits ? 2.250 : 2)+3.5);
|
ui->ppmFrameLength->setMinimum(module.channelsCount*(model->extendedLimits ? 2.250 : 2)+3.5);
|
||||||
ui->ppmFrameLength->setMaximum(firmware->getCapability(PPMFrameLength));
|
ui->ppmFrameLength->setMaximum(firmware->getCapability(PPMFrameLength));
|
||||||
ui->ppmFrameLength->setValue(22.5+((double)module.ppmFrameLength)*0.5);
|
ui->ppmFrameLength->setValue(22.5+((double)module.ppmFrameLength)*0.5);
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ void ModulePanel::update()
|
||||||
void ModulePanel::on_trainerMode_currentIndexChanged(int index)
|
void ModulePanel::on_trainerMode_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
model.trainerMode = index;
|
model->trainerMode = index;
|
||||||
update();
|
update();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ void ModulePanel::on_ppmDelay_editingFinished()
|
||||||
|
|
||||||
void ModulePanel::on_rxNumber_editingFinished()
|
void ModulePanel::on_rxNumber_editingFinished()
|
||||||
{
|
{
|
||||||
model.modelId = ui->rxNumber->value();
|
model->modelId = ui->rxNumber->value();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,39 +522,39 @@ SetupPanel::~SetupPanel()
|
||||||
|
|
||||||
void SetupPanel::on_extendedLimits_toggled(bool checked)
|
void SetupPanel::on_extendedLimits_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.extendedLimits = checked;
|
model->extendedLimits = checked;
|
||||||
emit extendedLimitsToggled();
|
emit extendedLimitsToggled();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::on_throttleWarning_toggled(bool checked)
|
void SetupPanel::on_throttleWarning_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.disableThrottleWarning = !checked;
|
model->disableThrottleWarning = !checked;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::on_throttleReverse_toggled(bool checked)
|
void SetupPanel::on_throttleReverse_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.throttleReversed = checked;
|
model->throttleReversed = checked;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::on_extendedTrims_toggled(bool checked)
|
void SetupPanel::on_extendedTrims_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.extendedTrims = checked;
|
model->extendedTrims = checked;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::on_trimIncrement_currentIndexChanged(int index)
|
void SetupPanel::on_trimIncrement_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
model.trimInc = index-2;
|
model->trimInc = index-2;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::on_throttleSource_currentIndexChanged(int index)
|
void SetupPanel::on_throttleSource_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
model.thrTraceSrc = ui->throttleSource->itemData(index).toInt();
|
model->thrTraceSrc = ui->throttleSource->itemData(index).toInt();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -562,25 +562,25 @@ void SetupPanel::on_throttleSource_currentIndexChanged(int index)
|
||||||
void SetupPanel::on_name_editingFinished()
|
void SetupPanel::on_name_editingFinished()
|
||||||
{
|
{
|
||||||
int length = ui->name->maxLength();
|
int length = ui->name->maxLength();
|
||||||
strncpy(model.name, ui->name->text().toAscii(), length);
|
strncpy(model->name, ui->name->text().toAscii(), length);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::on_image_currentIndexChanged(int index)
|
void SetupPanel::on_image_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
strncpy(model.bitmap, ui->image->currentText().toAscii(), 10);
|
strncpy(model->bitmap, ui->image->currentText().toAscii(), 10);
|
||||||
QString path = g.profile[g.id()].sdPath();
|
QString path = g.profile[g.id()].sdPath();
|
||||||
path.append("/BMP/");
|
path.append("/BMP/");
|
||||||
QDir qd(path);
|
QDir qd(path);
|
||||||
if (qd.exists()) {
|
if (qd.exists()) {
|
||||||
QString fileName=path;
|
QString fileName=path;
|
||||||
fileName.append(model.bitmap);
|
fileName.append(model->bitmap);
|
||||||
fileName.append(".bmp");
|
fileName.append(".bmp");
|
||||||
QImage image(fileName);
|
QImage image(fileName);
|
||||||
if (image.isNull()) {
|
if (image.isNull()) {
|
||||||
fileName=path;
|
fileName=path;
|
||||||
fileName.append(model.bitmap);
|
fileName.append(model->bitmap);
|
||||||
fileName.append(".BMP");
|
fileName.append(".BMP");
|
||||||
image.load(fileName);
|
image.load(fileName);
|
||||||
}
|
}
|
||||||
|
@ -618,13 +618,13 @@ void SetupPanel::populateThrottleSourceCB()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.thrTraceSrc < i)
|
if (model->thrTraceSrc < i)
|
||||||
ui->throttleSource->setCurrentIndex(model.thrTraceSrc);
|
ui->throttleSource->setCurrentIndex(model->thrTraceSrc);
|
||||||
|
|
||||||
int channels = (IS_ARM(GetEepromInterface()->getBoard()) ? 32 : 16);
|
int channels = (IS_ARM(GetEepromInterface()->getBoard()) ? 32 : 16);
|
||||||
for (int i=0; i<channels; i++) {
|
for (int i=0; i<channels; i++) {
|
||||||
ui->throttleSource->addItem(QObject::tr("CH%1").arg(i+1, 2, 10, QChar('0')), THROTTLE_SOURCE_FIRST_CHANNEL+i);
|
ui->throttleSource->addItem(QObject::tr("CH%1").arg(i+1, 2, 10, QChar('0')), THROTTLE_SOURCE_FIRST_CHANNEL+i);
|
||||||
if (model.thrTraceSrc == unsigned(THROTTLE_SOURCE_FIRST_CHANNEL+i))
|
if (model->thrTraceSrc == unsigned(THROTTLE_SOURCE_FIRST_CHANNEL+i))
|
||||||
ui->throttleSource->setCurrentIndex(ui->throttleSource->count()-1);
|
ui->throttleSource->setCurrentIndex(ui->throttleSource->count()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,18 +633,18 @@ void SetupPanel::populateThrottleSourceCB()
|
||||||
|
|
||||||
void SetupPanel::update()
|
void SetupPanel::update()
|
||||||
{
|
{
|
||||||
ui->name->setText(model.name);
|
ui->name->setText(model->name);
|
||||||
|
|
||||||
ui->throttleReverse->setChecked(model.throttleReversed);
|
ui->throttleReverse->setChecked(model->throttleReversed);
|
||||||
populateThrottleSourceCB();
|
populateThrottleSourceCB();
|
||||||
ui->throttleWarning->setChecked(!model.disableThrottleWarning);
|
ui->throttleWarning->setChecked(!model->disableThrottleWarning);
|
||||||
|
|
||||||
//trim inc, thro trim, thro expo, instatrim
|
//trim inc, thro trim, thro expo, instatrim
|
||||||
ui->trimIncrement->setCurrentIndex(model.trimInc+2);
|
ui->trimIncrement->setCurrentIndex(model->trimInc+2);
|
||||||
ui->throttleTrim->setChecked(model.thrTrim);
|
ui->throttleTrim->setChecked(model->thrTrim);
|
||||||
ui->extendedLimits->setChecked(model.extendedLimits);
|
ui->extendedLimits->setChecked(model->extendedLimits);
|
||||||
ui->extendedTrims->setChecked(model.extendedTrims);
|
ui->extendedTrims->setChecked(model->extendedTrims);
|
||||||
ui->displayText->setChecked(model.displayChecklist);
|
ui->displayText->setChecked(model->displayChecklist);
|
||||||
|
|
||||||
updateBeepCenter();
|
updateBeepCenter();
|
||||||
updateStartupSwitches();
|
updateStartupSwitches();
|
||||||
|
@ -664,7 +664,7 @@ void SetupPanel::update()
|
||||||
void SetupPanel::updateBeepCenter()
|
void SetupPanel::updateBeepCenter()
|
||||||
{
|
{
|
||||||
for (int i=0; i<centerBeepCheckboxes.size(); i++) {
|
for (int i=0; i<centerBeepCheckboxes.size(); i++) {
|
||||||
centerBeepCheckboxes[i]->setChecked(model.beepANACenter & (0x01 << i));
|
centerBeepCheckboxes[i]->setChecked(model->beepANACenter & (0x01 << i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,12 +672,12 @@ void SetupPanel::updateStartupSwitches()
|
||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
unsigned int switchStates = model.switchWarningStates;
|
unsigned int switchStates = model->switchWarningStates;
|
||||||
|
|
||||||
for (int i=0; i<firmware->getCapability(Switches)-1; i++) {
|
for (int i=0; i<firmware->getCapability(Switches)-1; i++) {
|
||||||
QSlider * slider = startupSwitchesSliders[i];
|
QSlider * slider = startupSwitchesSliders[i];
|
||||||
QCheckBox * cb = startupSwitchesCheckboxes[i];
|
QCheckBox * cb = startupSwitchesCheckboxes[i];
|
||||||
bool enabled = !(model.nSwToWarn & (1 << i));
|
bool enabled = !(model->nSwToWarn & (1 << i));
|
||||||
slider->setEnabled(enabled);
|
slider->setEnabled(enabled);
|
||||||
cb->setChecked(enabled);
|
cb->setChecked(enabled);
|
||||||
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
|
||||||
|
@ -721,10 +721,10 @@ void SetupPanel::startupSwitchEdited(int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model.switchWarningStates &= ~mask;
|
model->switchWarningStates &= ~mask;
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
model.switchWarningStates |= (value << shift);
|
model->switchWarningStates |= (value << shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStartupSwitches();
|
updateStartupSwitches();
|
||||||
|
@ -738,9 +738,9 @@ void SetupPanel::startupSwitchToggled(bool checked)
|
||||||
int index = sender()->property("index").toInt()-1;
|
int index = sender()->property("index").toInt()-1;
|
||||||
|
|
||||||
if (checked)
|
if (checked)
|
||||||
model.nSwToWarn &= ~(1 << index);
|
model->nSwToWarn &= ~(1 << index);
|
||||||
else
|
else
|
||||||
model.nSwToWarn |= (1 << index);
|
model->nSwToWarn |= (1 << index);
|
||||||
|
|
||||||
updateStartupSwitches();
|
updateStartupSwitches();
|
||||||
emit modified();
|
emit modified();
|
||||||
|
@ -750,14 +750,14 @@ void SetupPanel::startupSwitchToggled(bool checked)
|
||||||
void SetupPanel::updatePotWarnings()
|
void SetupPanel::updatePotWarnings()
|
||||||
{
|
{
|
||||||
lock = true;
|
lock = true;
|
||||||
int mode = model.nPotsToWarn >> 6;
|
int mode = model->nPotsToWarn >> 6;
|
||||||
ui->potWarningMode->setCurrentIndex(mode);
|
ui->potWarningMode->setCurrentIndex(mode);
|
||||||
|
|
||||||
if (mode == 0)
|
if (mode == 0)
|
||||||
model.nPotsToWarn = 0x3F;
|
model->nPotsToWarn = 0x3F;
|
||||||
|
|
||||||
for (int i=0; i<potWarningCheckboxes.size(); i++) {
|
for (int i=0; i<potWarningCheckboxes.size(); i++) {
|
||||||
bool enabled = !(model.nPotsToWarn & (1 << i));
|
bool enabled = !(model->nPotsToWarn & (1 << i));
|
||||||
|
|
||||||
potWarningCheckboxes[i]->setChecked(enabled);
|
potWarningCheckboxes[i]->setChecked(enabled);
|
||||||
potWarningCheckboxes[i]->setDisabled(mode == 0);
|
potWarningCheckboxes[i]->setDisabled(mode == 0);
|
||||||
|
@ -771,9 +771,9 @@ void SetupPanel::potWarningToggled(bool checked)
|
||||||
int index = sender()->property("index").toInt()-1;
|
int index = sender()->property("index").toInt()-1;
|
||||||
|
|
||||||
if(checked)
|
if(checked)
|
||||||
model.nPotsToWarn &= ~(1 << index);
|
model->nPotsToWarn &= ~(1 << index);
|
||||||
else
|
else
|
||||||
model.nPotsToWarn |= (1 << index);
|
model->nPotsToWarn |= (1 << index);
|
||||||
|
|
||||||
updatePotWarnings();
|
updatePotWarnings();
|
||||||
emit modified();
|
emit modified();
|
||||||
|
@ -784,8 +784,8 @@ void SetupPanel::on_potWarningMode_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
int mask = 0xC0;
|
int mask = 0xC0;
|
||||||
model.nPotsToWarn = model.nPotsToWarn & ~mask;
|
model->nPotsToWarn = model->nPotsToWarn & ~mask;
|
||||||
model.nPotsToWarn = model.nPotsToWarn | ((index << 6) & mask);
|
model->nPotsToWarn = model->nPotsToWarn | ((index << 6) & mask);
|
||||||
|
|
||||||
updatePotWarnings();
|
updatePotWarnings();
|
||||||
emit modified();
|
emit modified();
|
||||||
|
@ -794,13 +794,13 @@ void SetupPanel::on_potWarningMode_currentIndexChanged(int index)
|
||||||
|
|
||||||
void SetupPanel::on_displayText_toggled(bool checked)
|
void SetupPanel::on_displayText_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.displayChecklist = checked;
|
model->displayChecklist = checked;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupPanel::on_throttleTrim_toggled(bool checked)
|
void SetupPanel::on_throttleTrim_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.thrTrim = checked;
|
model->thrTrim = checked;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,9 +810,9 @@ void SetupPanel::onBeepCenterToggled(bool checked)
|
||||||
int index = sender()->property("index").toInt();
|
int index = sender()->property("index").toInt();
|
||||||
unsigned int mask = (0x01 << index);
|
unsigned int mask = (0x01 << index);
|
||||||
if (checked)
|
if (checked)
|
||||||
model.beepANACenter |= mask;
|
model->beepANACenter |= mask;
|
||||||
else
|
else
|
||||||
model.beepANACenter &= ~mask;
|
model->beepANACenter &= ~mask;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef SETUP_H
|
#ifndef SETUP_H
|
||||||
#define SETUP_H
|
#define SETUP_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
|
|
|
@ -367,12 +367,12 @@ void TelemetryCustomScreen::update()
|
||||||
|
|
||||||
for (int l=0; l<4; l++) {
|
for (int l=0; l<4; l++) {
|
||||||
for (int c=0; c<firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
for (int c=0; c<firmware->getCapability(TelemetryCustomScreensFieldsPerLine); c++) {
|
||||||
populateTelemetrySourceCB(fieldsCB[l][c], screen.body.lines[l].source[c], l==3, model.frsky.usrProto);
|
populateTelemetrySourceCB(fieldsCB[l][c], screen.body.lines[l].source[c], l==3, model->frsky.usrProto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int l=0; l<4; l++) {
|
for (int l=0; l<4; l++) {
|
||||||
populateTelemetrySourceCB(barsCB[l], screen.body.bars[l].source, false, model.frsky.usrProto);
|
populateTelemetrySourceCB(barsCB[l], screen.body.bars[l].source, false, model->frsky.usrProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screen.type == TELEMETRY_SCREEN_BARS) {
|
if (screen.type == TELEMETRY_SCREEN_BARS) {
|
||||||
|
@ -540,7 +540,7 @@ TelemetryPanel::~TelemetryPanel()
|
||||||
void TelemetryPanel::update()
|
void TelemetryPanel::update()
|
||||||
{
|
{
|
||||||
if (IS_TARANIS(firmware->getBoard())) {
|
if (IS_TARANIS(firmware->getBoard())) {
|
||||||
if (model.moduleData[0].protocol == OFF && model.moduleData[1].protocol == PPM) {
|
if (model->moduleData[0].protocol == OFF && model->moduleData[1].protocol == PPM) {
|
||||||
ui->telemetryProtocol->setEnabled(true);
|
ui->telemetryProtocol->setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -556,11 +556,11 @@ void TelemetryPanel::setup()
|
||||||
|
|
||||||
lock = true;
|
lock = true;
|
||||||
|
|
||||||
ui->rssiAlarm1SB->setValue(model.frsky.rssiAlarms[0].value);
|
ui->rssiAlarm1SB->setValue(model->frsky.rssiAlarms[0].value);
|
||||||
ui->rssiAlarm2SB->setValue(model.frsky.rssiAlarms[1].value);
|
ui->rssiAlarm2SB->setValue(model->frsky.rssiAlarms[1].value);
|
||||||
if (!IS_TARANIS(firmware->getBoard())) {
|
if (!IS_TARANIS(firmware->getBoard())) {
|
||||||
ui->rssiAlarm1CB->setCurrentIndex(model.frsky.rssiAlarms[0].level);
|
ui->rssiAlarm1CB->setCurrentIndex(model->frsky.rssiAlarms[0].level);
|
||||||
ui->rssiAlarm2CB->setCurrentIndex(model.frsky.rssiAlarms[1].level);
|
ui->rssiAlarm2CB->setCurrentIndex(model->frsky.rssiAlarms[1].level);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->rssiAlarm1CB->hide();
|
ui->rssiAlarm1CB->hide();
|
||||||
|
@ -573,11 +573,11 @@ void TelemetryPanel::setup()
|
||||||
ui->AltitudeGPS_ChkB->hide();
|
ui->AltitudeGPS_ChkB->hide();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->AltitudeGPS_ChkB->setChecked(model.frsky.FrSkyGpsAlt);
|
ui->AltitudeGPS_ChkB->setChecked(model->frsky.FrSkyGpsAlt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_TARANIS(firmware->getBoard())) {
|
if (IS_TARANIS(firmware->getBoard())) {
|
||||||
ui->AltitudeToolbar_ChkB->setChecked(model.frsky.altitudeDisplayed);
|
ui->AltitudeToolbar_ChkB->setChecked(model->frsky.altitudeDisplayed);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->AltitudeToolbar_ChkB->hide();
|
ui->AltitudeToolbar_ChkB->hide();
|
||||||
|
@ -606,17 +606,17 @@ void TelemetryPanel::setup()
|
||||||
ui->VarioLabel_1->hide();
|
ui->VarioLabel_1->hide();
|
||||||
ui->VarioLabel_2->hide();
|
ui->VarioLabel_2->hide();
|
||||||
}
|
}
|
||||||
ui->varioLimitMin_DSB->setValue(model.frsky.varioMin-10);
|
ui->varioLimitMin_DSB->setValue(model->frsky.varioMin-10);
|
||||||
ui->varioLimitMax_DSB->setValue(model.frsky.varioMax+10);
|
ui->varioLimitMax_DSB->setValue(model->frsky.varioMax+10);
|
||||||
ui->varioLimitCenterMax_DSB->setValue((model.frsky.varioCenterMax/10.0)+0.5);
|
ui->varioLimitCenterMax_DSB->setValue((model->frsky.varioCenterMax/10.0)+0.5);
|
||||||
if (model.frsky.varioCenterMin==-16) {
|
if (model->frsky.varioCenterMin==-16) {
|
||||||
ui->varioLimitMinOff_ChkB->setChecked(true);
|
ui->varioLimitMinOff_ChkB->setChecked(true);
|
||||||
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
||||||
ui->varioLimitCenterMin_DSB->setDisabled(true);
|
ui->varioLimitCenterMin_DSB->setDisabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->varioLimitMinOff_ChkB->setChecked(false);
|
ui->varioLimitMinOff_ChkB->setChecked(false);
|
||||||
ui->varioLimitCenterMin_DSB->setValue((model.frsky.varioCenterMin/10.0)-0.5);
|
ui->varioLimitCenterMin_DSB->setValue((model->frsky.varioCenterMin/10.0)-0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +636,7 @@ void TelemetryPanel::setup()
|
||||||
ui->fasOffset_DSB->hide();
|
ui->fasOffset_DSB->hide();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->fasOffset_DSB->setValue(model.frsky.fasOffset/10.0);
|
ui->fasOffset_DSB->setValue(model->frsky.fasOffset/10.0);
|
||||||
ui->variousGB->show();
|
ui->variousGB->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,9 +646,9 @@ void TelemetryPanel::setup()
|
||||||
ui->mahCount_ChkB->hide();
|
ui->mahCount_ChkB->hide();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (model.frsky.mAhPersistent) {
|
if (model->frsky.mAhPersistent) {
|
||||||
ui->mahCount_ChkB->setChecked(true);
|
ui->mahCount_ChkB->setChecked(true);
|
||||||
ui->mahCount_SB->setValue(model.frsky.storedMah);
|
ui->mahCount_SB->setValue(model->frsky.storedMah);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->mahCount_SB->setDisabled(true);
|
ui->mahCount_SB->setDisabled(true);
|
||||||
|
@ -656,8 +656,8 @@ void TelemetryPanel::setup()
|
||||||
ui->variousGB->show();
|
ui->variousGB->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->frskyProtoCB->setCurrentIndex(model.frsky.usrProto);
|
ui->frskyProtoCB->setCurrentIndex(model->frsky.usrProto);
|
||||||
ui->bladesCount->setValue(model.frsky.blades);
|
ui->bladesCount->setValue(model->frsky.blades);
|
||||||
|
|
||||||
populateVoltsSource();
|
populateVoltsSource();
|
||||||
populateCurrentSource();
|
populateCurrentSource();
|
||||||
|
@ -669,7 +669,7 @@ void TelemetryPanel::setup()
|
||||||
void TelemetryPanel::populateVarioSource()
|
void TelemetryPanel::populateVarioSource()
|
||||||
{
|
{
|
||||||
QUnsignedAutoComboBox * cb = ui->varioSourceCB;
|
QUnsignedAutoComboBox * cb = ui->varioSourceCB;
|
||||||
cb->setField(&model.frsky.varioSource, this);
|
cb->setField(&model->frsky.varioSource, this);
|
||||||
if (!IS_TARANIS(firmware->getBoard())) {
|
if (!IS_TARANIS(firmware->getBoard())) {
|
||||||
cb->addItem(tr("Alti"), TELEMETRY_VARIO_SOURCE_ALTI);
|
cb->addItem(tr("Alti"), TELEMETRY_VARIO_SOURCE_ALTI);
|
||||||
cb->addItem(tr("Alti+"), TELEMETRY_VARIO_SOURCE_ALTI_PLUS);
|
cb->addItem(tr("Alti+"), TELEMETRY_VARIO_SOURCE_ALTI_PLUS);
|
||||||
|
@ -685,7 +685,7 @@ void TelemetryPanel::populateVarioSource()
|
||||||
void TelemetryPanel::populateVoltsSource()
|
void TelemetryPanel::populateVoltsSource()
|
||||||
{
|
{
|
||||||
QUnsignedAutoComboBox * cb = ui->frskyVoltCB;
|
QUnsignedAutoComboBox * cb = ui->frskyVoltCB;
|
||||||
cb->setField(&model.frsky.voltsSource, this);
|
cb->setField(&model->frsky.voltsSource, this);
|
||||||
cb->addItem(tr("A1"), TELEMETRY_VOLTS_SOURCE_A1);
|
cb->addItem(tr("A1"), TELEMETRY_VOLTS_SOURCE_A1);
|
||||||
cb->addItem(tr("A2"), TELEMETRY_VOLTS_SOURCE_A2);
|
cb->addItem(tr("A2"), TELEMETRY_VOLTS_SOURCE_A2);
|
||||||
if (IS_ARM(firmware->getBoard())) {
|
if (IS_ARM(firmware->getBoard())) {
|
||||||
|
@ -699,7 +699,7 @@ void TelemetryPanel::populateVoltsSource()
|
||||||
void TelemetryPanel::populateCurrentSource()
|
void TelemetryPanel::populateCurrentSource()
|
||||||
{
|
{
|
||||||
QUnsignedAutoComboBox * cb = ui->frskyCurrentCB;
|
QUnsignedAutoComboBox * cb = ui->frskyCurrentCB;
|
||||||
cb->setField(&model.frsky.currentSource, this);
|
cb->setField(&model->frsky.currentSource, this);
|
||||||
cb->addItem(tr("---"), TELEMETRY_CURRENT_SOURCE_NONE);
|
cb->addItem(tr("---"), TELEMETRY_CURRENT_SOURCE_NONE);
|
||||||
cb->addItem(tr("A1"), TELEMETRY_CURRENT_SOURCE_A1);
|
cb->addItem(tr("A1"), TELEMETRY_CURRENT_SOURCE_A1);
|
||||||
cb->addItem(tr("A2"), TELEMETRY_CURRENT_SOURCE_A2);
|
cb->addItem(tr("A2"), TELEMETRY_CURRENT_SOURCE_A2);
|
||||||
|
@ -712,7 +712,7 @@ void TelemetryPanel::populateCurrentSource()
|
||||||
|
|
||||||
void TelemetryPanel::on_telemetryProtocol_currentIndexChanged(int index)
|
void TelemetryPanel::on_telemetryProtocol_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
model.telemetryProtocol = index;
|
model->telemetryProtocol = index;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,13 +723,13 @@ void TelemetryPanel::onAnalogModified()
|
||||||
|
|
||||||
void TelemetryPanel::on_bladesCount_editingFinished()
|
void TelemetryPanel::on_bladesCount_editingFinished()
|
||||||
{
|
{
|
||||||
model.frsky.blades = ui->bladesCount->value();
|
model->frsky.blades = ui->bladesCount->value();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
|
void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
model.frsky.usrProto = index;
|
model->frsky.usrProto = index;
|
||||||
for (int i=0; i<firmware->getCapability(TelemetryCustomScreens); i++)
|
for (int i=0; i<firmware->getCapability(TelemetryCustomScreens); i++)
|
||||||
telemetryCustomScreens[i]->update();
|
telemetryCustomScreens[i]->update();
|
||||||
emit modified();
|
emit modified();
|
||||||
|
@ -737,49 +737,49 @@ void TelemetryPanel::on_frskyProtoCB_currentIndexChanged(int index)
|
||||||
|
|
||||||
void TelemetryPanel::on_rssiAlarm1CB_currentIndexChanged(int index)
|
void TelemetryPanel::on_rssiAlarm1CB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
model.frsky.rssiAlarms[0].level = index;
|
model->frsky.rssiAlarms[0].level = index;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_rssiAlarm2CB_currentIndexChanged(int index)
|
void TelemetryPanel::on_rssiAlarm2CB_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
model.frsky.rssiAlarms[1].level = index;
|
model->frsky.rssiAlarms[1].level = index;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_rssiAlarm1SB_editingFinished()
|
void TelemetryPanel::on_rssiAlarm1SB_editingFinished()
|
||||||
{
|
{
|
||||||
model.frsky.rssiAlarms[0].value = ui->rssiAlarm1SB->value();
|
model->frsky.rssiAlarms[0].value = ui->rssiAlarm1SB->value();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_rssiAlarm2SB_editingFinished()
|
void TelemetryPanel::on_rssiAlarm2SB_editingFinished()
|
||||||
{
|
{
|
||||||
model.frsky.rssiAlarms[1].value = ui->rssiAlarm2SB->value();
|
model->frsky.rssiAlarms[1].value = ui->rssiAlarm2SB->value();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_AltitudeGPS_ChkB_toggled(bool checked)
|
void TelemetryPanel::on_AltitudeGPS_ChkB_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.frsky.FrSkyGpsAlt = checked;
|
model->frsky.FrSkyGpsAlt = checked;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_AltitudeToolbar_ChkB_toggled(bool checked)
|
void TelemetryPanel::on_AltitudeToolbar_ChkB_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.frsky.altitudeDisplayed = checked;
|
model->frsky.altitudeDisplayed = checked;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_varioLimitMin_DSB_editingFinished()
|
void TelemetryPanel::on_varioLimitMin_DSB_editingFinished()
|
||||||
{
|
{
|
||||||
model.frsky.varioMin = round(ui->varioLimitMin_DSB->value()+10);
|
model->frsky.varioMin = round(ui->varioLimitMin_DSB->value()+10);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_varioLimitMax_DSB_editingFinished()
|
void TelemetryPanel::on_varioLimitMax_DSB_editingFinished()
|
||||||
{
|
{
|
||||||
model.frsky.varioMax = round(ui->varioLimitMax_DSB->value()-10);
|
model->frsky.varioMax = round(ui->varioLimitMax_DSB->value()-10);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -789,7 +789,7 @@ void TelemetryPanel::on_varioLimitCenterMin_DSB_editingFinished()
|
||||||
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
|
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
|
||||||
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
|
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
|
||||||
}
|
}
|
||||||
model.frsky.varioCenterMin = round((ui->varioLimitCenterMin_DSB->value()+0.5)*10);
|
model->frsky.varioCenterMin = round((ui->varioLimitCenterMin_DSB->value()+0.5)*10);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -797,7 +797,7 @@ void TelemetryPanel::on_varioLimitCenterMin_DSB_editingFinished()
|
||||||
void TelemetryPanel::on_varioLimitMinOff_ChkB_toggled(bool checked)
|
void TelemetryPanel::on_varioLimitMinOff_ChkB_toggled(bool checked)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
model.frsky.varioCenterMin = -16;
|
model->frsky.varioCenterMin = -16;
|
||||||
if (!checked) {
|
if (!checked) {
|
||||||
lock=true;
|
lock=true;
|
||||||
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
ui->varioLimitCenterMin_DSB->setValue(-2.0);
|
||||||
|
@ -818,26 +818,26 @@ void TelemetryPanel::on_varioLimitCenterMax_DSB_editingFinished()
|
||||||
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
|
if (ui->varioLimitCenterMin_DSB->value()>ui->varioLimitCenterMax_DSB->value()) {
|
||||||
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
|
ui->varioLimitCenterMax_DSB->setValue(ui->varioLimitCenterMin_DSB->value());
|
||||||
}
|
}
|
||||||
model.frsky.varioCenterMax = round((ui->varioLimitCenterMax_DSB->value()-0.5)*10);
|
model->frsky.varioCenterMax = round((ui->varioLimitCenterMax_DSB->value()-0.5)*10);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_fasOffset_DSB_editingFinished()
|
void TelemetryPanel::on_fasOffset_DSB_editingFinished()
|
||||||
{
|
{
|
||||||
model.frsky.fasOffset = ui->fasOffset_DSB->value() * 10;
|
model->frsky.fasOffset = ui->fasOffset_DSB->value() * 10;
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_mahCount_SB_editingFinished()
|
void TelemetryPanel::on_mahCount_SB_editingFinished()
|
||||||
{
|
{
|
||||||
model.frsky.storedMah = ui->mahCount_SB->value();
|
model->frsky.storedMah = ui->mahCount_SB->value();
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryPanel::on_mahCount_ChkB_toggled(bool checked)
|
void TelemetryPanel::on_mahCount_ChkB_toggled(bool checked)
|
||||||
{
|
{
|
||||||
model.frsky.mAhPersistent = checked;
|
model->frsky.mAhPersistent = checked;
|
||||||
ui->mahCount_SB->setDisabled(!checked);
|
ui->mahCount_SB->setDisabled(!checked);
|
||||||
emit modified();
|
emit modified();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef TELEMETRY_H
|
#ifndef TELEMETRY_H
|
||||||
#define TELEMETRY_H
|
#define TELEMETRY_H
|
||||||
|
|
||||||
#include "modelpanel.h"
|
#include "modeledit.h"
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
|
|
|
@ -211,7 +211,7 @@ void PrintDialog::printInputs()
|
||||||
str.append("<tr><td><font size=+1 face='Courier New'>");
|
str.append("<tr><td><font size=+1 face='Courier New'>");
|
||||||
if(lastCHN!=ed->chn) {
|
if(lastCHN!=ed->chn) {
|
||||||
lastCHN=ed->chn;
|
lastCHN=ed->chn;
|
||||||
str.append("<b>"+getInputStr(*g_model, ed->chn)+"</b>");
|
str.append("<b>"+getInputStr(g_model, ed->chn)+"</b>");
|
||||||
}
|
}
|
||||||
str.append("</font></td>");
|
str.append("</font></td>");
|
||||||
str.append("<td><font size=+1 face='Courier New' color=green>");
|
str.append("<td><font size=+1 face='Courier New' color=green>");
|
||||||
|
@ -231,9 +231,9 @@ void PrintDialog::printInputs()
|
||||||
str += " " + tr("Weight") + QString("(%1)").arg(getGVarString(ed->weight,true));
|
str += " " + tr("Weight") + QString("(%1)").arg(getGVarString(ed->weight,true));
|
||||||
|
|
||||||
if (firmware->getCapability(VirtualInputs)) {
|
if (firmware->getCapability(VirtualInputs)) {
|
||||||
str += " " + tr("Source") + QString("(%1)").arg(ed->srcRaw.toString(*g_model));
|
str += " " + tr("Source") + QString("(%1)").arg(ed->srcRaw.toString(g_model));
|
||||||
if (ed->carryTrim>0) str += " " + tr("NoTrim");
|
if (ed->carryTrim>0) str += " " + tr("NoTrim");
|
||||||
else if (ed->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(ed->carryTrim)-1)).toString(*g_model);
|
else if (ed->carryTrim<0) str += " " + RawSource(SOURCE_TYPE_TRIM, (-(ed->carryTrim)-1)).toString(g_model);
|
||||||
}
|
}
|
||||||
if (ed->curve.value) str += " " + Qt::escape(ed->curve.toString());
|
if (ed->curve.value) str += " " + Qt::escape(ed->curve.toString());
|
||||||
|
|
||||||
|
@ -315,10 +315,10 @@ void PrintDialog::printMixes()
|
||||||
default: str += " "; break;
|
default: str += " "; break;
|
||||||
};
|
};
|
||||||
|
|
||||||
str += " " + md->srcRaw.toString(*g_model);
|
str += " " + md->srcRaw.toString(g_model);
|
||||||
str += " " + Qt::escape(tr("Weight(%1)").arg(getGVarString(md->weight, true)));
|
str += " " + Qt::escape(tr("Weight(%1)").arg(getGVarString(md->weight, true)));
|
||||||
|
|
||||||
QString phasesStr = getPhasesStr(md->phases, *g_model);
|
QString phasesStr = getPhasesStr(md->phases, g_model);
|
||||||
if (!phasesStr.isEmpty()) str += " " + Qt::escape(phasesStr);
|
if (!phasesStr.isEmpty()) str += " " + Qt::escape(phasesStr);
|
||||||
|
|
||||||
if (md->swtch.type != SWITCH_TYPE_NONE) {
|
if (md->swtch.type != SWITCH_TYPE_NONE) {
|
||||||
|
@ -328,7 +328,7 @@ void PrintDialog::printMixes()
|
||||||
if (md->carryTrim>0)
|
if (md->carryTrim>0)
|
||||||
str += " " + Qt::escape(tr("NoTrim"));
|
str += " " + Qt::escape(tr("NoTrim"));
|
||||||
else if (md->carryTrim<0)
|
else if (md->carryTrim<0)
|
||||||
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(*g_model);
|
str += " " + RawSource(SOURCE_TYPE_TRIM, (-(md->carryTrim)-1)).toString(g_model);
|
||||||
|
|
||||||
if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo"));
|
if (firmware->getCapability(HasNoExpo) && md->noExpo) str += " " + Qt::escape(tr("No DR/Expo"));
|
||||||
if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset)));
|
if (md->sOffset) str += " " + Qt::escape(tr("Offset(%1)").arg(getGVarString(md->sOffset)));
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define QAUTOCOMBOBOX_H_
|
#define QAUTOCOMBOBOX_H_
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include "modeledit/modelpanel.h"
|
#include "modeledit/modeledit.h"
|
||||||
|
|
||||||
class QUnsignedAutoComboBox: public QComboBox
|
class QUnsignedAutoComboBox: public QComboBox
|
||||||
{
|
{
|
||||||
|
|
|
@ -373,7 +373,7 @@ void SimulatorDialog::initUi(T * ui)
|
||||||
}
|
}
|
||||||
QLabel * label = new QLabel(tabWidget);
|
QLabel * label = new QLabel(tabWidget);
|
||||||
ModelData model;
|
ModelData model;
|
||||||
label->setText(RawSource(SOURCE_TYPE_CH, i).toString(model));
|
label->setText(RawSource(SOURCE_TYPE_CH, i).toString(&model));
|
||||||
outputTab->addWidget(label, line, column == 0 ? 0 : 5, 1, 1);
|
outputTab->addWidget(label, line, column == 0 ? 0 : 5, 1, 1);
|
||||||
|
|
||||||
QSlider * slider = new QSlider(tabWidget);
|
QSlider * slider = new QSlider(tabWidget);
|
||||||
|
|
|
@ -5071,8 +5071,10 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu
|
||||||
{
|
{
|
||||||
int8_t sub = m_posVert - 1;
|
int8_t sub = m_posVert - 1;
|
||||||
|
|
||||||
#if defined(CPUARM) || defined(AUTOSWITCH)
|
#if defined(CPUARM)
|
||||||
uint8_t eeFlags = (functions == g_model.customFn) ? EE_MODEL : EE_GENERAL;
|
uint8_t eeFlags = (functions == g_model.customFn) ? EE_MODEL : EE_GENERAL;
|
||||||
|
#elif !defined(CPUM64) || defined(AUTOSWITCH)
|
||||||
|
uint8_t eeFlags = EE_MODEL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
|
|
|
@ -520,7 +520,7 @@ enum AdjustGvarFunctionParam {
|
||||||
#define LEN_CFN_NAME 6
|
#define LEN_CFN_NAME 6
|
||||||
#define CFN_SPARE_TYPE int16_t
|
#define CFN_SPARE_TYPE int16_t
|
||||||
#endif
|
#endif
|
||||||
PACK(typedef struct t_CustomFunctionData { // Function Switches data
|
PACK(typedef struct {
|
||||||
int8_t swtch;
|
int8_t swtch;
|
||||||
uint8_t func;
|
uint8_t func;
|
||||||
PACK(union {
|
PACK(union {
|
||||||
|
@ -557,7 +557,7 @@ PACK(typedef struct t_CustomFunctionData { // Function Switches data
|
||||||
#define CFN_RESET(p) ((p)->active=0, (p)->clear.val1=0, (p)->clear.val2=0)
|
#define CFN_RESET(p) ((p)->active=0, (p)->clear.val1=0, (p)->clear.val2=0)
|
||||||
#define CFN_GVAR_CST_MAX GVAR_LIMIT
|
#define CFN_GVAR_CST_MAX GVAR_LIMIT
|
||||||
#else
|
#else
|
||||||
PACK(typedef struct t_CustomFunctionData {
|
PACK(typedef struct {
|
||||||
PACK(union {
|
PACK(union {
|
||||||
PACK(struct {
|
PACK(struct {
|
||||||
int16_t swtch:6;
|
int16_t swtch:6;
|
||||||
|
@ -650,7 +650,7 @@ PACK(typedef struct t_EEGeneral {
|
||||||
|
|
||||||
EXTRA_GENERAL_FIELDS
|
EXTRA_GENERAL_FIELDS
|
||||||
|
|
||||||
swstate_t switchUnlockStates;
|
ARM_FIELD(swstate_t switchUnlockStates)
|
||||||
|
|
||||||
ARM_FIELD(CustomFunctionData customFn[NUM_CFN])
|
ARM_FIELD(CustomFunctionData customFn[NUM_CFN])
|
||||||
|
|
||||||
|
|
|
@ -389,12 +389,15 @@ TEST(Trims, CopyTrimsToOffset)
|
||||||
MODEL_RESET();
|
MODEL_RESET();
|
||||||
modelDefault(0);
|
modelDefault(0);
|
||||||
setTrimValue(0, ELE_STICK, -100); // -100 on elevator
|
setTrimValue(0, ELE_STICK, -100); // -100 on elevator
|
||||||
|
#if defined(CPUARM)
|
||||||
|
evalFunctions(g_model.customFn, modelFunctionsContext); // it disables all safety channels
|
||||||
|
copyTrimsToOffset(1);
|
||||||
|
EXPECT_EQ(getTrimValue(0, ELE_STICK), -100); // unchanged
|
||||||
|
EXPECT_EQ(g_model.limitData[1].offset, -195);
|
||||||
|
#else
|
||||||
evalFunctions(); // it disables all safety channels
|
evalFunctions(); // it disables all safety channels
|
||||||
copyTrimsToOffset(1);
|
copyTrimsToOffset(1);
|
||||||
EXPECT_EQ(getTrimValue(0, ELE_STICK), -100); // unchanged
|
EXPECT_EQ(getTrimValue(0, ELE_STICK), -100); // unchanged
|
||||||
#if defined(CPUARM)
|
|
||||||
EXPECT_EQ(g_model.limitData[1].offset, -195);
|
|
||||||
#else
|
|
||||||
EXPECT_EQ(g_model.limitData[1].offset, -200);
|
EXPECT_EQ(g_model.limitData[1].offset, -200);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue