1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-16 21:05:26 +03:00

Support of current EEPROM inside Companion. Some more code around

EEPROMS export removed (needed to be fixed, so I preferred to remove in
the same commit).
This commit is contained in:
Bertrand Songis 2014-01-07 17:57:42 +01:00
parent 5d3c827488
commit 3b59d07724
48 changed files with 938 additions and 7439 deletions

View file

@ -126,16 +126,16 @@ SET( companion9x_SRCS
${ER9X_CHECKOUT_DIRECTORY}/er9xsimulator.cpp
firmwares/gruvin9x/gruvin9xeeprom.cpp
firmwares/gruvin9x/gruvin9xinterface.cpp
firmwares/opentx/open9xeeprom.cpp
firmwares/opentx/opentxeeprom.cpp
firmwares/opentx/open9xStockeeprom.cpp
firmwares/opentx/open9xinterface.cpp
firmwares/opentx/open9xGruvin9xeeprom.cpp
firmwares/opentx/open9xSky9xeeprom.cpp
firmwares/opentx/opentxinterface.cpp
firmwares/opentx/opentxTaranisSimulator.cpp
firmwares/opentx/open9xSky9xsimulator.cpp
firmwares/opentx/open9xGruvin9xsimulator.cpp
firmwares/opentx/open9xM128simulator.cpp
firmwares/opentx/open9xsimulator.cpp
firmwares/opentx/opentxSky9xsimulator.cpp
firmwares/opentx/opentxGruvin9xsimulator.cpp
firmwares/opentx/opentxM128simulator.cpp
firmwares/opentx/opentxsimulator.cpp
firmwares/ersky9x/ersky9xeeprom.cpp
firmwares/ersky9x/ersky9xinterface.cpp
${ERSKY9X_CHECKOUT_DIRECTORY}/ersky9xsimulator.cpp

View file

@ -649,7 +649,8 @@ void compareDialog::printExpos()
};
str += tr("Weight") + QString("%1").arg(getGVarString(ed->weight)).rightJustified(6, ' ');
str += " " + tr("Expo") + QString("%1").arg(getGVarString(ed->expo)).rightJustified(7, ' ');
str += ed->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (GetEepromInterface()->getCapability(FlightPhases)) {
if(ed->phases) {
if (ed->phases!=(unsigned int)(1<<GetEepromInterface()->getCapability(FlightPhases))-1) {
@ -681,16 +682,14 @@ void compareDialog::printExpos()
mask <<=1;
}
str += QString(")");
} else {
}
else {
str += tr("DISABLED")+QString(" !!!");
}
}
}
if (ed->swtch.type)
str += " " + tr("Switch") + QString("(%1)").arg(ed->swtch.toString());
if (ed->curveMode)
if (ed->curveParam)
str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(ed->curveParam).replace("<", "&lt;").replace(">", "&gt;"));
str += "</font></td></tr>";
}
}
@ -728,7 +727,8 @@ void compareDialog::printExpos()
}
str += tr("Weight") + QString("%1").arg(getGVarString(ed->weight)).rightJustified(6, ' ');
str += " " + tr("Expo") + QString("%1").arg(getGVarString(ed->expo)).rightJustified(7, ' ');
str += ed->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (GetEepromInterface()->getCapability(FlightPhases)) {
if(ed->phases) {
if (ed->phases!=(unsigned int)(1<<GetEepromInterface()->getCapability(FlightPhases))-1) {
@ -767,9 +767,7 @@ void compareDialog::printExpos()
}
if (ed->swtch.type)
str += " " + tr("Switch") + QString("(%1)").arg(ed->swtch.toString());
if (ed->curveMode)
if (ed->curveParam)
str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(ed->curveParam).replace("<", "&lt;").replace(">", "&gt;"));
str += "</font></td></tr>";
}
}
@ -824,13 +822,8 @@ void compareDialog::printMixers()
str += md->srcRaw.toString();
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
if (md->carryTrim) str += " " + tr("noTrim");
if(GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1){
if (md->sOffset) str += " "+ tr("FMTrim") + QString(" (%1%)").arg(md->sOffset);
} else {
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
}
if (md->differential) str += " "+ tr("Diff") + QString(" (%1%)").arg(getGVarString(md->differential));
if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve).replace("<", "&lt;").replace(">", "&gt;"));
str += md->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (md->delayDown || md->delayUp) str += tr(" Delay(u%1:d%2)").arg(md->delayUp/scale).arg(md->delayDown/scale);
if (md->speedDown || md->speedUp) str += tr(" Slow(u%1:d%2)").arg(md->speedUp/scale).arg(md->speedDown/scale);
if (md->mixWarn) str += " "+tr("Warn")+QString("(%1)").arg(md->mixWarn);
@ -907,13 +900,9 @@ void compareDialog::printMixers()
str += md->srcRaw.toString();
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
if (md->carryTrim) str += " " + tr("noTrim");
if(GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1){
if (md->sOffset) str += " "+ tr("FMTrim") + QString(" (%1%)").arg(getGVarString(md->sOffset));
} else {
if (md->sOffset) str += " "+ tr("Offset") + QString(" (%1%)").arg(getGVarString(md->sOffset));
}
if (md->differential) str += " "+ tr("Diff") + QString(" (%1%)").arg(getGVarString(md->differential));
if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve).replace("<", "&lt;").replace(">", "&gt;"));
// TODO if (md->differential) str += " "+ tr("Diff") + QString(" (%1%)").arg(getGVarString(md->differential));
// TODO if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve).replace("<", "&lt;").replace(">", "&gt;"));
if (md->delayDown || md->delayUp) str += tr(" Delay(u%1:d%2)").arg(md->delayUp/scale).arg(md->delayDown/scale);
if (md->speedDown || md->speedUp) str += tr(" Slow(u%1:d%2)").arg(md->speedUp/scale).arg(md->speedDown/scale);
if (md->mixWarn) str += " "+tr("Warn")+QString("(%1)").arg(md->mixWarn);

View file

@ -74,7 +74,10 @@ class DataField {
QByteArray bytes = bitsToBytes(bits);
int result = (offset+bits.count()) % 8;
for (int i=0; i<level; i++) printf(" ");
printf("%s ", getName());
if (bits.count() % 8 == 0)
printf("%s (%dbytes) ", getName(), bytes.count());
else
printf("%s (%dbits) ", getName(), bits.count());
for (int i=0; i<bytes.count(); i++) {
unsigned char c = bytes[i];
if ((i==0 && offset) || (i==bytes.count()-1 && result!=0))
@ -422,7 +425,7 @@ class StructField: public DataField {
virtual int Dump(int level=0, int offset=0)
{
for (int i=0; i<level; i++) printf(" ");
printf("%s\n", getName());
printf("%s (%d bytes)\n", getName(), size()/8);
foreach(DataField *field, fields) {
offset = field->Dump(level+1, offset);
}

View file

@ -4,9 +4,10 @@
#include "firmwares/er9x/er9xinterface.h"
#include "firmwares/th9x/th9xinterface.h"
#include "firmwares/gruvin9x/gruvin9xinterface.h"
#include "firmwares/opentx/open9xinterface.h"
#include "firmwares/opentx/opentxinterface.h"
#include "firmwares/ersky9x/ersky9xinterface.h"
#include "qsettings.h"
#include "helpers.h"
QString EEPROMWarnings;
@ -408,6 +409,25 @@ QString RawSwitch::toString()
return QObject::tr("----");
}
QString CurveReference::toString()
{
if (value == 0) {
return "";
}
else {
switch(type) {
case CURVE_REF_DIFF:
return QObject::tr("Diff(%1%%)").arg(getGVarString(value));
case CURVE_REF_EXPO:
return QObject::tr("Expo(%1%%)").arg(getGVarString(value));
case CURVE_REF_FUNC:
return QObject::tr("Function(%1)").arg(QString("x>0" "x<0" "|x|" "f>0" "f<0" "|f|").mid(3*(value-1), 3));
default:
return QString(value > 0 ? QObject::tr("Curve(%1)") : QObject::tr("!Curve(%1)")).arg(abs(value));
}
}
}
GeneralSettings::GeneralSettings()
{
memset(this, 0, sizeof(GeneralSettings));
@ -579,11 +599,7 @@ void ModelData::clear()
expoData[i].clear();
for (int i=0; i<C9X_NUM_CSW; i++)
customSw[i].clear();
bool custom = GetEepromInterface()->getCapability(CustomCurves);
for (int i=0; i<C9X_MAX_CURVES; i++) {
if (!custom && i>=8)
curves[i].clear(9);
else
curves[i].clear(5);
}
@ -628,13 +644,13 @@ ModelData ModelData::removeGlobalVars()
for (int i=0; i<C9X_MAX_MIXERS; i++) {
removeGlobalVar(mixData[i].weight);
removeGlobalVar(mixData[i].differential);
removeGlobalVar(mixData[i].curve.value);
removeGlobalVar(mixData[i].sOffset);
}
for (int i=0; i<C9X_MAX_EXPOS; i++) {
removeGlobalVar(expoData[i].weight);
removeGlobalVar(expoData[i].expo);
removeGlobalVar(expoData[i].curve.value);
}
return result;

View file

@ -44,12 +44,15 @@ template<class t> t LIMIT(t mi, t x, t ma) { return std::min(std::max(mi, x), ma
enum BoardEnum {
BOARD_STOCK,
BOARD_M128,
BOARD_MEGA2560,
BOARD_GRUVIN9X,
BOARD_SKY9X,
BOARD_TARANIS,
BOARD_TARANIS_REV4a
};
#define IS_STOCK(board) (board==BOARD_STOCK || board==BOARD_M128)
#define IS_2560(board) (board==BOARD_GRUVIN9X || board==BOARD_MEGA2560)
#define IS_ARM(board) (board==BOARD_SKY9X || board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a)
#define IS_TARANIS(board) (board==BOARD_TARANIS || board==BOARD_TARANIS_REV4a)
@ -470,17 +473,44 @@ class GeneralSettings {
unsigned int switchUnlockStates;
};
class CurveReference {
public:
enum CurveRefType {
CURVE_REF_DIFF,
CURVE_REF_EXPO,
CURVE_REF_FUNC,
CURVE_REF_CUSTOM
};
CurveReference() { clear(); }
CurveReference(CurveRefType type, int value):
type(type),
value(value)
{
}
void clear() { memset(this, 0, sizeof(CurveReference)); }
CurveRefType type;
int value;
QString toString();
};
class ExpoData {
public:
ExpoData() { clear(); }
RawSource srcRaw;
unsigned int scale;
unsigned int mode; // 0=end, 1=pos, 2=neg, 3=both
unsigned int chn;
RawSwitch swtch;
unsigned int phases; // -5=!FP4, 0=normal, 5=FP4
int weight;
int expo;
unsigned int curveMode;
int curveParam;
int offset;
CurveReference curve;
int carryTrim;
char name[10+1];
void clear() { memset(this, 0, sizeof(ExpoData)); }
};
@ -493,9 +523,17 @@ class CurvePoint {
class CurveData {
public:
enum CurveType {
CURVE_TYPE_STANDARD,
CURVE_TYPE_CUSTOM,
CURVE_TYPE_LAST = CURVE_TYPE_CUSTOM
};
CurveData() { clear(5); }
bool custom; // 0=end, 1=pos, 2=neg, 3=both
uint8_t count;
CurveType type;
bool smooth;
int count;
CurvePoint points[C9X_MAX_POINTS];
char name[6+1];
void clear(int count) { memset(this, 0, sizeof(CurveData)); this->count = count; }
@ -511,6 +549,7 @@ class LimitData {
int ppmCenter;
bool symetrical;
char name[6+1];
CurveReference curve;
void clear() { memset(this, 0, sizeof(LimitData)); min = -100; max = +100; }
};
@ -520,7 +559,6 @@ enum MltpxValue {
MLTPX_REP=2
};
class MixData {
public:
MixData() { clear(); }
@ -528,9 +566,8 @@ class MixData {
RawSource srcRaw;
unsigned int srcVariant;
int weight;
int differential;
RawSwitch swtch;
int curve; //0=symmetrisch
CurveReference curve; //0=symmetrisch
unsigned int delayUp;
unsigned int delayDown;
unsigned int speedUp; // Servogeschwindigkeit aus Tabelle (10ms Cycle)
@ -539,7 +576,6 @@ class MixData {
bool noExpo;
MltpxValue mltpx; // multiplex method 0=+ 1=* 2=replace
unsigned int mixWarn; // mixer warning
unsigned int enableFmTrim;
unsigned int phases; // -5=!FP4, 0=normal, 5=FP4
unsigned int lateOffset;
int sOffset;
@ -621,7 +657,7 @@ class PhaseData {
unsigned int fadeIn;
unsigned int fadeOut;
int rotaryEncoders[2];
int gvars[5];
int gvars[C9X_MAX_GVARS];
void clear() { memset(this, 0, sizeof(PhaseData)); for (int i=0; i<NUM_STICKS; i++) trimRef[i] = -1; }
};
@ -824,7 +860,9 @@ class ModelData {
int8_t t2throttle; // Start timer2 using throttle
unsigned int modelId;
unsigned int switchWarningStates;
// TODO structure
char gvars_names[C9X_MAX_GVARS][6+1];
bool gvars_popups[C9X_MAX_GVARS];
uint8_t gvsource[5];
uint8_t bt_telemetry;
uint8_t numVoice;
@ -893,16 +931,7 @@ enum Capability {
ExtraInputs,
ExtraTrims,
ExtendedTrims,
HasNegCurves,
HasInputFilter,
HasExpoCurves,
ExpoIsCurve,
ExpoCurve5,
ExpoCurve9,
CustomCurves,
NumCurves3,
NumCurves5,
NumCurves9,
NumCurves,
NumCurvePoints,
OffsetWeight,
@ -934,7 +963,6 @@ enum Capability {
OptrexDisplay,
PPMExtCtrl,
PPMFrameLength,
MixFmTrim,
gsSwitchMask,
BLonStickMove,
DSM2Indexes,
@ -971,7 +999,6 @@ enum Capability {
HasSoundMixer,
NumModules,
FSSwitch,
DiffMixers,
PPMCenter,
SYMLimits,
HasCurrentCalibration,

View file

@ -3,26 +3,6 @@
#include "helpers.h"
#include <QObject>
int8_t er9xFromSwitch(const RawSwitch & sw)
{
switch (sw.type) {
case SWITCH_TYPE_SWITCH:
return sw.index;
case SWITCH_TYPE_VIRTUAL:
return sw.index > 0 ? (9 + sw.index) : (-9 + sw.index);
case SWITCH_TYPE_ON:
return 22;
case SWITCH_TYPE_OFF:
return -22;
case SWITCH_TYPE_MOMENT_SWITCH:
return sw.index > 0 ? (22 + sw.index) : (-22 + sw.index);
case SWITCH_TYPE_MOMENT_VIRTUAL:
return sw.index > 0 ? (31 + sw.index) : (-31 + sw.index);
default:
return 0;
}
}
RawSwitch er9xToSwitch(int8_t sw)
{
uint8_t swa = abs(sw);
@ -47,15 +27,6 @@ t_Er9xTrainerMix::t_Er9xTrainerMix()
memset(this, 0, sizeof(t_Er9xTrainerMix));
}
t_Er9xTrainerMix::t_Er9xTrainerMix(TrainerMix &c9x)
{
memset(this, 0, sizeof(t_Er9xTrainerMix));
srcChn = c9x.src;
swtch = er9xFromSwitch(c9x.swtch);
studWeight = (8 * c9x.weight) / 25;
mode = c9x.mode;
}
t_Er9xTrainerMix::operator TrainerMix()
{
TrainerMix c9x;
@ -71,15 +42,6 @@ t_Er9xTrainerData::t_Er9xTrainerData()
memset(this, 0, sizeof(t_Er9xTrainerData));
}
t_Er9xTrainerData::t_Er9xTrainerData(TrainerData &c9x)
{
memset(this, 0, sizeof(t_Er9xTrainerData));
for (int i=0; i<NUM_STICKS; i++) {
calib[i] = c9x.calib[i];
mix[i] = c9x.mix[i];
}
}
t_Er9xTrainerData::operator TrainerData ()
{
TrainerData c9x;
@ -95,75 +57,6 @@ t_Er9xGeneral::t_Er9xGeneral()
memset(this, 0, sizeof(t_Er9xGeneral));
}
t_Er9xGeneral::t_Er9xGeneral(GeneralSettings &c9x)
{
memset(this, 0, sizeof(t_Er9xGeneral));
myVers = MDVERS;
for (int i=0; i<NUM_STICKSnPOTS; i++) {
calibMid[i] = c9x.calibMid[i];
calibSpanNeg[i] = c9x.calibSpanNeg[i];
calibSpanPos[i] = c9x.calibSpanPos[i];
}
uint16_t sum = 0;
for (int i=0; i<12; i++)
sum += calibMid[i];
chkSum = sum;
currModel = c9x.currModel;
contrast = c9x.contrast;
vBatWarn = c9x.vBatWarn;
vBatCalib = c9x.vBatCalib;
trainer = c9x.trainer;
view = c9x.view;
disableThrottleWarning = c9x.disableThrottleWarning;
disableSwitchWarning = (c9x.switchWarning != -1);
disableMemoryWarning = c9x.disableMemoryWarning;
if (c9x.beeperMode == e_quiet)
beeperVal = 0;
else if (c9x.beeperMode < e_all)
beeperVal = 1;
else
beeperVal = c9x.beeperLength + 4;
disableAlarmWarning = c9x.disableAlarmWarning;
stickMode = c9x.stickMode;
inactivityTimer = c9x.inactivityTimer - 10;
minuteBeep = c9x.minuteBeep;
preBeep = c9x.preBeep;
flashBeep = c9x.flashBeep;
disableSplashScreen = c9x.splashMode;
disablePotScroll=(c9x.disablePotScroll ? 1 : 0);
disableBG=(c9x.disableBG ? 1 :0);
frskyinternalalarm = c9x.frskyinternalalarm;
blightinv=(c9x.blightinv ? 1 : 0);
stickScroll=(c9x.stickScroll ? 1 : 0);
if (c9x.backlightMode == 4)
lightSw = 22;
if (c9x.backlightMode & 1)
lightAutoOff = c9x.backlightDelay;
if (c9x.backlightMode & 2)
lightOnStickMove = c9x.backlightDelay;
templateSetup = c9x.templateSetup;
PPM_Multiplier = c9x.PPM_Multiplier;
setEEPROMString(ownerName, c9x.ownerName, sizeof(ownerName));
speakerPitch = c9x.speakerPitch;
hapticStrength = c9x.hapticStrength;
hideNameOnSplash = (c9x.hideNameOnSplash ? 1 : 0);
enablePpmsim = (c9x.enablePpmsim ? 1 : 0);;
speakerMode = c9x.speakerMode;
switchWarningStates =c9x.switchWarningStates;
crosstrim=(c9x.crosstrim ? 1 : 0);
}
Er9xGeneral::operator GeneralSettings ()
{
GeneralSettings result;
@ -242,15 +135,6 @@ t_Er9xLimitData::t_Er9xLimitData()
memset(this, 0, sizeof(t_Er9xLimitData));
}
t_Er9xLimitData::t_Er9xLimitData(LimitData &c9x)
{
memset(this, 0, sizeof(t_Er9xLimitData));
min = c9x.min+100;
max = c9x.max-100;
revert = c9x.revert;
offset = c9x.offset;
}
t_Er9xLimitData::operator LimitData ()
{
LimitData c9x;
@ -266,107 +150,6 @@ t_Er9xMixData::t_Er9xMixData()
memset(this, 0, sizeof(t_Er9xMixData));
}
t_Er9xMixData::t_Er9xMixData(MixData &c9x)
{
memset(this, 0, sizeof(t_Er9xMixData));
destCh = c9x.destCh;
swtch = er9xFromSwitch(c9x.swtch);
if (c9x.srcRaw.type == SOURCE_TYPE_NONE) {
srcRaw = 0;
swtch = 0;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_STICK) {
srcRaw = 1 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have Rotary Encoders") + "\n";
srcRaw = 5 + c9x.srcRaw.index; // use pots instead
}
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX) {
srcRaw = 8; // MAX
}
else if (c9x.srcRaw.type == SOURCE_TYPE_SWITCH) {
srcRaw = 9; // FULL
swtch = er9xFromSwitch(RawSwitch(c9x.srcRaw.index));
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CYC) {
srcRaw = 10 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM) {
srcRaw = 13 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CH) {
srcRaw = 21 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_GVAR) {
srcRaw = 38 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_TRIM) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have trims as source") + "\n";
srcRaw = 0; // use pots instead
}
if (abs(c9x.weight)>125) {
if (c9x.weight>0) {
int index=abs(c9x.weight)-10000;
int gvar=125+index;
if (gvar>127) {
gvar-=256;
}
weight = gvar;
} else {
EEPROMWarnings += ::QObject::tr("er9x doesn't have negative gvars as weight") + "\n";
weight=0;
}
} else {
weight = c9x.weight;
}
if (abs(c9x.sOffset)>125) {
if (c9x.sOffset>0) {
int index=abs(c9x.sOffset)-10000;
int gvar=125+index;
if (gvar>127) {
gvar-=256;
}
sOffset = gvar;
} else {
EEPROMWarnings += ::QObject::tr("er9x doesn't have negative gvars as offset") + "\n";
sOffset=0;
}
} else {
sOffset = c9x.sOffset;
}
if (c9x.curve!=0) {
curve = c9x.curve;
differential=0;
} else {
if (c9x.differential!=0) {
curve=c9x.differential;
differential=1;
} else {
curve=0;
differential=0;
}
}
lateOffset=c9x.lateOffset;
delayUp = c9x.delayUp;
delayDown = c9x.delayDown;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
if (c9x.carryTrim<0) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have swappable trims") + "\n";
carryTrim=1;
} else {
carryTrim = c9x.carryTrim;
}
mltpx = (MltpxValue)c9x.mltpx;
mixWarn = c9x.mixWarn;
enableFmTrim=c9x.enableFmTrim;
}
t_Er9xMixData::operator MixData ()
{
MixData c9x;
@ -432,13 +215,20 @@ t_Er9xMixData::operator MixData ()
else {
c9x.srcRaw = RawSource(SOURCE_TYPE_GVAR, srcRaw-38);
}
if (differential==1) {
c9x.differential=curve;
c9x.curve=0;
} else {
c9x.differential=0;
c9x.curve=curve;
c9x.curve.type = CurveReference::CURVE_REF_DIFF;
c9x.curve.value = differential;
}
else if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
c9x.lateOffset=lateOffset;
c9x.delayUp = delayUp;
c9x.delayDown = delayDown;
@ -447,32 +237,10 @@ t_Er9xMixData::operator MixData ()
c9x.carryTrim = carryTrim;
c9x.mltpx = (MltpxValue)mltpx;
c9x.mixWarn = mixWarn;
c9x.enableFmTrim=enableFmTrim;
// c9x.enableFmTrim=enableFmTrim;
return c9x;
}
int8_t er9xFromSource(RawSource source)
{
int v1 = 0;
if (source.type == SOURCE_TYPE_STICK)
v1 = 1+source.index;
else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("er9x on this board doesn't have Rotary Encoders") + "\n";
v1 = 5+source.index;
}
else if (source.type == SOURCE_TYPE_MAX)
v1 = 8;
else if (source.type == SOURCE_TYPE_CYC)
v1 = 10+source.index;
else if (source.type == SOURCE_TYPE_PPM)
v1 = 13+source.index;
else if (source.type == SOURCE_TYPE_CH)
v1 = 21+source.index;
else if (source.type == SOURCE_TYPE_TELEMETRY)
v1 = 36+source.index;
return v1;
}
RawSource er9xToSource(int8_t value)
{
if (value == 0) {
@ -501,33 +269,6 @@ RawSource er9xToSource(int8_t value)
}
}
t_Er9xCustomSwData::t_Er9xCustomSwData(CustomSwData &c9x)
{
func = c9x.func;
v1 = c9x.val1;
v2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
v1 = er9xFromSource(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
v2 = er9xFromSource(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
v1 = er9xFromSwitch(RawSwitch(c9x.val1));
v2 = er9xFromSwitch(RawSwitch(c9x.val2));
}
if (func>ER9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("er9x does not support Custom Switch function %1").arg(getFuncName(func)) + "\n";
func=0;
v1=0;
v2=0;
}
}
Er9xCustomSwData::operator CustomSwData ()
{
CustomSwData c9x;
@ -557,13 +298,6 @@ t_Er9xSafetySwData::t_Er9xSafetySwData()
memset(this, 0, sizeof(t_Er9xSafetySwData));
}
t_Er9xSafetySwData::t_Er9xSafetySwData(SafetySwData &c9x)
{
memset(this, 0, sizeof(t_Er9xSafetySwData));
swtch = er9xFromSwitch(c9x.swtch);
val = c9x.val;
}
t_Er9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
@ -572,35 +306,11 @@ t_Er9xSafetySwData::operator SafetySwData ()
return c9x;
}
t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData()
{
memset(this, 0, sizeof(t_Er9xFrSkyChannelData));
}
t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData(FrSkyChannelData &c9x)
{
memset(this, 0, sizeof(t_Er9xFrSkyChannelData));
ratio = c9x.ratio;
alarms_value[0] = c9x.alarms[0].value;
alarms_value[1] = c9x.alarms[1].value;
alarms_level = (c9x.alarms[1].level << 2) + c9x.alarms[0].level;
alarms_greater = (c9x.alarms[1].greater << 1) + c9x.alarms[0].greater;
if (c9x.type==0) {
if (c9x.multiplier==0) {
type = 0;
} else if (c9x.multiplier==1) {
type = 2;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this range for A1/A2") + "\n";
}
} else if (c9x.type==1 || c9x.type==3) {
type=c9x.type;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this telemetry units") + "\n";
}
}
t_Er9xFrSkyChannelData::operator FrSkyChannelData ()
{
FrSkyChannelData c9x;
@ -620,19 +330,11 @@ t_Er9xFrSkyChannelData::operator FrSkyChannelData ()
return c9x;
}
t_Er9xFrSkyData::t_Er9xFrSkyData()
{
memset(this, 0, sizeof(t_Er9xFrSkyData));
}
t_Er9xFrSkyData::t_Er9xFrSkyData(FrSkyData &c9x)
{
memset(this, 0, sizeof(t_Er9xFrSkyData));
channels[0] = c9x.channels[0];
channels[1] = c9x.channels[1];
}
t_Er9xFrSkyData::operator FrSkyData ()
{
FrSkyData c9x;
@ -641,24 +343,6 @@ t_Er9xFrSkyData::operator FrSkyData ()
return c9x;
}
int setEr9xTimerMode(TimerMode mode)
{
if (mode == TMRMODE_OFF || mode == TMRMODE_ABS)
return mode;
else if (mode == TMRMODE_THs || mode == TMRMODE_THp)
return mode + 4;
else if (mode >= TMRMODE_FIRST_MOMENT_SWITCH)
return 37+mode-TMRMODE_FIRST_MOMENT_SWITCH;
else if (mode >= TMRMODE_FIRST_SWITCH)
return 16+mode-TMRMODE_FIRST_SWITCH;
else if (mode <= TMRMODE_FIRST_NEG_MOMENT_SWITCH)
return -37+mode-TMRMODE_FIRST_NEG_MOMENT_SWITCH;
else if (mode <= TMRMODE_FIRST_NEG_SWITCH)
return -16+mode-TMRMODE_FIRST_NEG_SWITCH;
else
return 0;
}
TimerMode getEr9xTimerMode(int mode)
{
if (mode <= -33)
@ -673,162 +357,6 @@ TimerMode getEr9xTimerMode(int mode)
return TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-16-21));
}
t_Er9xModelData::t_Er9xModelData(ModelData &c9x)
{
memset(this, 0, sizeof(t_Er9xModelData));
if (c9x.used) {
setEEPROMString(name, c9x.name, sizeof(name));
modelVoice=c9x.modelVoice;
tmrMode = setEr9xTimerMode(c9x.timers[0].mode);
tmrModeB = c9x.timers[0].modeB;
tmrDir = c9x.timers[0].dir;
tmrVal = c9x.timers[0].val;
switch(c9x.moduleData[0].protocol) {
case PPM:
protocol = 0;
break;
case PXX_DJT:
protocol = 1;
break;
case DSM2:
protocol = 2;
break;
case PPM16:
protocol = 3;
break;
default:
protocol = 0;
EEPROMWarnings += QObject::tr("Er9x doesn't accept this protocol") + "\n";
// TODO more explicit warning for each protocol
break;
}
traineron = c9x.traineron;
t2throttle = c9x.t2throttle;
ppmFrameLength = c9x.moduleData[0].ppmFrameLength;
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
for (unsigned int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++)
if (c9x.funcSw[i].func == FuncInstantTrim && c9x.funcSw[i].swtch.type != SWITCH_TYPE_NONE) {
trimSw = er9xFromSwitch(c9x.funcSw[i].swtch);
break;
}
beepANACenter = (uint8_t)(c9x.beepANACenter & 0x7F);
pulsePol = c9x.moduleData[0].ppmPulsePol;
extendedLimits = c9x.extendedLimits;
swashInvertELE = c9x.swashRingData.invertELE;
swashInvertAIL = c9x.swashRingData.invertAIL;
swashInvertCOL = c9x.swashRingData.invertCOL;
swashType = c9x.swashRingData.type;
swashCollectiveSource = er9xFromSource(c9x.swashRingData.collectiveSource);
swashRingValue = c9x.swashRingData.value;
for (int i=0; i<ER9X_MAX_MIXERS; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++)
limitData[i] = c9x.limitData[i];
// expoData
for (unsigned int i=0; i<NUM_STICKS; i++) {
// first we find the switches
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i) {
if (c9x.expoData[e].swtch.type!=SWITCH_TYPE_NONE) {
if (!expoData[i].drSw1)
expoData[i].drSw1 = -er9xFromSwitch(c9x.expoData[e].swtch);
else if (er9xFromSwitch(c9x.expoData[e].swtch) != -expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw2 = -er9xFromSwitch(c9x.expoData[e].swtch);
}
}
}
}
if (expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw1 = -expoData[i].drSw1;
}
for (int pos=0; pos<3; pos++) {
int swtch1=0, swtch2=0;
if (expoData[i].drSw1 && !expoData[i].drSw2) {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
break;
default:
swtch1 = expoData[i].drSw1;
break;
}
}
else {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
swtch2 = -expoData[i].drSw2;
break;
default:
swtch1 = expoData[i].drSw1;
swtch2 = expoData[i].drSw2;
break;
}
}
for (int mode=0; mode<2; mode++) {
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i && !c9x.expoData[e].phases) {
if (c9x.expoData[e].swtch.type==SWITCH_TYPE_NONE || c9x.expoData[e].swtch == er9xToSwitch(swtch1) || c9x.expoData[e].swtch == er9xToSwitch(swtch2)) {
if (c9x.expoData[e].mode == 3 || (c9x.expoData[e].mode==2 && mode==0) || (c9x.expoData[e].mode==1 && mode==1)) {
expoData[i].expo[pos][0][mode] = c9x.expoData[e].expo;
expoData[i].expo[pos][1][mode] = c9x.expoData[e].weight - 100;
break;
}
}
}
}
}
}
}
for (int i=0; i<NUM_STICKS; i++)
trim[i] = std::max(-125, std::min(125, c9x.phaseData[0].trim[i]));
for (int i=0; i<ER9X_MAX_CURVE5; i++)
if (c9x.curves[i].count==5) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("Er9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("Er9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<ER9X_MAX_CURVE9; i++)
if (c9x.curves[i+ER9X_MAX_CURVE5].count==9) {
if (c9x.curves[i+ER9X_MAX_CURVE5].custom)
EEPROMWarnings += QObject::tr("Er9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+ER9X_MAX_CURVE5) + "\n";
for (int j=0; j<9; j++)
curves9[i][j] = c9x.curves[i+ER9X_MAX_CURVE5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("Er9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+ER9X_MAX_CURVE5].count).arg(i+1+ER9X_MAX_CURVE5) + "\n";
}
for (int i=0; i<ER9X_NUM_CSW; i++)
customSw[i] = c9x.customSw[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++)
safetySw[i] = c9x.safetySw[i];
frsky = c9x.frsky;
FrSkyUsrProto = c9x.frsky.usrProto;
FrSkyImperial = c9x.frsky.imperial;
FrSkyGpsAlt = c9x.frsky.FrSkyGpsAlt;
}
}
t_Er9xModelData::operator ModelData ()
{
ModelData c9x;
@ -900,7 +428,10 @@ t_Er9xModelData::operator ModelData ()
c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? -expoData[ch].drSw1 : (dr == 1 ? -expoData[ch].drSw2 : 0));
}
c9x.expoData[e].chn = ch;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][0];
if (expoData[ch].expo[pos][0][0]) {
c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][0];
}
c9x.expoData[e].weight = 100 + expoData[ch].expo[pos][1][0];
if (expoData[ch].expo[pos][0][0] == expoData[ch].expo[pos][0][1] && expoData[ch].expo[pos][1][0] == expoData[ch].expo[pos][1][1]) {
c9x.expoData[e++].mode = 3;
@ -911,7 +442,10 @@ t_Er9xModelData::operator ModelData ()
c9x.expoData[e + 1].swtch = c9x.expoData[e].swtch;
c9x.expoData[++e].chn = ch;
c9x.expoData[e].mode = 1;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][1];
if (expoData[ch].expo[pos][0][1]) {
c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][1];
}
c9x.expoData[e++].weight = 100 + expoData[ch].expo[pos][1][1];
}
}
@ -922,7 +456,6 @@ t_Er9xModelData::operator ModelData ()
c9x.phaseData[0].trim[i] = trim[i];
for (int i=0; i<ER9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@ -930,7 +463,6 @@ t_Er9xModelData::operator ModelData ()
}
}
for (int i=0; i<ER9X_MAX_CURVE9; i++) {
c9x.curves[ER9X_MAX_CURVE5 + i].custom = false;
c9x.curves[ER9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[ER9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;

View file

@ -42,8 +42,6 @@ PACK(typedef struct t_Er9xTrainerMix {
operator TrainerMix();
t_Er9xTrainerMix();
t_Er9xTrainerMix(TrainerMix&);
}) Er9xTrainerMix; //
PACK(typedef struct t_Er9xTrainerData {
@ -52,8 +50,6 @@ PACK(typedef struct t_Er9xTrainerData {
operator TrainerData();
t_Er9xTrainerData();
t_Er9xTrainerData(TrainerData&);
}) Er9xTrainerData;
PACK(typedef struct t_Er9xGeneral {
@ -109,8 +105,6 @@ PACK(typedef struct t_Er9xGeneral {
operator GeneralSettings();
t_Er9xGeneral();
t_Er9xGeneral(GeneralSettings&);
}) Er9xGeneral;
PACK(typedef struct t_Er9xExpoData {
@ -130,7 +124,6 @@ PACK(typedef struct t_Er9xLimitData {
operator LimitData();
t_Er9xLimitData();
t_Er9xLimitData(LimitData&);
}) Er9xLimitData;
#define MLTPX_ADD 0
@ -158,7 +151,6 @@ PACK(typedef struct t_Er9xMixData {
operator MixData();
t_Er9xMixData();
t_Er9xMixData(MixData&);
}) Er9xMixData;
@ -170,7 +162,6 @@ PACK(typedef struct t_Er9xCustomSwData { // Custom Switches data
operator CustomSwData();
t_Er9xCustomSwData() { memset(this, 0, sizeof(t_Er9xCustomSwData)); }
t_Er9xCustomSwData(CustomSwData&);
}) Er9xCustomSwData;
PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data
@ -179,7 +170,6 @@ PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data
operator SafetySwData();
t_Er9xSafetySwData();
t_Er9xSafetySwData(SafetySwData&);
}) Er9xSafetySwData;
PACK(typedef struct t_Er9xFrSkyChannelData {
@ -191,7 +181,6 @@ PACK(typedef struct t_Er9xFrSkyChannelData {
operator FrSkyChannelData();
t_Er9xFrSkyChannelData();
t_Er9xFrSkyChannelData(FrSkyChannelData&);
}) Er9xFrSkyChannelData;
PACK(typedef struct t_Er9xFrSkyData {
@ -199,7 +188,6 @@ PACK(typedef struct t_Er9xFrSkyData {
operator FrSkyData();
t_Er9xFrSkyData();
t_Er9xFrSkyData(FrSkyData&);
}) Er9xFrSkyData;
PACK(typedef struct t_gvar {
@ -268,9 +256,6 @@ PACK(typedef struct t_Er9xModelData {
operator ModelData();
t_Er9xModelData() { memset(this, 0, sizeof(t_Er9xModelData)); }
t_Er9xModelData(ModelData&);
}) Er9xModelData;
#endif
/*eof*/

View file

@ -184,57 +184,20 @@ bool Er9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize,
int Er9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
std::cout << "NO!\n";
// TODO an error
efile->EeFsCreate(eeprom, getEEpromSize(), BOARD_STOCK);
Er9xGeneral er9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc1(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&er9xGeneral, sizeof(Er9xGeneral));
if(sz != sizeof(Er9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
Er9xModelData er9xModel(radioData.models[i]);
applyStickModeToModel(er9xModel, radioData.generalSettings.stickMode+1);
sz = efile->writeRlc1(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&er9xModel, sizeof(Er9xModelData));
if(sz != sizeof(Er9xModelData)) {
return 0;
}
}
}
return getEEpromSize();
}
int Er9xInterface::getSize(ModelData &model)
{
if (model.isempty())
return 0;
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Er9xModelData er9xModel(model);
int sz = efile->writeRlc1(0, FILE_TYP_MODEL, (uint8_t*)&er9xModel, sizeof(Er9xModelData));
if(sz != sizeof(Er9xModelData)) {
return -1;
}
return efile->size(0);
}
int Er9xInterface::getSize(GeneralSettings &settings)
{
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Er9xGeneral er9xGeneral(settings);
int sz = efile->writeRlc1(0, FILE_TYP_GENERAL, (uint8_t*)&er9xGeneral, sizeof(Er9xGeneral));
if(sz != sizeof(Er9xGeneral)) {
return -1;
}
return efile->size(0);
return 0;
}
int Er9xInterface::getCapability(const Capability capability)
@ -244,12 +207,6 @@ int Er9xInterface::getCapability(const Capability capability)
return 4;
case Mixes:
return ER9X_MAX_MIXERS;
case NumCurves5:
return ER9X_MAX_CURVE5;
case NumCurves9:
return ER9X_MAX_CURVE5;
case MixFmTrim:
return 1;
case PPMExtCtrl:
return 1;
case ModelTrainerEnable:
@ -324,8 +281,6 @@ int Er9xInterface::getCapability(const Capability capability)
case HasVolume:
case HasBlInvert:
case ModelVoice:
case DiffMixers:
case HasNegCurves:
case HasFixOffset:
return 1;
case Gvars:

View file

@ -3,19 +3,8 @@
#include "ersky9xeeprom.h"
#include <QObject>
extern int8_t er9xFromSwitch(const RawSwitch & sw);
extern RawSwitch er9xToSwitch(int8_t sw);
int setErSky9xTimerMode(TimerMode mode)
{
if (mode == TMRMODE_OFF || mode == TMRMODE_ABS || mode == TMRMODE_THs || mode == TMRMODE_THp)
return mode;
else if (mode >= TMRMODE_FIRST_CHPERC)
return 4+mode-TMRMODE_FIRST_CHPERC;
else
return 0;
}
TimerMode getErSky9xTimerMode(int mode)
{
if (mode<4)
@ -26,26 +15,6 @@ TimerMode getErSky9xTimerMode(int mode)
return TimerMode(0);
}
int8_t ersky9xFromSwitch(const RawSwitch & sw)
{
switch (sw.type) {
case SWITCH_TYPE_SWITCH:
return sw.index;
case SWITCH_TYPE_VIRTUAL:
return sw.index > 0 ? (9 + sw.index) : (-9 + sw.index);
case SWITCH_TYPE_ON:
return 34;
case SWITCH_TYPE_OFF:
return -34;
case SWITCH_TYPE_MOMENT_SWITCH:
return sw.index > 0 ? (34 + sw.index) : (-34 + sw.index);
case SWITCH_TYPE_MOMENT_VIRTUAL:
return sw.index > 0 ? (31 + sw.index) : (-31 + sw.index);
default:
return 0;
}
}
RawSwitch ersky9xToSwitch(int8_t sw)
{
uint8_t swa = abs(sw);
@ -65,21 +34,11 @@ RawSwitch ersky9xToSwitch(int8_t sw)
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-34-9 : sw+34+9);
}
t_Ersky9xTrainerMix::t_Ersky9xTrainerMix()
{
memset(this, 0, sizeof(t_Ersky9xTrainerMix));
}
t_Ersky9xTrainerMix::t_Ersky9xTrainerMix(TrainerMix &c9x)
{
memset(this, 0, sizeof(t_Ersky9xTrainerMix));
srcChn = c9x.src;
swtch = er9xFromSwitch(c9x.swtch);
studWeight = (8 * c9x.weight) / 25;
mode = c9x.mode;
}
t_Ersky9xTrainerMix::operator TrainerMix()
{
TrainerMix c9x;
@ -95,15 +54,6 @@ t_Ersky9xTrainerData::t_Ersky9xTrainerData()
memset(this, 0, sizeof(t_Ersky9xTrainerData));
}
t_Ersky9xTrainerData::t_Ersky9xTrainerData(TrainerData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xTrainerData));
for (int i=0; i<NUM_STICKS; i++) {
calib[i] = c9x.calib[i];
mix[i] = c9x.mix[i];
}
}
t_Ersky9xTrainerData::operator TrainerData ()
{
TrainerData c9x;
@ -119,71 +69,6 @@ t_Ersky9xGeneral::t_Ersky9xGeneral()
memset(this, 0, sizeof(t_Ersky9xGeneral));
}
t_Ersky9xGeneral::t_Ersky9xGeneral(GeneralSettings &c9x)
{
memset(this, 0, sizeof(t_Ersky9xGeneral));
myVers = ERSKY9X_MDVERS11;
for (int i=0; i<NUM_STICKSnPOTS; i++) {
calibMid[i] = c9x.calibMid[i];
calibSpanNeg[i] = c9x.calibSpanNeg[i];
calibSpanPos[i] = c9x.calibSpanPos[i];
}
uint16_t sum = 0;
for (int i=0; i<12; i++)
sum += calibMid[i];
chkSum = sum;
currModel = c9x.currModel;
contrast = c9x.contrast;
vBatWarn = c9x.vBatWarn;
vBatCalib = c9x.vBatCalib;
if (c9x.backlightMode == 4)
lightSw = 22;
if (c9x.backlightMode & 1)
lightAutoOff = c9x.backlightDelay;
if (c9x.backlightMode & 2)
lightOnStickMove = c9x.backlightDelay;
trainer = c9x.trainer;
view = c9x.view;
disableThrottleWarning = c9x.disableThrottleWarning;
disableSwitchWarning = (c9x.switchWarning != -1);
disableMemoryWarning = c9x.disableMemoryWarning;
if (c9x.beeperMode == e_quiet)
beeperVal = 0;
else if (c9x.beeperMode < e_all)
beeperVal = 1;
else
beeperVal = c9x.beeperLength + 4;
disableAlarmWarning = c9x.disableAlarmWarning;
stickMode = c9x.stickMode;
inactivityTimer = c9x.inactivityTimer - 10;
minuteBeep = c9x.minuteBeep;
preBeep = c9x.preBeep;
flashBeep = c9x.flashBeep;
disableSplashScreen = c9x.splashMode;
disablePotScroll=(c9x.disablePotScroll ? 1 : 0);
disableBG=(c9x.disableBG ? 1 :0);
filterInput = c9x.filterInput;
templateSetup = c9x.templateSetup;
PPM_Multiplier = c9x.PPM_Multiplier;
setEEPROMString(ownerName, c9x.ownerName, sizeof(ownerName));
optrexDisplay = c9x.optrexDisplay;
speakerPitch = c9x.speakerPitch;
hapticStrength = c9x.hapticStrength;
speakerMode = c9x.speakerMode;
switchWarningStates =c9x.switchWarningStates;
volume = c9x.speakerVolume;
bright = c9x.backlightBright;
current_calib = c9x.currentCalib;
}
Ersky9xGeneral::operator GeneralSettings ()
{
GeneralSettings result;
@ -262,15 +147,6 @@ t_Ersky9xLimitData::t_Ersky9xLimitData()
memset(this, 0, sizeof(t_Ersky9xLimitData));
}
t_Ersky9xLimitData::t_Ersky9xLimitData(LimitData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xLimitData));
min = c9x.min+100;
max = c9x.max-100;
revert = c9x.revert;
offset = c9x.offset;
}
t_Ersky9xLimitData::operator LimitData ()
{
LimitData c9x;
@ -286,65 +162,6 @@ t_Ersky9xMixData_v10::t_Ersky9xMixData_v10()
memset(this, 0, sizeof(t_Ersky9xMixData_v10));
}
t_Ersky9xMixData_v10::t_Ersky9xMixData_v10(MixData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xMixData_v10));
destCh = c9x.destCh;
swtch = er9xFromSwitch(c9x.swtch);
if (c9x.srcRaw.type == SOURCE_TYPE_NONE) {
srcRaw = 0;
swtch = 0;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_STICK) {
srcRaw = 1 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("ersky9x doesn't have Rotary Encoders") + "\n";
srcRaw = 5 + c9x.srcRaw.index; // use pots instead
}
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX) {
srcRaw = 8; // MAX
}
/* else if (c9x.srcRaw.type == SOURCE_TYPE_3POS) {
srcRaw = 37;
} */
else if (c9x.srcRaw.type == SOURCE_TYPE_SWITCH) {
srcRaw = 9; // FULL
swtch = er9xFromSwitch(RawSwitch(c9x.srcRaw.index));
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CYC) {
srcRaw = 10 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM) {
srcRaw = 13 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CH) {
srcRaw = 21 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_TRIM) {
EEPROMWarnings += ::QObject::tr("ersky9x doesn't have trims as source") + "\n";
srcRaw = 0; // use pots instead
}
weight = c9x.weight;
curve = c9x.curve;
delayUp = c9x.delayUp;
delayDown = c9x.delayDown;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
if (c9x.carryTrim<0) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have swappable trims") + "\n";
carryTrim=1;
} else {
carryTrim = c9x.carryTrim;
}
mltpx = (MltpxValue)c9x.mltpx;
mixWarn = c9x.mixWarn;
enableFmTrim=c9x.enableFmTrim;
sOffset = c9x.sOffset;
}
t_Ersky9xMixData_v10::operator MixData ()
{
MixData c9x;
@ -388,7 +205,15 @@ t_Ersky9xMixData_v10::operator MixData ()
c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-21);
}
c9x.curve = curve;
if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
c9x.delayUp = delayUp;
c9x.delayDown = delayDown;
c9x.speedUp = speedUp;
@ -396,7 +221,7 @@ t_Ersky9xMixData_v10::operator MixData ()
c9x.carryTrim = carryTrim;
c9x.mltpx = (MltpxValue)mltpx;
c9x.mixWarn = mixWarn;
c9x.enableFmTrim=enableFmTrim;
// c9x.enableFmTrim=enableFmTrim;
c9x.sOffset = sOffset;
return c9x;
}
@ -407,67 +232,6 @@ t_Ersky9xMixData_v11::t_Ersky9xMixData_v11()
memset(this, 0, sizeof(t_Ersky9xMixData_v11));
}
t_Ersky9xMixData_v11::t_Ersky9xMixData_v11(MixData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xMixData_v11));
destCh = c9x.destCh;
swtch = ersky9xFromSwitch(c9x.swtch);
if (c9x.srcRaw.type == SOURCE_TYPE_NONE) {
srcRaw = 0;
swtch = 0;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_STICK) {
srcRaw = 1 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("ersky9x doesn't have Rotary Encoders") + "\n";
srcRaw = 5 + c9x.srcRaw.index; // use pots instead
}
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX) {
srcRaw = 8; // MAX
}
/* else if (c9x.srcRaw.type == SOURCE_TYPE_3POS) {
srcRaw = 45;
} */
else if (c9x.srcRaw.type == SOURCE_TYPE_GVAR) {
srcRaw = 46+c9x.srcRaw.index; // MAX
}
else if (c9x.srcRaw.type == SOURCE_TYPE_SWITCH) {
srcRaw = 9; // FULL
swtch = ersky9xFromSwitch(RawSwitch(c9x.srcRaw.index));
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CYC) {
srcRaw = 10 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM) {
srcRaw = 13 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CH) {
srcRaw = 21 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_TRIM) {
EEPROMWarnings += ::QObject::tr("ersky9x doesn't have trims as source") + "\n";
srcRaw = 0; // use pots instead
}
weight = c9x.weight;
curve = c9x.curve;
delayUp = c9x.delayUp;
delayDown = c9x.delayDown;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
if (c9x.carryTrim<0) {
EEPROMWarnings += ::QObject::tr("er9x doesn't have swappable trims") + "\n";
carryTrim=1;
} else {
carryTrim = c9x.carryTrim;
}
mltpx = (MltpxValue)c9x.mltpx;
mixWarn = c9x.mixWarn;
enableFmTrim=c9x.enableFmTrim;
sOffset = c9x.sOffset;
}
t_Ersky9xMixData_v11::operator MixData ()
{
MixData c9x;
@ -514,7 +278,15 @@ t_Ersky9xMixData_v11::operator MixData ()
c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-21);
}
c9x.curve = curve;
if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
c9x.delayUp = delayUp;
c9x.delayDown = delayDown;
c9x.speedUp = speedUp;
@ -522,60 +294,11 @@ t_Ersky9xMixData_v11::operator MixData ()
c9x.carryTrim = carryTrim;
c9x.mltpx = (MltpxValue)mltpx;
c9x.mixWarn = mixWarn;
c9x.enableFmTrim=enableFmTrim;
// c9x.enableFmTrim=enableFmTrim;
c9x.sOffset = sOffset;
return c9x;
}
int8_t ersky9xFromSource_v10(RawSource source)
{
int v1 = 0;
if (source.type == SOURCE_TYPE_STICK)
v1 = 1+source.index;
else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("er9x on this board doesn't have Rotary Encoders") + "\n";
v1 = 5+source.index;
}
else if (source.type == SOURCE_TYPE_MAX)
v1 = 8;
/* else if (source.type == SOURCE_TYPE_3POS)
v1 = 0; */
else if (source.type == SOURCE_TYPE_CYC)
v1 = 10+source.index;
else if (source.type == SOURCE_TYPE_PPM)
v1 = 13+source.index;
else if (source.type == SOURCE_TYPE_CH)
v1 = 21+source.index;
else if (source.type == SOURCE_TYPE_TELEMETRY)
v1 = 36+source.index;
return v1;
}
int8_t ersky9xFromSource_v11(RawSource source)
{
int v1 = 0;
if (source.type == SOURCE_TYPE_STICK)
v1 = 1+source.index;
else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("er9x on this board doesn't have Rotary Encoders") + "\n";
v1 = 5+source.index;
}
else if (source.type == SOURCE_TYPE_MAX)
v1 = 8;
/* else if (source.type == SOURCE_TYPE_3POS)
v1 = 0; */
else if (source.type == SOURCE_TYPE_CYC)
v1 = 10+source.index;
else if (source.type == SOURCE_TYPE_PPM)
v1 = 13+source.index;
else if (source.type == SOURCE_TYPE_CH)
v1 = 21+source.index;
else if (source.type == SOURCE_TYPE_TELEMETRY)
v1 = 36+source.index;
return v1;
}
RawSource ersky9xToSource_v10(int8_t value)
{
if (value == 0) {
@ -632,33 +355,6 @@ RawSource ersky9xToSource_v11(int8_t value)
}
}
t_Ersky9xCustomSwData_v10::t_Ersky9xCustomSwData_v10(CustomSwData &c9x)
{
func = c9x.func;
v1 = c9x.val1;
v2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
v1 = ersky9xFromSource_v10(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
v2 = ersky9xFromSource_v10(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
v1 = er9xFromSwitch(RawSwitch(c9x.val1));
v2 = er9xFromSwitch(RawSwitch(c9x.val2));
}
if (func>ERSKY9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("ersky9x does not support Custom Switch function %1").arg(getFuncName(func)) + "\n";
func=0;
v1=0;
v2=0;
}
}
Ersky9xCustomSwData_v10::operator CustomSwData ()
{
CustomSwData c9x;
@ -682,33 +378,6 @@ Ersky9xCustomSwData_v10::operator CustomSwData ()
return c9x;
}
t_Ersky9xCustomSwData_v11::t_Ersky9xCustomSwData_v11(CustomSwData &c9x)
{
func = c9x.func;
v1 = c9x.val1;
v2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
v1 = ersky9xFromSource_v11(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
v2 = ersky9xFromSource_v11(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
v1 = er9xFromSwitch(RawSwitch(c9x.val1));
v2 = er9xFromSwitch(RawSwitch(c9x.val2));
}
if (func>ERSKY9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("ersky9x does not support Custom Switch function %1").arg(getFuncName(func)) + "\n";
func=0;
v1=0;
v2=0;
}
}
Ersky9xCustomSwData_v11::operator CustomSwData ()
{
CustomSwData c9x;
@ -737,13 +406,6 @@ t_Ersky9xSafetySwData_v10::t_Ersky9xSafetySwData_v10()
memset(this, 0, sizeof(t_Ersky9xSafetySwData_v10));
}
t_Ersky9xSafetySwData_v10::t_Ersky9xSafetySwData_v10(SafetySwData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xSafetySwData_v10));
swtch = er9xFromSwitch(c9x.swtch);
val = c9x.val;
}
t_Ersky9xSafetySwData_v10::operator SafetySwData ()
{
SafetySwData c9x;
@ -757,13 +419,6 @@ t_Ersky9xSafetySwData_v11::t_Ersky9xSafetySwData_v11()
memset(this, 0, sizeof(t_Ersky9xSafetySwData_v11));
}
t_Ersky9xSafetySwData_v11::t_Ersky9xSafetySwData_v11(SafetySwData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xSafetySwData_v11));
opt.ss.swtch = ersky9xFromSwitch(c9x.swtch);
opt.ss.val = c9x.val;
}
t_Ersky9xSafetySwData_v11::operator SafetySwData ()
{
SafetySwData c9x;
@ -777,29 +432,6 @@ t_Ersky9xFrSkyChannelData_v10::t_Ersky9xFrSkyChannelData_v10()
memset(this, 0, sizeof(t_Ersky9xFrSkyChannelData_v10));
}
t_Ersky9xFrSkyChannelData_v10::t_Ersky9xFrSkyChannelData_v10(FrSkyChannelData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xFrSkyChannelData_v10));
ratio = c9x.ratio;
alarms_value[0] = c9x.alarms[0].value;
alarms_value[1] = c9x.alarms[1].value;
alarms_level = (c9x.alarms[1].level << 2) + c9x.alarms[0].level;
alarms_greater = (c9x.alarms[1].greater << 1) + c9x.alarms[0].greater;
if (c9x.type==0) {
if (c9x.multiplier==0) {
type = 0;
} else if (c9x.multiplier==1) {
type = 2;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this range for A1/A2") + "\n";
}
} else if (c9x.type==1 || c9x.type==3) {
type=c9x.type;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this telemetry units") + "\n";
}
}
t_Ersky9xFrSkyChannelData_v10::operator FrSkyChannelData ()
{
FrSkyChannelData c9x;
@ -824,29 +456,6 @@ t_Ersky9xFrSkyChannelData_v11::t_Ersky9xFrSkyChannelData_v11()
memset(this, 0, sizeof(t_Ersky9xFrSkyChannelData_v11));
}
t_Ersky9xFrSkyChannelData_v11::t_Ersky9xFrSkyChannelData_v11(FrSkyChannelData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xFrSkyChannelData_v11));
ratio = c9x.ratio;
alarms_value[0] = c9x.alarms[0].value;
alarms_value[1] = c9x.alarms[1].value;
alarms_level = (c9x.alarms[1].level << 2) + c9x.alarms[0].level;
alarms_greater = (c9x.alarms[1].greater << 1) + c9x.alarms[0].greater;
if (c9x.type==0) {
if (c9x.multiplier==0) {
type = 0;
} else if (c9x.multiplier==1) {
type = 2;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this range for A1/A2") + "\n";
}
} else if (c9x.type==1 || c9x.type==3) {
type=c9x.type;
} else {
EEPROMWarnings += ::QObject::tr("er9x does not support this telemetry units") + "\n";
}
}
t_Ersky9xFrSkyChannelData_v11::operator FrSkyChannelData ()
{
FrSkyChannelData c9x;
@ -871,13 +480,6 @@ t_Ersky9xFrSkyData_v10::t_Ersky9xFrSkyData_v10()
memset(this, 0, sizeof(t_Ersky9xFrSkyData_v10));
}
t_Ersky9xFrSkyData_v10::t_Ersky9xFrSkyData_v10(FrSkyData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xFrSkyData_v10));
channels[0] = c9x.channels[0];
channels[1] = c9x.channels[1];
}
t_Ersky9xFrSkyData_v10::operator FrSkyData ()
{
FrSkyData c9x;
@ -891,13 +493,6 @@ t_Ersky9xFrSkyData_v11::t_Ersky9xFrSkyData_v11()
memset(this, 0, sizeof(t_Ersky9xFrSkyData_v11));
}
t_Ersky9xFrSkyData_v11::t_Ersky9xFrSkyData_v11(FrSkyData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xFrSkyData_v11));
channels[0] = c9x.channels[0];
channels[1] = c9x.channels[1];
}
t_Ersky9xFrSkyData_v11::operator FrSkyData ()
{
FrSkyData c9x;
@ -906,168 +501,6 @@ t_Ersky9xFrSkyData_v11::operator FrSkyData ()
return c9x;
}
t_Ersky9xModelData_v10::t_Ersky9xModelData_v10(ModelData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xModelData_v10));
if (c9x.used) {
setEEPROMString(name, c9x.name, sizeof(name));
reserved_spare = 0;
spare21 = 0;
sparex = 0;
spare22 = 0;
for (int i=0; i<2; i++) {
timer[i].tmrModeA = setErSky9xTimerMode(c9x.timers[i].mode);
timer[i].tmrModeB = c9x.timers[i].modeB;
timer[i].tmrDir = c9x.timers[i].dir;
timer[i].tmrVal = c9x.timers[i].val;
}
switch(c9x.moduleData[0].protocol) {
case PPM:
protocol = 0;
break;
case PXX_DJT:
protocol = 1;
break;
case DSM2:
protocol = 2;
break;
case PPM16:
protocol = 3;
break;
default:
protocol = 0;
EEPROMWarnings += QObject::tr("Ersky9x doesn't accept this protocol") + "\n";
// TODO more explicit warning for each protocol
break;
}
traineron = c9x.traineron;
// t2throttle = c9x.t2throttle;
ppmFrameLength = c9x.moduleData[0].ppmFrameLength;
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
for (unsigned int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++)
if (c9x.funcSw[i].func == FuncInstantTrim && c9x.funcSw[i].swtch.type != SWITCH_TYPE_NONE) {
trimSw = er9xFromSwitch(c9x.funcSw[i].swtch);
break;
}
beepANACenter = (uint8_t)(c9x.beepANACenter &0x7F);
pulsePol = c9x.moduleData[0].ppmPulsePol;
extendedLimits = c9x.extendedLimits;
swashInvertELE = c9x.swashRingData.invertELE;
swashInvertAIL = c9x.swashRingData.invertAIL;
swashInvertCOL = c9x.swashRingData.invertCOL;
swashType = c9x.swashRingData.type;
swashCollectiveSource = ersky9xFromSource_v10(c9x.swashRingData.collectiveSource);
swashRingValue = c9x.swashRingData.value;
for (int i=0; i<ERSKY9X_MAX_MIXERS_V10; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V10; i++)
limitData[i] = c9x.limitData[i];
// expoData
for (unsigned int i=0; i<NUM_STICKS; i++) {
// first we find the switches
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i) {
if (c9x.expoData[e].swtch.type!=SWITCH_TYPE_NONE) {
if (!expoData[i].drSw1)
expoData[i].drSw1 = -er9xFromSwitch(c9x.expoData[e].swtch);
else if (er9xFromSwitch(c9x.expoData[e].swtch) != -expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw2 = -er9xFromSwitch(c9x.expoData[e].swtch);
}
}
}
}
if (expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw1 = -expoData[i].drSw1;
}
for (int pos=0; pos<3; pos++) {
int swtch1=0, swtch2=0;
if (expoData[i].drSw1 && !expoData[i].drSw2) {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
break;
default:
swtch1 = expoData[i].drSw1;
break;
}
}
else {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
swtch2 = -expoData[i].drSw2;
break;
default:
swtch1 = expoData[i].drSw1;
swtch2 = expoData[i].drSw2;
break;
}
}
for (int mode=0; mode<2; mode++) {
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i && !c9x.expoData[e].phases) {
if (c9x.expoData[e].swtch.type==SWITCH_TYPE_NONE || c9x.expoData[e].swtch == er9xToSwitch(swtch1) || c9x.expoData[e].swtch == er9xToSwitch(swtch2)) {
if (c9x.expoData[e].mode == 3 || (c9x.expoData[e].mode==2 && mode==0) || (c9x.expoData[e].mode==1 && mode==1)) {
expoData[i].expo[pos][0][mode] = c9x.expoData[e].expo;
expoData[i].expo[pos][1][mode] = c9x.expoData[e].weight - 100;
break;
}
}
}
}
}
}
}
for (int i=0; i<NUM_STICKS; i++)
trim[i] = std::max(-125, std::min(125, c9x.phaseData[0].trim[i]));
for (int i=0; i<ERSKY9X_MAX_CURVE5; i++)
if (c9x.curves[i].count==5) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("ErSky9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("ErSky9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<ERSKY9X_MAX_CURVE9; i++)
if (c9x.curves[i+ERSKY9X_MAX_CURVE5].count==9) {
if (c9x.curves[i+ERSKY9X_MAX_CURVE5].custom)
EEPROMWarnings += QObject::tr("ErSky9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+ERSKY9X_MAX_CURVE5) + "\n";
for (int j=0; j<9; j++)
curves9[i][j] = c9x.curves[i+ERSKY9X_MAX_CURVE5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("ErSky9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+ERSKY9X_MAX_CURVE5].count).arg(i+1+ERSKY9X_MAX_CURVE5) + "\n";
}
for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++)
customSw[i] = c9x.customSw[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V10; i++)
safetySw[i] = c9x.safetySw[i];
frsky = c9x.frsky;
FrSkyUsrProto = c9x.frsky.usrProto;
FrSkyImperial = c9x.frsky.imperial;
FrSkyGpsAlt=c9x.frsky.FrSkyGpsAlt;
}
}
t_Ersky9xModelData_v10::operator ModelData ()
{
ModelData c9x;
@ -1135,7 +568,10 @@ t_Ersky9xModelData_v10::operator ModelData ()
c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? -expoData[ch].drSw1 : (dr == 1 ? -expoData[ch].drSw2 : 0));
}
c9x.expoData[e].chn = ch;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][0];
if (expoData[ch].expo[pos][0][0]) {
c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][0];
}
c9x.expoData[e].weight = 100 + expoData[ch].expo[pos][1][0];
if (expoData[ch].expo[pos][0][0] == expoData[ch].expo[pos][0][1] && expoData[ch].expo[pos][1][0] == expoData[ch].expo[pos][1][1]) {
c9x.expoData[e++].mode = 3;
@ -1146,7 +582,10 @@ t_Ersky9xModelData_v10::operator ModelData ()
c9x.expoData[e + 1].swtch = c9x.expoData[e].swtch;
c9x.expoData[++e].chn = ch;
c9x.expoData[e].mode = 1;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][1];
if (expoData[ch].expo[pos][0][1]) {
c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][1];
}
c9x.expoData[e++].weight = 100 + expoData[ch].expo[pos][1][1];
}
}
@ -1157,7 +596,6 @@ t_Ersky9xModelData_v10::operator ModelData ()
c9x.phaseData[0].trim[i] = trim[i];
for (int i=0; i<ERSKY9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@ -1165,7 +603,6 @@ t_Ersky9xModelData_v10::operator ModelData ()
}
}
for (int i=0; i<ERSKY9X_MAX_CURVE9; i++) {
c9x.curves[ERSKY9X_MAX_CURVE5 + i].custom = false;
c9x.curves[ERSKY9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[ERSKY9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
@ -1186,180 +623,6 @@ t_Ersky9xModelData_v10::operator ModelData ()
return c9x;
}
t_Ersky9xModelData_v11::t_Ersky9xModelData_v11(ModelData &c9x)
{
memset(this, 0, sizeof(t_Ersky9xModelData_v11));
if (c9x.used) {
setEEPROMString(name, c9x.name, sizeof(name));
sparex = 0;
spare22 = 0;
version=ERSKY9X_MDVERS11;
for (int i=0; i<2; i++) {
timer[i].tmrModeA = setErSky9xTimerMode(c9x.timers[i].mode);
timer[i].tmrModeB = c9x.timers[i].modeB;
timer[i].tmrDir = c9x.timers[i].dir;
timer[i].tmrVal = c9x.timers[i].val;
}
switch(c9x.moduleData[0].protocol) {
case PPM:
protocol = 0;
break;
case PXX_DJT:
protocol = 1;
break;
case DSM2:
protocol = 2;
break;
case PPM16:
protocol = 3;
break;
default:
protocol = 0;
EEPROMWarnings += QObject::tr("Ersky9x doesn't accept this protocol") + "\n";
// TODO more explicit warning for each protocol
break;
}
traineron = c9x.traineron;
// t2throttle = c9x.t2throttle;
ppmFrameLength = c9x.moduleData[0].ppmFrameLength;
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
for (unsigned int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++)
if (c9x.funcSw[i].func == FuncInstantTrim && c9x.funcSw[i].swtch.type != SWITCH_TYPE_NONE) {
trimSw = er9xFromSwitch(c9x.funcSw[i].swtch);
break;
}
beepANACenter = (uint8_t)(c9x.beepANACenter &0x7F);
pulsePol = c9x.moduleData[0].ppmPulsePol;
extendedLimits = c9x.extendedLimits;
swashInvertELE = c9x.swashRingData.invertELE;
swashInvertAIL = c9x.swashRingData.invertAIL;
swashInvertCOL = c9x.swashRingData.invertCOL;
swashType = c9x.swashRingData.type;
swashCollectiveSource = ersky9xFromSource_v11(c9x.swashRingData.collectiveSource);
swashRingValue = c9x.swashRingData.value;
for (int i=0; i<ERSKY9X_MAX_MIXERS_V11; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++)
limitData[i] = c9x.limitData[i];
// expoData
for (unsigned int i=0; i<4; i++) {
// first we find the switches
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i) {
if (c9x.expoData[e].swtch.type!=SWITCH_TYPE_NONE) {
if (!expoData[i].drSw1)
expoData[i].drSw1 = -er9xFromSwitch(c9x.expoData[e].swtch);
else if (er9xFromSwitch(c9x.expoData[e].swtch) != -expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw2 = -er9xFromSwitch(c9x.expoData[e].swtch);
}
}
}
}
if (expoData[i].drSw1 && !expoData[i].drSw2) {
expoData[i].drSw1 = -expoData[i].drSw1;
}
for (int pos=0; pos<3; pos++) {
int swtch1=0, swtch2=0;
if (expoData[i].drSw1 && !expoData[i].drSw2) {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
break;
default:
swtch1 = expoData[i].drSw1;
break;
}
}
else {
switch (pos) {
case 0:
swtch1 = -expoData[i].drSw1;
break;
case 1:
swtch1 = expoData[i].drSw1;
swtch2 = -expoData[i].drSw2;
break;
default:
swtch1 = expoData[i].drSw1;
swtch2 = expoData[i].drSw2;
break;
}
}
for (int mode=0; mode<2; mode++) {
for (int e=0; e<C9X_MAX_EXPOS && c9x.expoData[e].mode; e++) {
if (c9x.expoData[e].chn == i && !c9x.expoData[e].phases) {
if (c9x.expoData[e].swtch.type==SWITCH_TYPE_NONE || c9x.expoData[e].swtch == er9xToSwitch(swtch1) || c9x.expoData[e].swtch == er9xToSwitch(swtch2)) {
if (c9x.expoData[e].mode == 3 || (c9x.expoData[e].mode==2 && mode==0) || (c9x.expoData[e].mode==1 && mode==1)) {
expoData[i].expo[pos][0][mode] = c9x.expoData[e].expo;
expoData[i].expo[pos][1][mode] = c9x.expoData[e].weight - 100;
break;
}
}
}
}
}
}
}
for (int i=0; i<NUM_STICKS; i++)
trim[i] = std::max(-125, std::min(125, c9x.phaseData[0].trim[i]));
for (int i=0; i<18; i++)
curvexy[i]=0;
for (int i=0; i<ERSKY9X_MAX_CURVE5; i++)
if (c9x.curves[i].count==5) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("ErSky9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("ErSky9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<ERSKY9X_MAX_CURVE9; i++)
if (c9x.curves[i+ERSKY9X_MAX_CURVE5].count==9) {
if (c9x.curves[i+ERSKY9X_MAX_CURVE5].custom)
EEPROMWarnings += QObject::tr("ErSky9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+ERSKY9X_MAX_CURVE5) + "\n";
for (int j=0; j<9; j++)
curves9[i][j] = c9x.curves[i+ERSKY9X_MAX_CURVE5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("ErSky9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+ERSKY9X_MAX_CURVE5].count).arg(i+1+ERSKY9X_MAX_CURVE5) + "\n";
}
for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++)
customSw[i] = c9x.customSw[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++)
safetySw[i] = c9x.safetySw[i];
frsky = c9x.frsky;
FrSkyUsrProto = c9x.frsky.usrProto;
FrSkyImperial = c9x.frsky.imperial;
FrSkyGpsAlt=c9x.frsky.FrSkyGpsAlt;
for (int i=0; i<8; i++) {
frskyAlarms.alarmData[i].frskyAlarmLimit=c9x.frskyalarms[i].frskyAlarmLimit;
frskyAlarms.alarmData[i].frskyAlarmSound=c9x.frskyalarms[i].frskyAlarmSound;
frskyAlarms.alarmData[i].frskyAlarmType=c9x.frskyalarms[i].frskyAlarmType;
}
for (int i=0; i<8; i++) {
customDisplayIndex[i]=c9x.customdisplay[i];
}
for (int i=0; i<5;i++) {
gvars[i].gvar=c9x.phaseData[0].gvars[i];
gvars[i].gvsource=c9x.gvsource[i];
}
}
}
t_Ersky9xModelData_v11::operator ModelData ()
{
ModelData c9x;
@ -1427,7 +690,10 @@ t_Ersky9xModelData_v11::operator ModelData ()
c9x.expoData[e].swtch = er9xToSwitch(dr == 0 ? -expoData[ch].drSw1 : (dr == 1 ? -expoData[ch].drSw2 : 0));
}
c9x.expoData[e].chn = ch;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][0];
if (expoData[ch].expo[pos][0][0]) {
c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][0];
}
c9x.expoData[e].weight = 100 + expoData[ch].expo[pos][1][0];
if (expoData[ch].expo[pos][0][0] == expoData[ch].expo[pos][0][1] && expoData[ch].expo[pos][1][0] == expoData[ch].expo[pos][1][1]) {
c9x.expoData[e++].mode = 3;
@ -1438,7 +704,10 @@ t_Ersky9xModelData_v11::operator ModelData ()
c9x.expoData[e + 1].swtch = c9x.expoData[e].swtch;
c9x.expoData[++e].chn = ch;
c9x.expoData[e].mode = 1;
c9x.expoData[e].expo = expoData[ch].expo[pos][0][1];
if (expoData[ch].expo[pos][0][1]) {
c9x.expoData[e].curve.type = CurveReference::CURVE_REF_EXPO;
c9x.expoData[e].curve.value = expoData[ch].expo[pos][0][1];
}
c9x.expoData[e++].weight = 100 + expoData[ch].expo[pos][1][1];
}
}
@ -1449,7 +718,6 @@ t_Ersky9xModelData_v11::operator ModelData ()
c9x.phaseData[0].trim[i] = trim[i];
for (int i=0; i<ERSKY9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@ -1457,7 +725,6 @@ t_Ersky9xModelData_v11::operator ModelData ()
}
}
for (int i=0; i<ERSKY9X_MAX_CURVE9; i++) {
c9x.curves[ERSKY9X_MAX_CURVE5 + i].custom = false;
c9x.curves[ERSKY9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[ERSKY9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;

View file

@ -51,8 +51,6 @@ PACK(typedef struct t_Ersky9xTrainerMix {
operator TrainerMix();
t_Ersky9xTrainerMix();
t_Ersky9xTrainerMix(TrainerMix&);
}) Ersky9xTrainerMix; //
PACK(typedef struct t_Ersky9xTrainerData {
@ -61,8 +59,6 @@ PACK(typedef struct t_Ersky9xTrainerData {
operator TrainerData();
t_Ersky9xTrainerData();
t_Ersky9xTrainerData(TrainerData&);
}) Ersky9xTrainerData;
PACK(typedef struct t_Ersky9xGeneral {
@ -122,8 +118,6 @@ PACK(typedef struct t_Ersky9xGeneral {
uint8_t rotaryDivisor ;
operator GeneralSettings();
t_Ersky9xGeneral();
t_Ersky9xGeneral(GeneralSettings&);
}) Ersky9xGeneral;
PACK(typedef struct t_Ersky9xExpoData {
@ -143,7 +137,6 @@ PACK(typedef struct t_Ersky9xLimitData {
operator LimitData();
t_Ersky9xLimitData() ;
t_Ersky9xLimitData(LimitData&);
}) Ersky9xLimitData;
#define MLTPX_ADD 0
@ -170,7 +163,6 @@ PACK(typedef struct t_Ersky9xMixData_v10 {
operator MixData();
t_Ersky9xMixData_v10();
t_Ersky9xMixData_v10(MixData&);
}) Ersky9xMixData_v10;
PACK(typedef struct t_Ersky9xMixData_v11 {
@ -192,7 +184,6 @@ PACK(typedef struct t_Ersky9xMixData_v11 {
uint8_t res[4];
operator MixData();
t_Ersky9xMixData_v11();
t_Ersky9xMixData_v11(MixData&);
}) Ersky9xMixData_v11;
PACK(typedef struct t_Ersky9xCustomSwData_v10 { // Custom Switches data
@ -202,8 +193,6 @@ PACK(typedef struct t_Ersky9xCustomSwData_v10 { // Custom Switches data
operator CustomSwData();
t_Ersky9xCustomSwData_v10() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v10)); }
t_Ersky9xCustomSwData_v10(CustomSwData&);
}) Ersky9xCustomSwData_v10;
PACK(typedef struct t_Ersky9xCustomSwData_v11 { // Custom Switches data
@ -215,8 +204,6 @@ PACK(typedef struct t_Ersky9xCustomSwData_v11 { // Custom Switches data
operator CustomSwData();
t_Ersky9xCustomSwData_v11() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v11)); }
t_Ersky9xCustomSwData_v11(CustomSwData&);
}) Ersky9xCustomSwData_v11;
PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data
@ -225,7 +212,6 @@ PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data
operator SafetySwData();
t_Ersky9xSafetySwData_v10();
t_Ersky9xSafetySwData_v10(SafetySwData&);
}) Ersky9xSafetySwData_v10;
PACK(typedef struct t_Ersky9xSafetySwData_v11 { // Custom Switches data
@ -246,7 +232,6 @@ PACK(typedef struct t_Ersky9xSafetySwData_v11 { // Custom Switches data
operator SafetySwData();
t_Ersky9xSafetySwData_v11();
t_Ersky9xSafetySwData_v11(SafetySwData&);
}) Ersky9xSafetySwData_v11;
PACK(typedef struct t_Ersky9xgvar {
@ -281,7 +266,6 @@ PACK(typedef struct t_Ersky9xFrSkyChannelData_v10 {
operator FrSkyChannelData();
t_Ersky9xFrSkyChannelData_v10();
t_Ersky9xFrSkyChannelData_v10(FrSkyChannelData&);
}) Ersky9xFrSkyChannelData_v10;
PACK(typedef struct t_Ersky9xFrSkyData_v10 {
@ -289,7 +273,6 @@ PACK(typedef struct t_Ersky9xFrSkyData_v10 {
operator FrSkyData();
t_Ersky9xFrSkyData_v10();
t_Ersky9xFrSkyData_v10(FrSkyData&);
}) Ersky9xFrSkyData_v10;
PACK(typedef struct t_Ersky9xFrSkyChannelData_v11 {
@ -303,7 +286,6 @@ PACK(typedef struct t_Ersky9xFrSkyChannelData_v11 {
operator FrSkyChannelData();
t_Ersky9xFrSkyChannelData_v11();
t_Ersky9xFrSkyChannelData_v11(FrSkyChannelData&);
}) Ersky9xFrSkyChannelData_v11;
PACK(typedef struct t_Ersky9xFrSkyData_v11 {
@ -311,7 +293,6 @@ PACK(typedef struct t_Ersky9xFrSkyData_v11 {
operator FrSkyData();
t_Ersky9xFrSkyData_v11();
t_Ersky9xFrSkyData_v11(FrSkyData&);
}) Ersky9xFrSkyData_v11;
PACK(typedef struct t_Ersky9xFrSkyalarms_v11 {
@ -390,7 +371,6 @@ PACK(typedef struct t_Ersky9xModelData_v10 {
Ersky9xTimerMode_v10 timer[2] ;
operator ModelData();
t_Ersky9xModelData_v10() { memset(this, 0, sizeof(t_Ersky9xModelData_v10)); }
t_Ersky9xModelData_v10(ModelData&);
}) Ersky9xModelData_v10;
PACK(typedef struct t_Ersky9xModelData_v11 {
@ -449,8 +429,6 @@ PACK(typedef struct t_Ersky9xModelData_v11 {
operator ModelData();
t_Ersky9xModelData_v11() { memset(this, 0, sizeof(t_Ersky9xModelData_v11)); }
t_Ersky9xModelData_v11(ModelData&);
}) Ersky9xModelData_v11;
#endif
/*eof*/

View file

@ -228,35 +228,12 @@ bool Ersky9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esi
int Ersky9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
std::cout << "NO!\n";
// TODO an error
efile->EeFsCreate(eeprom, EESIZE_SKY9X, BOARD_SKY9X);
Ersky9xGeneral ersky9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc2(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&ersky9xGeneral, sizeof(Ersky9xGeneral));
if(sz != sizeof(Ersky9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
Ersky9xModelData_v11 ersky9xModel(radioData.models[i]);
applyStickModeToModel(ersky9xModel, radioData.generalSettings.stickMode+1);
sz = efile->writeRlc2(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&ersky9xModel, sizeof(Ersky9xModelData_v11));
if(sz != sizeof(Ersky9xModelData_v11)) {
return 0;
}
}
}
if (!EEPROMWarnings.isEmpty())
QMessageBox::warning(NULL,
QObject::tr("Warning"),
QObject::tr("EEPROM saved with these warnings:") + "\n- " + EEPROMWarnings.remove(EEPROMWarnings.length()-1, 1).replace("\n", "\n- "));
return EESIZE_SKY9X;
}
int Ersky9xInterface::getSize(ModelData &model)
{
return 0;
@ -272,12 +249,6 @@ int Ersky9xInterface::getCapability(const Capability capability)
switch (capability) {
case Mixes:
return ERSKY9X_MAX_MIXERS_V11;
case NumCurves5:
return ERSKY9X_MAX_CURVE5;
case NumCurves9:
return ERSKY9X_MAX_CURVE9;
case MixFmTrim:
return 1;
case PPMExtCtrl:
return 1;
case ModelTrainerEnable:

View file

@ -6,7 +6,6 @@
#define EEPROM_VER 106
extern void setEEPROMZString(char *dst, const char *src, int size);
extern void getEEPROMZString(char *dst, const char *src, int size);
RawSwitch gruvin9xToSwitch(int8_t sw)
@ -19,18 +18,6 @@ RawSwitch gruvin9xToSwitch(int8_t sw)
return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-9 : sw+9);
}
int8_t gruvin9xFromSwitch(const RawSwitch & sw)
{
switch (sw.type) {
case SWITCH_TYPE_SWITCH:
return sw.index;
case SWITCH_TYPE_VIRTUAL:
return sw.index > 0 ? (9 + sw.index) : (-9 + sw.index);
default:
return 0;
}
}
t_Gruvin9xTrainerMix_v103::operator TrainerMix()
{
TrainerMix c9x;
@ -50,14 +37,6 @@ t_Gruvin9xTrainerMix_v104::operator TrainerMix()
return c9x;
}
t_Gruvin9xTrainerMix_v104::t_Gruvin9xTrainerMix_v104(TrainerMix &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xTrainerMix_v104));
srcChn = c9x.src;
studWeight = c9x.weight;
mode = c9x.mode;
}
t_Gruvin9xTrainerData_v103::operator TrainerData ()
{
TrainerData c9x;
@ -78,16 +57,6 @@ t_Gruvin9xTrainerData_v104::operator TrainerData ()
return c9x;
}
t_Gruvin9xTrainerData_v104::t_Gruvin9xTrainerData_v104(TrainerData &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xTrainerData_v104));
for (int i=0; i<NUM_STICKS; i++) {
calib[i] = c9x.calib[i];
mix[i] = c9x.mix[i];
}
}
Gruvin9xGeneral_v103::operator GeneralSettings ()
{
GeneralSettings result;
@ -146,59 +115,6 @@ Gruvin9xGeneral_v103::operator GeneralSettings ()
return result;
}
t_Gruvin9xGeneral_v104::t_Gruvin9xGeneral_v104(GeneralSettings &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xGeneral_v104));
myVers = EEPROM_VER;
for (int i=0; i<NUM_STICKS+BOARD_9X_NUM_POTS; i++) {
calibMid[i] = c9x.calibMid[i];
calibSpanNeg[i] = c9x.calibSpanNeg[i];
calibSpanPos[i] = c9x.calibSpanPos[i];
}
uint16_t sum = 0;
for (int i=0; i<12; i++)
sum += calibMid[i];
chkSum = sum;
currModel = c9x.currModel;
contrast = c9x.contrast;
vBatWarn = c9x.vBatWarn;
vBatCalib = c9x.vBatCalib;
if (c9x.backlightMode == 4)
lightSw = 22;
if (c9x.backlightMode & 1)
lightAutoOff = c9x.backlightDelay;
trainer = c9x.trainer;
view = c9x.view;
disableThrottleWarning = c9x.disableThrottleWarning;
if (c9x.beeperMode == e_quiet)
beeperVal = 0;
else if (c9x.beeperMode < e_all)
beeperVal = 1;
else
beeperVal = std::min(4, c9x.beeperLength + 4);
switchWarning = c9x.switchWarning;
disableMemoryWarning = c9x.disableMemoryWarning;
disableAlarmWarning = c9x.disableAlarmWarning;
stickMode = c9x.stickMode;
inactivityTimer = c9x.inactivityTimer;
minuteBeep = c9x.minuteBeep;
preBeep = c9x.preBeep;
flashBeep = c9x.flashBeep;
disableSplashScreen = c9x.splashMode;
enableTelemetryAlarm = c9x.enableTelemetryAlarm;
spare = 0;
filterInput = c9x.filterInput;
templateSetup = c9x.templateSetup;
PPM_Multiplier = c9x.PPM_Multiplier;
// TODO frskyRssiAlarms[2];
}
Gruvin9xGeneral_v104::operator GeneralSettings ()
{
GeneralSettings result;
@ -249,69 +165,11 @@ t_Gruvin9xExpoData::t_Gruvin9xExpoData()
memset(this, 0, sizeof(t_Gruvin9xExpoData));
}
t_Gruvin9xExpoData::t_Gruvin9xExpoData(ExpoData &c9x)
{
mode = c9x.mode;
chn = c9x.chn;
if (c9x.curveMode==1) {
curve = c9x.curveParam;
} else {
curve=0;
}
swtch = gruvin9xFromSwitch(c9x.swtch);
int zeros=0;
int ones=0;
int phtemp=c9x.phases;
for (int i=0; i<G9X_MAX_PHASES; i++) {
if (phtemp & 1) {
ones++;
} else {
zeros++;
}
phtemp >>=1;
}
if (zeros==G9X_MAX_PHASES || zeros==0) {
phase=0;
negPhase=0;
} else if (zeros==1) {
int phtemp=c9x.phases;
int ph=0;
for (int i=0; i<G9X_MAX_PHASES; i++) {
if ((phtemp & 1)==0) {
ph=i;
break;
}
phtemp >>=1;
}
phase=ph+1;
negPhase=0;
} else if (ones==1) {
int phtemp=c9x.phases;
int ph=0;
for (int i=0; i<G9X_MAX_PHASES; i++) {
if (phtemp & 1) {
ph=i;
break;
}
phtemp >>=1;
}
phase=(ph+1);
negPhase=1;
} else {
phase=0;
EEPROMWarnings += ::QObject::tr("Flight modes settings on expos not exported") + "\n";
}
weight = c9x.weight;
expo = c9x.expo;
}
t_Gruvin9xExpoData::operator ExpoData ()
{
ExpoData c9x;
c9x.mode = mode;
c9x.chn = chn;
c9x.curveParam = curve;
c9x.curveMode=1;
c9x.swtch = gruvin9xToSwitch(swtch);
if (negPhase) {
c9x.phases= 1 << (phase -1);
@ -322,7 +180,18 @@ t_Gruvin9xExpoData::operator ExpoData ()
c9x.phases &= ~(1 << (phase -1));
}
c9x.weight = weight;
c9x.expo = expo;
if (expo) {
c9x.curve.type = CurveReference::CURVE_REF_EXPO;
c9x.curve.value = expo;
}
else if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
return c9x;
}
@ -331,14 +200,6 @@ t_Gruvin9xLimitData::t_Gruvin9xLimitData()
memset(this, 0, sizeof(t_Gruvin9xLimitData));
}
t_Gruvin9xLimitData::t_Gruvin9xLimitData(LimitData &c9x)
{
min = c9x.min+100;
max = c9x.max-100;
revert = c9x.revert;
offset = c9x.offset;
}
t_Gruvin9xLimitData::operator LimitData ()
{
LimitData c9x;
@ -349,67 +210,11 @@ t_Gruvin9xLimitData::operator LimitData ()
return c9x;
}
t_Gruvin9xMixData::t_Gruvin9xMixData()
{
memset(this, 0, sizeof(t_Gruvin9xMixData));
}
t_Gruvin9xMixData::t_Gruvin9xMixData(MixData &c9x)
{
destCh = c9x.destCh;
mixWarn = c9x.mixWarn;
swtch = gruvin9xFromSwitch(c9x.swtch);
if (c9x.srcRaw.type == SOURCE_TYPE_NONE) {
srcRaw = 0;
swtch = 0;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_STICK) {
srcRaw = 1 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("Open9x on this board doesn't have Rotary Encoders") + "\n";
srcRaw = 5 + c9x.srcRaw.index; // use pots instead
}
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX) {
srcRaw = 8; // MAX
}
else if (c9x.srcRaw.type == SOURCE_TYPE_SWITCH) {
srcRaw = 9; // FULL
swtch = c9x.srcRaw.index+1;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CYC) {
srcRaw = 10 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM) {
srcRaw = 13 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_CH) {
srcRaw = 21 + c9x.srcRaw.index;
}
else if (c9x.srcRaw.type == SOURCE_TYPE_TRIM) {
EEPROMWarnings += ::QObject::tr("gruvin9x doesn't have trims as source") + "\n";
srcRaw = 0; // use pots instead
}
weight = c9x.weight;
curve = c9x.curve;
delayUp = c9x.delayUp;
delayDown = c9x.delayDown;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
if (c9x.carryTrim<0) {
EEPROMWarnings += ::QObject::tr("gruvin9x doesn't have swappable trims") + "\n";
carryTrim=1;
} else {
carryTrim = c9x.carryTrim;
}
mltpx = (MltpxValue)c9x.mltpx;
// phase = c9x.phase;
sOffset = c9x.sOffset;
}
t_Gruvin9xMixData::operator MixData ()
{
MixData c9x;
@ -447,7 +252,6 @@ t_Gruvin9xMixData::operator MixData ()
c9x.srcRaw = RawSource(SOURCE_TYPE_CH, srcRaw-21);
}
c9x.curve = curve;
c9x.delayUp = delayUp;
c9x.delayDown = delayDown;
c9x.speedUp = speedUp;
@ -455,36 +259,20 @@ t_Gruvin9xMixData::operator MixData ()
c9x.carryTrim = carryTrim;
c9x.mltpx = (MltpxValue)mltpx;
c9x.mixWarn = mixWarn;
// c9x.phase = phase;
c9x.sOffset = sOffset;
if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
return c9x;
}
int8_t gruvin9xFromSource(RawSource source)
{
int v1 = 0;
if (source.type == SOURCE_TYPE_STICK)
v1 = 1+source.index;
else if (source.type == SOURCE_TYPE_ROTARY_ENCODER) {
EEPROMWarnings += ::QObject::tr("gruvin9x on this board doesn't have Rotary Encoders") + "\n";
v1 = 5+source.index;
}
else if (source.type == SOURCE_TYPE_MAX)
v1 = 8;
/* else if (source.type == SOURCE_TYPE_3POS)
v1 = 0; */
else if (source.type == SOURCE_TYPE_CYC)
v1 = 10+source.index;
else if (source.type == SOURCE_TYPE_PPM)
v1 = 13+source.index;
else if (source.type == SOURCE_TYPE_CH)
v1 = 21+source.index;
else if (source.type == SOURCE_TYPE_TELEMETRY)
v1 = 36+source.index;
return v1;
}
RawSource gruvin9xToSource(int8_t value)
{
if (value == 0) {
@ -513,33 +301,6 @@ RawSource gruvin9xToSource(int8_t value)
}
}
t_Gruvin9xCustomSwData::t_Gruvin9xCustomSwData(CustomSwData &c9x)
{
func = c9x.func;
v1 = c9x.val1;
v2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
v1 = gruvin9xFromSource(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
v2 = gruvin9xFromSource(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
v1 = gruvin9xFromSwitch(RawSwitch(c9x.val1));
v2 = gruvin9xFromSwitch(RawSwitch(c9x.val2));
}
if (func>GR9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("gruvin9x does not support Custom Switch function %1").arg(getFuncName(func)) + "\n";
func=0;
v1=0;
v2=0;
}
}
Gruvin9xCustomSwData::operator CustomSwData ()
{
CustomSwData c9x;
@ -563,12 +324,6 @@ Gruvin9xCustomSwData::operator CustomSwData ()
return c9x;
}
t_Gruvin9xFuncSwData::t_Gruvin9xFuncSwData(FuncSwData &c9x)
{
swtch = gruvin9xFromSwitch(c9x.swtch);
func = c9x.func - G9X_NUM_CHNOUT;
}
Gruvin9xFuncSwData::operator FuncSwData ()
{
FuncSwData c9x;
@ -577,12 +332,6 @@ Gruvin9xFuncSwData::operator FuncSwData ()
return c9x;
}
t_Gruvin9xSafetySwData::t_Gruvin9xSafetySwData(SafetySwData &c9x)
{
swtch = gruvin9xFromSwitch(c9x.swtch);
val = c9x.val;
}
t_Gruvin9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
@ -596,16 +345,6 @@ t_Gruvin9xSwashRingData::t_Gruvin9xSwashRingData()
memset(this, 0, sizeof(t_Gruvin9xSwashRingData));
}
t_Gruvin9xSwashRingData::t_Gruvin9xSwashRingData(SwashRingData &c9x)
{
invertELE = c9x.invertELE;
invertAIL = c9x.invertAIL;
invertCOL = c9x.invertCOL;
type = c9x.type;
collectiveSource = gruvin9xFromSource(c9x.collectiveSource);
value = c9x.value;
}
t_Gruvin9xSwashRingData::operator SwashRingData ()
{
SwashRingData c9x;
@ -642,21 +381,7 @@ t_Gruvin9xPhaseData_v106::operator PhaseData ()
return c9x;
}
t_Gruvin9xPhaseData_v106::t_Gruvin9xPhaseData_v106(PhaseData &c9x)
{
trim_ext = 0;
for (int i=0; i<NUM_STICKS; i++) {
trim[i] = (int8_t)(c9x.trim[i] >> 2);
trim_ext = (trim_ext & ~(0x03 << (2*i))) + (((c9x.trim[i] & 0x03) << (2*i)));
}
swtch = gruvin9xFromSwitch(c9x.swtch);
setEEPROMZString(name, c9x.name, sizeof(name));
fadeIn = c9x.fadeIn;
fadeOut = c9x.fadeOut;
}
extern TimerMode getEr9xTimerMode(int mode);
extern int setEr9xTimerMode(TimerMode mode);
t_Gruvin9xTimerData::operator TimerData ()
{
@ -667,29 +392,11 @@ t_Gruvin9xTimerData::operator TimerData ()
return c9x;
}
t_Gruvin9xTimerData::t_Gruvin9xTimerData(TimerData &c9x)
{
mode = setEr9xTimerMode(c9x.mode);
val = c9x.val;
dir = c9x.dir;
}
t_Gruvin9xFrSkyChannelData::t_Gruvin9xFrSkyChannelData()
{
memset(this, 0, sizeof(t_Gruvin9xFrSkyChannelData));
}
t_Gruvin9xFrSkyChannelData::t_Gruvin9xFrSkyChannelData(FrSkyChannelData &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xFrSkyChannelData));
ratio = c9x.ratio;
alarms_value[0] = c9x.alarms[0].value;
alarms_value[1] = c9x.alarms[1].value;
alarms_level = (c9x.alarms[1].level << 2) + c9x.alarms[0].level;
alarms_greater = (c9x.alarms[1].greater << 1) + c9x.alarms[0].greater;
type = c9x.type;
}
t_Gruvin9xFrSkyChannelData::operator FrSkyChannelData ()
{
FrSkyChannelData c9x;
@ -704,19 +411,11 @@ t_Gruvin9xFrSkyChannelData::operator FrSkyChannelData ()
return c9x;
}
t_Gruvin9xFrSkyData::t_Gruvin9xFrSkyData()
{
memset(this, 0, sizeof(t_Gruvin9xFrSkyData));
}
t_Gruvin9xFrSkyData::t_Gruvin9xFrSkyData(FrSkyData &c9x)
{
memset(this, 0, sizeof(t_Gruvin9xFrSkyData));
channels[0] = c9x.channels[0];
channels[1] = c9x.channels[1];
}
t_Gruvin9xFrSkyData::operator FrSkyData ()
{
FrSkyData c9x;
@ -725,7 +424,6 @@ t_Gruvin9xFrSkyData::operator FrSkyData ()
return c9x;
}
t_Gruvin9xModelData_v102::operator ModelData ()
{
ModelData c9x;
@ -775,7 +473,6 @@ t_Gruvin9xModelData_v102::operator ModelData ()
c9x.expoData[i] = expoData[i];
for (int i=0; i<G9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@ -783,7 +480,6 @@ t_Gruvin9xModelData_v102::operator ModelData ()
}
}
for (int i=0; i<G9X_MAX_CURVE9; i++) {
c9x.curves[G9X_MAX_CURVE5 + i].custom = false;
c9x.curves[G9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[G9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
@ -848,7 +544,6 @@ t_Gruvin9xModelData_v103::operator ModelData ()
c9x.expoData[i] = expoData[i];
for (int i=0; i<G9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@ -856,7 +551,6 @@ t_Gruvin9xModelData_v103::operator ModelData ()
}
}
for (int i=0; i<G9X_MAX_CURVE9; i++) {
c9x.curves[G9X_MAX_CURVE5 + i].custom = false;
c9x.curves[G9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[G9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
@ -938,7 +632,6 @@ t_Gruvin9xModelData_v105::operator ModelData ()
c9x.expoData[i] = expoData[i];
for (int i=0; i<G9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@ -946,7 +639,6 @@ t_Gruvin9xModelData_v105::operator ModelData ()
}
}
for (int i=0; i<G9X_MAX_CURVE9; i++) {
c9x.curves[G9X_MAX_CURVE5 + i].custom = false;
c9x.curves[G9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[G9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
@ -1024,7 +716,6 @@ t_Gruvin9xModelData_v106::operator ModelData ()
c9x.expoData[i] = expoData[i];
for (int i=0; i<G9X_MAX_CURVE5; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 5;
for (int j = 0; j < 5; j++) {
c9x.curves[i].points[j].x = -100 + 50 * i;
@ -1032,7 +723,6 @@ t_Gruvin9xModelData_v106::operator ModelData ()
}
}
for (int i=0; i<G9X_MAX_CURVE9; i++) {
c9x.curves[G9X_MAX_CURVE5 + i].custom = false;
c9x.curves[G9X_MAX_CURVE5 + i].count = 9;
for (int j = 0; j < 9; j++) {
c9x.curves[G9X_MAX_CURVE5 + i].points[j].x = -100 + 25 * i;
@ -1052,99 +742,3 @@ t_Gruvin9xModelData_v106::operator ModelData ()
return c9x;
}
t_Gruvin9xModelData_v106::t_Gruvin9xModelData_v106(ModelData &c9x)
{
if (c9x.used) {
setEEPROMZString(name, c9x.name, sizeof(name));
timer1 = c9x.timers[0];
switch(c9x.moduleData[0].protocol) {
case PPM:
protocol = 0;
break;
case PXX_DJT:
protocol = 1;
break;
case DSM2:
protocol = 2;
break;
case SILV_A:
protocol = 3;
break;
case SILV_B:
protocol = 4;
break;
case SILV_C:
protocol = 5;
break;
case CTP1009:
protocol = 6;
break;
default:
protocol = 0;
EEPROMWarnings += QObject::tr("Er9x doesn't accept this protocol") + "\n";
// TODO more explicit warning for each protocol
break;
}
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
pulsePol = c9x.moduleData[0].ppmPulsePol;
extendedLimits = c9x.extendedLimits;
extendedTrims = c9x.extendedTrims;
spare2 = 0;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
beepANACenter = c9x.beepANACenter;
timer2 = c9x.timers[1];
for (int i=0; i<G9X_MAX_MIXERS; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++)
limitData[i] = c9x.limitData[i];
for (int i=0; i<G9X_MAX_EXPOS; i++)
expoData[i] = c9x.expoData[i];
if (c9x.expoData[G9X_MAX_EXPOS].mode)
EEPROMWarnings += QObject::tr("gruvin9x only accepts %1 expos").arg(G9X_MAX_EXPOS) + "\n";
for (int i=0; i<G9X_MAX_CURVE5; i++)
if (c9x.curves[i].count==5) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("gruvin9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("gruvin9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<G9X_MAX_CURVE9; i++)
if (c9x.curves[i+G9X_MAX_CURVE5].count==9) {
if (c9x.curves[i+G9X_MAX_CURVE5].custom)
EEPROMWarnings += QObject::tr("gruvin9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+G9X_MAX_CURVE5) + "\n";
for (int j=0; j<9; j++)
curves9[i][j] = c9x.curves[i+G9X_MAX_CURVE5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("gruvin9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+G9X_MAX_CURVE5].count).arg(i+1+G9X_MAX_CURVE5) + "\n";
}
for (int i=0; i<G9X_NUM_CSW; i++)
customSw[i] = c9x.customSw[i];
for (int i=0; i<G9X_NUM_FSW; i++)
funcSw[i] = c9x.funcSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++)
safetySw[i] = c9x.safetySw[i];
swashR = c9x.swashRingData;
for (int i=0; i<G9X_MAX_PHASES; i++) {
PhaseData phase = c9x.phaseData[i];
for (int j=0; j<NUM_STICKS; j++) {
if (phase.trimRef[j] >= 0) {
phase.trim[j] = 501 + phase.trimRef[j] - (phase.trimRef[j] >= i ? 1 : 0);
}
else {
phase.trim[j] = std::max(-500, std::min(500, phase.trim[j]));
}
}
phaseData[i] = phase;
}
frsky = c9x.frsky;
}
else {
memset(this, 0, sizeof(t_Gruvin9xModelData_v106));
}
}

View file

@ -38,8 +38,6 @@ PACK(typedef struct t_Gruvin9xTrainerMix_v104 {
operator TrainerMix();
t_Gruvin9xTrainerMix_v104() { memset(this, 0, sizeof(t_Gruvin9xTrainerMix_v104)); }
t_Gruvin9xTrainerMix_v104(TrainerMix&);
}) Gruvin9xTrainerMix_v104; //
PACK(typedef struct t_Gruvin9xTrainerData_v103 {
@ -55,8 +53,6 @@ PACK(typedef struct t_Gruvin9xTrainerData_v104 {
operator TrainerData();
t_Gruvin9xTrainerData_v104() { memset(this, 0, sizeof(t_Gruvin9xTrainerData_v104)); }
t_Gruvin9xTrainerData_v104(TrainerData&);
}) Gruvin9xTrainerData_v104;
PACK(typedef struct t_Gruvin9xFrSkyRSSIAlarm {
@ -136,8 +132,6 @@ PACK(typedef struct t_Gruvin9xGeneral_v104 {
operator GeneralSettings();
t_Gruvin9xGeneral_v104() { memset(this, 0, sizeof(t_Gruvin9xGeneral_v104)); }
t_Gruvin9xGeneral_v104(GeneralSettings&);
}) Gruvin9xGeneral_v104;
typedef Gruvin9xGeneral_v104 Gruvin9xGeneral;
@ -156,8 +150,6 @@ PACK(typedef struct t_Gruvin9xExpoData {
operator ExpoData();
t_Gruvin9xExpoData();
t_Gruvin9xExpoData(ExpoData&);
}) Gruvin9xExpoData;
PACK(typedef struct t_Gruvin9xLimitData {
@ -168,8 +160,6 @@ PACK(typedef struct t_Gruvin9xLimitData {
operator LimitData();
t_Gruvin9xLimitData();
t_Gruvin9xLimitData(LimitData&);
}) Gruvin9xLimitData;
#define MLTPX_ADD 0
@ -194,8 +184,6 @@ PACK(typedef struct t_Gruvin9xMixData {
operator MixData();
t_Gruvin9xMixData();
t_Gruvin9xMixData(MixData&);
}) Gruvin9xMixData;
PACK(typedef struct t_Gruvin9xCustomSwData { // Custom Switches data
@ -205,8 +193,6 @@ PACK(typedef struct t_Gruvin9xCustomSwData { // Custom Switches data
operator CustomSwData();
t_Gruvin9xCustomSwData() { memset(this, 0, sizeof(t_Gruvin9xCustomSwData)); }
t_Gruvin9xCustomSwData(CustomSwData&);
}) Gruvin9xCustomSwData;
PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data
@ -215,8 +201,6 @@ PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data
operator SafetySwData();
t_Gruvin9xSafetySwData() { memset(this, 0, sizeof(t_Gruvin9xSafetySwData)); }
t_Gruvin9xSafetySwData(SafetySwData&);
}) Gruvin9xSafetySwData;
PACK(typedef struct t_Gruvin9xFuncSwData { // Function Switches data
@ -225,8 +209,6 @@ PACK(typedef struct t_Gruvin9xFuncSwData { // Function Switches data
operator FuncSwData();
t_Gruvin9xFuncSwData() { memset(this, 0, sizeof(t_Gruvin9xFuncSwData)); }
t_Gruvin9xFuncSwData(FuncSwData&);
}) Gruvin9xFuncSwData;
PACK(typedef struct t_Gruvin9xFrSkyChannelData {
@ -242,8 +224,6 @@ PACK(typedef struct t_Gruvin9xFrSkyChannelData {
operator FrSkyChannelData();
t_Gruvin9xFrSkyChannelData();
t_Gruvin9xFrSkyChannelData(FrSkyChannelData&);
}) Gruvin9xFrSkyChannelData;
PACK(typedef struct t_Gruvin9xFrSkyData {
@ -251,8 +231,6 @@ PACK(typedef struct t_Gruvin9xFrSkyData {
operator FrSkyData();
t_Gruvin9xFrSkyData();
t_Gruvin9xFrSkyData(FrSkyData&);
}) Gruvin9xFrSkyData;
PACK(typedef struct t_Gruvin9xSwashRingData { // Swash Ring data
@ -265,8 +243,6 @@ PACK(typedef struct t_Gruvin9xSwashRingData { // Swash Ring data
operator SwashRingData();
t_Gruvin9xSwashRingData();
t_Gruvin9xSwashRingData(SwashRingData&);
}) Gruvin9xSwashRingData;
PACK(typedef struct t_Gruvin9xPhaseData_v102 {
@ -291,7 +267,6 @@ PACK(typedef struct t_Gruvin9xPhaseData_v106 {
operator PhaseData();
t_Gruvin9xPhaseData_v106() { memset(this, 0, sizeof(t_Gruvin9xPhaseData_v106)); }
t_Gruvin9xPhaseData_v106(PhaseData &eepe);
}) Gruvin9xPhaseData_v106;
PACK(typedef struct t_Gruvin9xTimerData {
@ -301,7 +276,6 @@ PACK(typedef struct t_Gruvin9xTimerData {
operator TimerData();
t_Gruvin9xTimerData() { memset(this, 0, sizeof(t_Gruvin9xTimerData)); }
t_Gruvin9xTimerData(TimerData &eepe);
}) Gruvin9xTimerData;
#define G9X_MAX_PHASES 5
@ -410,8 +384,6 @@ PACK(typedef struct t_Gruvin9xModelData_v105 {
operator ModelData();
t_Gruvin9xModelData_v105() { memset(this, 0, sizeof(t_Gruvin9xModelData_v105)); }
t_Gruvin9xModelData_v105(ModelData&);
}) Gruvin9xModelData_v105;
PACK(typedef struct t_Gruvin9xModelData_v106 {
@ -443,11 +415,8 @@ PACK(typedef struct t_Gruvin9xModelData_v106 {
operator ModelData();
t_Gruvin9xModelData_v106() { memset(this, 0, sizeof(t_Gruvin9xModelData_v106)); }
t_Gruvin9xModelData_v106(ModelData&);
}) Gruvin9xModelData_v106;
typedef Gruvin9xModelData_v106 Gruvin9xModelData;
#endif
/*eof*/

View file

@ -200,62 +200,20 @@ bool Gruvin9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int es
int Gruvin9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
std::cout << "NO!\n";
// TODO an error
int size = getEEpromSize();
efile->EeFsCreate(eeprom, size, BOARD_STOCK);
Gruvin9xGeneral gruvin9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc2(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&gruvin9xGeneral, sizeof(Gruvin9xGeneral));
if(sz != sizeof(Gruvin9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
ModelData model = radioData.models[i];
if (1/*version < */) {
applyStickModeToModel(model, radioData.generalSettings.stickMode+1);
}
Gruvin9xModelData gruvin9xModel(model);
sz = efile->writeRlc2(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&gruvin9xModel, sizeof(Gruvin9xModelData));
if(sz != sizeof(Gruvin9xModelData)) {
return 0;
}
}
}
return size;
}
int Gruvin9xInterface::getSize(ModelData &model)
{
if (model.isempty())
return 0;
uint8_t tmp[EESIZE_GRUVIN9X];
efile->EeFsCreate(tmp, EESIZE_GRUVIN9X, BOARD_STOCK);
Gruvin9xModelData gruvin9xModel(model);
int sz = efile->writeRlc2(0, FILE_TYP_MODEL, (uint8_t*)&gruvin9xModel, sizeof(Gruvin9xModelData));
if(sz != sizeof(Gruvin9xModelData)) {
return -1;
}
return efile->size(0);
}
int Gruvin9xInterface::getSize(GeneralSettings &settings)
{
uint8_t tmp[EESIZE_GRUVIN9X];
efile->EeFsCreate(tmp, EESIZE_GRUVIN9X, BOARD_STOCK);
Gruvin9xGeneral gruvin9xGeneral(settings);
int sz = efile->writeRlc1(0, FILE_TYP_GENERAL, (uint8_t*)&gruvin9xGeneral, sizeof(gruvin9xGeneral));
if(sz != sizeof(gruvin9xGeneral)) {
return -1;
}
return efile->size(0);
return 0;
}
int Gruvin9xInterface::getCapability(const Capability capability)
@ -263,10 +221,6 @@ int Gruvin9xInterface::getCapability(const Capability capability)
switch (capability) {
case OwnerName:
return 0;
case NumCurves5:
return G9X_MAX_CURVE5;
case NumCurves9:
return G9X_MAX_CURVE9;
case Mixes:
return G9X_MAX_MIXERS;
case FlightPhases:
@ -297,7 +251,6 @@ int Gruvin9xInterface::getCapability(const Capability capability)
return true;
case OffsetWeight:
return 125;
case HasExpoCurves:
case HasContrast:
return true;
case Telemetry:

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,6 @@ PACK(typedef struct t_Open9xGruvin9xPhaseData_v207 {
int16_t rotaryEncoders[2];
operator PhaseData();
t_Open9xGruvin9xPhaseData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xPhaseData_v207)); }
t_Open9xGruvin9xPhaseData_v207(PhaseData &eepe);
}) Open9xGruvin9xPhaseData_v207;
PACK(typedef struct t_Open9xGruvin9xPhaseData_v208 {
@ -44,7 +43,6 @@ PACK(typedef struct t_Open9xGruvin9xPhaseData_v208 {
int16_t rotaryEncoders[2];
operator PhaseData();
t_Open9xGruvin9xPhaseData_v208() { memset(this, 0, sizeof(t_Open9xGruvin9xPhaseData_v208)); }
t_Open9xGruvin9xPhaseData_v208(PhaseData &eepe);
}) Open9xGruvin9xPhaseData_v208;
PACK(typedef struct t_Open9xGruvin9xMixData_v207 {
@ -66,8 +64,6 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v207 {
operator MixData();
t_Open9xGruvin9xMixData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v207)); }
t_Open9xGruvin9xMixData_v207(MixData&);
}) Open9xGruvin9xMixData_v207;
PACK(typedef struct t_Open9xGruvin9xMixData_v209 {
@ -89,8 +85,6 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v209 {
operator MixData();
t_Open9xGruvin9xMixData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v209)); }
t_Open9xGruvin9xMixData_v209(MixData&);
}) Open9xGruvin9xMixData_v209;
PACK(typedef struct t_Open9xGruvin9xMixData_v211 {
@ -114,8 +108,6 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v211 {
operator MixData();
t_Open9xGruvin9xMixData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v211)); }
t_Open9xGruvin9xMixData_v211(MixData&);
}) Open9xGruvin9xMixData_v211;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v207 { // Custom Switches data
@ -125,10 +117,8 @@ PACK(typedef struct t_Open9xGruvin9xCustomSwData_v207 { // Custom Switches data
operator CustomSwData();
t_Open9xGruvin9xCustomSwData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v207)); }
t_Open9xGruvin9xCustomSwData_v207(CustomSwData&);
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v207;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v209 { // Custom Switches data
@ -138,10 +128,8 @@ PACK(typedef struct t_Open9xGruvin9xCustomSwData_v209 { // Custom Switches data
operator CustomSwData();
t_Open9xGruvin9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v209)); }
t_Open9xGruvin9xCustomSwData_v209(CustomSwData&);
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v209;
PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data
@ -151,8 +139,6 @@ PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data
operator FuncSwData();
t_Open9xGruvin9xFuncSwData_v203() { memset(this, 0, sizeof(t_Open9xGruvin9xFuncSwData_v203)); }
t_Open9xGruvin9xFuncSwData_v203(FuncSwData&);
}) Open9xGruvin9xFuncSwData_v203;
PACK(typedef struct t_Open9xGruvin9xFuncSwData_v210 { // Function Switches data
@ -163,8 +149,6 @@ PACK(typedef struct t_Open9xGruvin9xFuncSwData_v210 { // Function Switches data
operator FuncSwData();
t_Open9xGruvin9xFuncSwData_v210() { memset(this, 0, sizeof(t_Open9xGruvin9xFuncSwData_v210)); }
t_Open9xGruvin9xFuncSwData_v210(FuncSwData&);
}) Open9xGruvin9xFuncSwData_v210;
PACK(typedef struct t_Open9xGruvin9xSwashRingData_v208 { // Swash Ring data
@ -177,8 +161,6 @@ PACK(typedef struct t_Open9xGruvin9xSwashRingData_v208 { // Swash Ring data
operator SwashRingData();
t_Open9xGruvin9xSwashRingData_v208() { memset(this, 0, sizeof(t_Open9xGruvin9xSwashRingData_v208)); }
t_Open9xGruvin9xSwashRingData_v208(SwashRingData&);
}) Open9xGruvin9xSwashRingData_v208;
PACK(typedef struct t_Open9xGruvin9xSwashRingData_v209 { // Swash Ring data
@ -191,8 +173,6 @@ PACK(typedef struct t_Open9xGruvin9xSwashRingData_v209 { // Swash Ring data
operator SwashRingData();
t_Open9xGruvin9xSwashRingData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xSwashRingData_v209)); }
t_Open9xGruvin9xSwashRingData_v209(SwashRingData&);
}) Open9xGruvin9xSwashRingData_v209;
PACK(typedef struct t_Open9xGruvin9xModelData_v207 {
@ -227,8 +207,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v207 {
operator ModelData();
t_Open9xGruvin9xModelData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v207)); }
t_Open9xGruvin9xModelData_v207(ModelData&);
}) Open9xGruvin9xModelData_v207;
PACK(typedef struct t_Open9xGruvin9xModelData_v208 {
@ -268,8 +246,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v208 {
operator ModelData();
t_Open9xGruvin9xModelData_v208() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v208)); }
t_Open9xGruvin9xModelData_v208(ModelData&);
}) Open9xGruvin9xModelData_v208;
PACK(typedef struct t_Open9xGruvin9xModelData_v209 {
@ -310,8 +286,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v209 {
operator ModelData();
t_Open9xGruvin9xModelData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v209)); }
t_Open9xGruvin9xModelData_v209(ModelData&);
}) Open9xGruvin9xModelData_v209;
PACK(typedef struct t_Open9xGruvin9xModelData_v210 {
@ -350,8 +324,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v210 {
operator ModelData();
t_Open9xGruvin9xModelData_v210() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v210)); }
t_Open9xGruvin9xModelData_v210(ModelData&);
}) Open9xGruvin9xModelData_v210;
PACK(typedef struct t_Open9xGruvin9xModelData_v211 {
@ -388,8 +360,6 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v211 {
operator ModelData();
t_Open9xGruvin9xModelData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xModelData_v211)); }
t_Open9xGruvin9xModelData_v211(ModelData&);
}) Open9xGruvin9xModelData_v211;
#endif

File diff suppressed because it is too large Load diff

View file

@ -36,7 +36,6 @@ PACK(typedef struct t_Open9xArmTimerData_v202 {
operator TimerData();
t_Open9xArmTimerData_v202() { memset(this, 0, sizeof(t_Open9xArmTimerData_v202)); }
t_Open9xArmTimerData_v202(TimerData &eepe);
}) Open9xArmTimerData_v202;
PACK(typedef struct t_Open9xArmExpoData_v208 {
@ -50,8 +49,6 @@ PACK(typedef struct t_Open9xArmExpoData_v208 {
operator ExpoData();
t_Open9xArmExpoData_v208() { memset(this, 0, sizeof(t_Open9xArmExpoData_v208)); }
t_Open9xArmExpoData_v208(ExpoData&);
}) Open9xArmExpoData_v208;
PACK(typedef struct t_Open9xArmExpoData_v210 {
@ -67,8 +64,6 @@ PACK(typedef struct t_Open9xArmExpoData_v210 {
operator ExpoData();
t_Open9xArmExpoData_v210() { memset(this, 0, sizeof(t_Open9xArmExpoData_v210)); }
t_Open9xArmExpoData_v210(ExpoData&);
}) Open9xArmExpoData_v210;
PACK(typedef struct t_Open9xArmExpoData_v212 {
@ -83,8 +78,6 @@ PACK(typedef struct t_Open9xArmExpoData_v212 {
operator ExpoData();
t_Open9xArmExpoData_v212() { memset(this, 0, sizeof(t_Open9xArmExpoData_v212)); }
t_Open9xArmExpoData_v212(ExpoData&);
}) Open9xArmExpoData_v212;
PACK(typedef struct t_Open9xArmMixData_v208 {
@ -106,8 +99,6 @@ PACK(typedef struct t_Open9xArmMixData_v208 {
operator MixData();
t_Open9xArmMixData_v208() { memset(this, 0, sizeof(t_Open9xArmMixData_v208)); }
t_Open9xArmMixData_v208(MixData&);
}) Open9xArmMixData_v208;
PACK(typedef struct t_Open9xArmMixData_v209 {
@ -129,8 +120,6 @@ PACK(typedef struct t_Open9xArmMixData_v209 {
operator MixData();
t_Open9xArmMixData_v209() { memset(this, 0, sizeof(t_Open9xArmMixData_v209)); }
t_Open9xArmMixData_v209(MixData&);
}) Open9xArmMixData_v209;
PACK(typedef struct t_Open9xArmMixData_v210 {
@ -154,8 +143,6 @@ PACK(typedef struct t_Open9xArmMixData_v210 {
operator MixData();
t_Open9xArmMixData_v210() { memset(this, 0, sizeof(t_Open9xArmMixData_v210)); }
t_Open9xArmMixData_v210(MixData&);
}) Open9xArmMixData_v210;
PACK(typedef struct t_Open9xArmMixData_v212 {
@ -180,8 +167,6 @@ PACK(typedef struct t_Open9xArmMixData_v212 {
operator MixData();
t_Open9xArmMixData_v212() { memset(this, 0, sizeof(t_Open9xArmMixData_v212)); }
t_Open9xArmMixData_v212(MixData&);
}) Open9xArmMixData_v212;
PACK(typedef struct t_Open9xArmPhaseData_v208 {
@ -192,7 +177,6 @@ PACK(typedef struct t_Open9xArmPhaseData_v208 {
uint8_t fadeOut:4;
operator PhaseData();
t_Open9xArmPhaseData_v208() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v208)); }
t_Open9xArmPhaseData_v208(PhaseData &eepe);
}) Open9xArmPhaseData_v208;
PACK(typedef struct t_Open9xArmPhaseData_v212 {
@ -204,7 +188,6 @@ PACK(typedef struct t_Open9xArmPhaseData_v212 {
int16_t rotaryEncoders[1];
operator PhaseData();
t_Open9xArmPhaseData_v212() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v212)); }
t_Open9xArmPhaseData_v212(PhaseData &eepe);
}) Open9xArmPhaseData_v212;
PACK(typedef struct t_Open9xArmCustomSwData_v208 { // Custom Switches data
@ -214,7 +197,6 @@ PACK(typedef struct t_Open9xArmCustomSwData_v208 { // Custom Switches data
operator CustomSwData();
t_Open9xArmCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v208)); }
t_Open9xArmCustomSwData_v208(CustomSwData&);
}) Open9xArmCustomSwData_v208;
PACK(typedef struct t_Open9xArmCustomSwData_v209 { // Custom Switches data
@ -224,7 +206,6 @@ PACK(typedef struct t_Open9xArmCustomSwData_v209 { // Custom Switches data
operator CustomSwData();
t_Open9xArmCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v209)); }
t_Open9xArmCustomSwData_v209(CustomSwData&);
}) Open9xArmCustomSwData_v209;
PACK(typedef struct t_Open9xArmCustomSwData_v210 { // Custom Switches data
@ -236,7 +217,6 @@ PACK(typedef struct t_Open9xArmCustomSwData_v210 { // Custom Switches data
operator CustomSwData();
t_Open9xArmCustomSwData_v210() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v210)); }
t_Open9xArmCustomSwData_v210(CustomSwData&);
}) Open9xArmCustomSwData_v210;
PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data
@ -246,8 +226,6 @@ PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data
operator FuncSwData();
t_Open9xArmFuncSwData_v208() { memset(this, 0, sizeof(t_Open9xArmFuncSwData_v208)); }
t_Open9xArmFuncSwData_v208(FuncSwData&);
}) Open9xArmFuncSwData_v208;
PACK(typedef struct t_Open9xArmFuncSwData_v210 { // Function Switches data
@ -257,8 +235,6 @@ PACK(typedef struct t_Open9xArmFuncSwData_v210 { // Function Switches data
operator FuncSwData();
t_Open9xArmFuncSwData_v210() { memset(this, 0, sizeof(t_Open9xArmFuncSwData_v210)); }
t_Open9xArmFuncSwData_v210(FuncSwData&);
}) Open9xArmFuncSwData_v210;
PACK(typedef struct t_Open9xArmFuncSwData_v211 { // Function Switches data
@ -270,8 +246,6 @@ PACK(typedef struct t_Open9xArmFuncSwData_v211 { // Function Switches data
operator FuncSwData();
t_Open9xArmFuncSwData_v211() { memset(this, 0, sizeof(t_Open9xArmFuncSwData_v211)); }
t_Open9xArmFuncSwData_v211(FuncSwData&);
}) Open9xArmFuncSwData_v211;
PACK(typedef struct t_Open9xArmSwashRingData_v208 { // Swash Ring data
@ -284,8 +258,6 @@ PACK(typedef struct t_Open9xArmSwashRingData_v208 { // Swash Ring data
operator SwashRingData();
t_Open9xArmSwashRingData_v208() { memset(this, 0, sizeof(t_Open9xArmSwashRingData_v208)); }
t_Open9xArmSwashRingData_v208(SwashRingData&);
}) Open9xArmSwashRingData_v208;
PACK(typedef struct t_Open9xArmSwashRingData_v209 { // Swash Ring data
@ -298,8 +270,6 @@ PACK(typedef struct t_Open9xArmSwashRingData_v209 { // Swash Ring data
operator SwashRingData();
t_Open9xArmSwashRingData_v209() { memset(this, 0, sizeof(t_Open9xArmSwashRingData_v209)); }
t_Open9xArmSwashRingData_v209(SwashRingData&);
}) Open9xArmSwashRingData_v209;
PACK(typedef struct t_Open9xArmSwashRingData_v210 { // Swash Ring data
@ -312,8 +282,6 @@ PACK(typedef struct t_Open9xArmSwashRingData_v210 { // Swash Ring data
operator SwashRingData();
t_Open9xArmSwashRingData_v210() { memset(this, 0, sizeof(t_Open9xArmSwashRingData_v210)); }
t_Open9xArmSwashRingData_v210(SwashRingData&);
}) Open9xArmSwashRingData_v210;
@ -336,7 +304,6 @@ PACK(typedef struct t_Open9xArmFrSkyData_v210 {
operator FrSkyData();
t_Open9xArmFrSkyData_v210() { memset(this, 0, sizeof(t_Open9xArmFrSkyData_v210)); }
t_Open9xArmFrSkyData_v210(FrSkyData&);
}) Open9xArmFrSkyData_v210;
PACK(typedef struct t_Open9xArmFrSkyData_v211 {
@ -355,7 +322,6 @@ PACK(typedef struct t_Open9xArmFrSkyData_v211 {
operator FrSkyData();
t_Open9xArmFrSkyData_v211() { memset(this, 0, sizeof(t_Open9xArmFrSkyData_v211)); }
t_Open9xArmFrSkyData_v211(FrSkyData&);
}) Open9xArmFrSkyData_v211;
PACK(typedef struct t_Open9xArmModelData_v208 {
@ -395,8 +361,6 @@ PACK(typedef struct t_Open9xArmModelData_v208 {
operator ModelData();
t_Open9xArmModelData_v208() { memset(this, 0, sizeof(t_Open9xArmModelData_v208)); }
t_Open9xArmModelData_v208(ModelData&);
}) Open9xArmModelData_v208;
PACK(typedef struct t_Open9xArmModelData_v209 {
@ -437,8 +401,6 @@ PACK(typedef struct t_Open9xArmModelData_v209 {
operator ModelData();
t_Open9xArmModelData_v209() { memset(this, 0, sizeof(t_Open9xArmModelData_v209)); }
t_Open9xArmModelData_v209(ModelData&);
}) Open9xArmModelData_v209;
PACK(typedef struct t_Open9xArmModelData_v210 {
@ -477,7 +439,6 @@ PACK(typedef struct t_Open9xArmModelData_v210 {
operator ModelData();
t_Open9xArmModelData_v210() { memset(this, 0, sizeof(t_Open9xArmModelData_v210)); }
t_Open9xArmModelData_v210(ModelData&);
}) Open9xArmModelData_v210;
@ -517,8 +478,6 @@ PACK(typedef struct t_Open9xArmModelData_v211 {
operator ModelData();
t_Open9xArmModelData_v211() { memset(this, 0, sizeof(t_Open9xArmModelData_v211)); }
t_Open9xArmModelData_v211(ModelData&);
}) Open9xArmModelData_v211;
PACK(typedef struct t_Open9xArmModelData_v212 {
@ -555,8 +514,6 @@ PACK(typedef struct t_Open9xArmModelData_v212 {
operator ModelData();
t_Open9xArmModelData_v212() { memset(this, 0, sizeof(t_Open9xArmModelData_v212)); }
t_Open9xArmModelData_v212(ModelData&);
}) Open9xArmModelData_v212;
#endif

File diff suppressed because it is too large Load diff

View file

@ -65,7 +65,6 @@ PACK(typedef struct t_Open9xFrSkyRSSIAlarm {
int8_t value:6;
FrSkyRSSIAlarm get(int index);
t_Open9xFrSkyRSSIAlarm() { memset(this, 0, sizeof(t_Open9xFrSkyRSSIAlarm)); }
t_Open9xFrSkyRSSIAlarm(int index, FrSkyRSSIAlarm&);
}) Open9xFrSkyRSSIAlarm;
PACK(typedef struct t_Open9xExpoData_v201 {
@ -80,8 +79,6 @@ PACK(typedef struct t_Open9xExpoData_v201 {
operator ExpoData();
t_Open9xExpoData_v201() { memset(this, 0, sizeof(t_Open9xExpoData_v201)); }
t_Open9xExpoData_v201(ExpoData&);
}) Open9xExpoData_v201;
PACK(typedef struct t_Open9xExpoData_v211 {
@ -95,8 +92,6 @@ PACK(typedef struct t_Open9xExpoData_v211 {
operator ExpoData();
t_Open9xExpoData_v211() { memset(this, 0, sizeof(t_Open9xExpoData_v211)); }
t_Open9xExpoData_v211(ExpoData&);
}) Open9xExpoData_v211;
PACK(typedef struct t_Open9xLimitData_v201 {
@ -107,8 +102,6 @@ PACK(typedef struct t_Open9xLimitData_v201 {
operator LimitData();
t_Open9xLimitData_v201() { memset(this, 0, sizeof(t_Open9xLimitData_v201)); }
t_Open9xLimitData_v201(LimitData&);
}) Open9xLimitData_v201;
PACK(typedef struct t_Open9xLimitData_v211 {
@ -121,8 +114,6 @@ PACK(typedef struct t_Open9xLimitData_v211 {
operator LimitData();
t_Open9xLimitData_v211() { memset(this, 0, sizeof(t_Open9xLimitData_v211)); }
t_Open9xLimitData_v211(LimitData&);
}) Open9xLimitData_v211;
PACK(typedef struct t_Open9xMixData_v201 {
@ -143,8 +134,6 @@ PACK(typedef struct t_Open9xMixData_v201 {
operator MixData();
t_Open9xMixData_v201() { memset(this, 0, sizeof(t_Open9xMixData_v201)); }
t_Open9xMixData_v201(MixData&);
}) Open9xMixData_v201;
PACK(typedef struct t_Open9xMixData_v203 {
@ -165,8 +154,6 @@ PACK(typedef struct t_Open9xMixData_v203 {
operator MixData();
t_Open9xMixData_v203() { memset(this, 0, sizeof(t_Open9xMixData_v203)); }
t_Open9xMixData_v203(MixData&);
}) Open9xMixData_v203;
PACK(typedef struct t_Open9xMixData_v205 {
@ -188,8 +175,6 @@ PACK(typedef struct t_Open9xMixData_v205 {
operator MixData();
t_Open9xMixData_v205() { memset(this, 0, sizeof(t_Open9xMixData_v205)); }
t_Open9xMixData_v205(MixData&);
}) Open9xMixData_v205;
PACK(typedef struct t_Open9xMixData_v209 {
@ -211,8 +196,6 @@ PACK(typedef struct t_Open9xMixData_v209 {
operator MixData();
t_Open9xMixData_v209() { memset(this, 0, sizeof(t_Open9xMixData_v209)); }
t_Open9xMixData_v209(MixData&);
}) Open9xMixData_v209;
PACK(typedef struct t_Open9xMixData_v211 {
@ -236,8 +219,6 @@ PACK(typedef struct t_Open9xMixData_v211 {
operator MixData();
t_Open9xMixData_v211() { memset(this, 0, sizeof(t_Open9xMixData_v211)); }
t_Open9xMixData_v211(MixData&);
}) Open9xMixData_v211;
PACK(typedef struct t_Open9xCustomSwData_v208 { // Custom Switches data
@ -257,7 +238,6 @@ PACK(typedef struct t_Open9xCustomSwData_v209 { // Custom Switches data
operator CustomSwData();
t_Open9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xCustomSwData_v209)); }
t_Open9xCustomSwData_v209(CustomSwData&);
}) Open9xCustomSwData_v209;
PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data
@ -266,8 +246,6 @@ PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data
operator SafetySwData();
t_Open9xSafetySwData() { memset(this, 0, sizeof(t_Open9xSafetySwData)); }
t_Open9xSafetySwData(SafetySwData&);
}) Open9xSafetySwData;
PACK(typedef struct t_Open9xFuncSwData_v201 { // Function Switches data
@ -276,8 +254,6 @@ PACK(typedef struct t_Open9xFuncSwData_v201 { // Function Switches data
operator FuncSwData();
t_Open9xFuncSwData_v201() { memset(this, 0, sizeof(t_Open9xFuncSwData_v201)); }
t_Open9xFuncSwData_v201(FuncSwData&);
}) Open9xFuncSwData_v201;
PACK(typedef struct t_Open9xFuncSwData_v203 { // Function Switches data
@ -287,8 +263,6 @@ PACK(typedef struct t_Open9xFuncSwData_v203 { // Function Switches data
operator FuncSwData();
t_Open9xFuncSwData_v203() { memset(this, 0, sizeof(t_Open9xFuncSwData_v203)); }
t_Open9xFuncSwData_v203(FuncSwData&);
}) Open9xFuncSwData_v203;
PACK(typedef struct t_Open9xFuncSwData_v210 { // Function Switches data
@ -299,8 +273,6 @@ PACK(typedef struct t_Open9xFuncSwData_v210 { // Function Switches data
operator FuncSwData();
t_Open9xFuncSwData_v210() { memset(this, 0, sizeof(t_Open9xFuncSwData_v210)); }
t_Open9xFuncSwData_v210(FuncSwData&);
}) Open9xFuncSwData_v210;
PACK(typedef struct t_Open9xFrSkyChannelData_v201 {
@ -316,8 +288,6 @@ PACK(typedef struct t_Open9xFrSkyChannelData_v201 {
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v201() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v201)); }
t_Open9xFrSkyChannelData_v201(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v201;
PACK(typedef struct t_Open9xFrSkyChannelData_v203 {
@ -333,8 +303,6 @@ PACK(typedef struct t_Open9xFrSkyChannelData_v203 {
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v203() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v203)); }
t_Open9xFrSkyChannelData_v203(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v203;
PACK(typedef struct t_Open9xFrSkyChannelData_v204 {
@ -348,8 +316,6 @@ PACK(typedef struct t_Open9xFrSkyChannelData_v204 {
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v204() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v204)); }
t_Open9xFrSkyChannelData_v204(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v204;
PACK(typedef struct t_Open9xFrSkyChannelData_v208 {
@ -363,8 +329,6 @@ PACK(typedef struct t_Open9xFrSkyChannelData_v208 {
operator FrSkyChannelData();
t_Open9xFrSkyChannelData_v208() { memset(this, 0, sizeof(t_Open9xFrSkyChannelData_v208)); }
t_Open9xFrSkyChannelData_v208(FrSkyChannelData&);
}) Open9xFrSkyChannelData_v208;
PACK(typedef struct t_Open9xFrSkyData_v201 {
@ -372,7 +336,6 @@ PACK(typedef struct t_Open9xFrSkyData_v201 {
operator FrSkyData();
t_Open9xFrSkyData_v201() { memset(this, 0, sizeof(t_Open9xFrSkyData_v201)); }
}) Open9xFrSkyData_v201;
PACK(typedef struct t_Open9xFrSkyData_v202 {
@ -382,8 +345,6 @@ PACK(typedef struct t_Open9xFrSkyData_v202 {
operator FrSkyData();
t_Open9xFrSkyData_v202() { memset(this, 0, sizeof(t_Open9xFrSkyData_v202)); }
t_Open9xFrSkyData_v202(FrSkyData&);
}) Open9xFrSkyData_v202;
PACK(typedef struct t_Open9xFrSkyData_v203 {
@ -392,8 +353,6 @@ PACK(typedef struct t_Open9xFrSkyData_v203 {
operator FrSkyData();
t_Open9xFrSkyData_v203() { memset(this, 0, sizeof(t_Open9xFrSkyData_v203)); }
t_Open9xFrSkyData_v203(FrSkyData&);
}) Open9xFrSkyData_v203;
PACK(typedef struct t_Open9xFrSkyBarData_v204 {
@ -403,8 +362,6 @@ PACK(typedef struct t_Open9xFrSkyBarData_v204 {
operator FrSkyBarData();
t_Open9xFrSkyBarData_v204() { memset(this, 0, sizeof(t_Open9xFrSkyBarData_v204)); }
t_Open9xFrSkyBarData_v204(FrSkyBarData&);
}) Open9xFrSkyBarData_v204;
PACK(typedef struct t_Open9xFrSkyData_v204 {
@ -417,7 +374,6 @@ PACK(typedef struct t_Open9xFrSkyData_v204 {
operator FrSkyData();
t_Open9xFrSkyData_v204() { memset(this, 0, sizeof(t_Open9xFrSkyData_v204)); }
t_Open9xFrSkyData_v204(FrSkyData&);
}) Open9xFrSkyData_v204;
PACK(typedef struct t_Open9xFrSkyData_v205 {
@ -431,7 +387,6 @@ PACK(typedef struct t_Open9xFrSkyData_v205 {
operator FrSkyData();
t_Open9xFrSkyData_v205() { memset(this, 0, sizeof(t_Open9xFrSkyData_v205)); }
t_Open9xFrSkyData_v205(FrSkyData&);
}) Open9xFrSkyData_v205;
PACK(typedef struct t_Open9xFrSkyData_v208 {
@ -445,7 +400,6 @@ PACK(typedef struct t_Open9xFrSkyData_v208 {
operator FrSkyData();
t_Open9xFrSkyData_v208() { memset(this, 0, sizeof(t_Open9xFrSkyData_v208)); }
t_Open9xFrSkyData_v208(FrSkyData&);
}) Open9xFrSkyData_v208;
PACK(typedef struct t_Open9xFrSkyData_v210 {
@ -466,7 +420,6 @@ PACK(typedef struct t_Open9xFrSkyData_v210 {
operator FrSkyData();
t_Open9xFrSkyData_v210() { memset(this, 0, sizeof(t_Open9xFrSkyData_v210)); }
t_Open9xFrSkyData_v210(FrSkyData&);
}) Open9xFrSkyData_v210;
PACK(typedef struct t_Open9xSwashRingData_v208 { // Swash Ring data
@ -479,8 +432,6 @@ PACK(typedef struct t_Open9xSwashRingData_v208 { // Swash Ring data
operator SwashRingData();
t_Open9xSwashRingData_v208() { memset(this, 0, sizeof(t_Open9xSwashRingData_v208)); }
t_Open9xSwashRingData_v208(SwashRingData&);
}) Open9xSwashRingData_v208;
PACK(typedef struct t_Open9xSwashRingData_v209 { // Swash Ring data
@ -493,8 +444,6 @@ PACK(typedef struct t_Open9xSwashRingData_v209 { // Swash Ring data
operator SwashRingData();
t_Open9xSwashRingData_v209() { memset(this, 0, sizeof(t_Open9xSwashRingData_v209)); }
t_Open9xSwashRingData_v209(SwashRingData&);
}) Open9xSwashRingData_v209;
PACK(typedef struct t_Open9xPhaseData_v201 {
@ -507,7 +456,6 @@ PACK(typedef struct t_Open9xPhaseData_v201 {
operator PhaseData();
t_Open9xPhaseData_v201() { memset(this, 0, sizeof(t_Open9xPhaseData_v201)); }
t_Open9xPhaseData_v201(PhaseData &eepe);
}) Open9xPhaseData_v201;
PACK(typedef struct t_Open9xTimerData_v201 {
@ -526,7 +474,6 @@ PACK(typedef struct t_Open9xTimerData_v202 {
operator TimerData();
t_Open9xTimerData_v202() { memset(this, 0, sizeof(t_Open9xTimerData_v202)); }
t_Open9xTimerData_v202(TimerData &eepe);
}) Open9xTimerData_v202;
PACK(typedef struct t_Open9xTimerDataExtra {
@ -579,8 +526,6 @@ PACK(typedef struct t_Open9xModelData_v201 {
operator ModelData();
t_Open9xModelData_v201() { memset(this, 0, sizeof(t_Open9xModelData_v201)); }
t_Open9xModelData_v201(ModelData&);
}) Open9xModelData_v201;
PACK(typedef struct t_Open9xModelData_v202 {
@ -615,8 +560,6 @@ PACK(typedef struct t_Open9xModelData_v202 {
operator ModelData();
t_Open9xModelData_v202() { memset(this, 0, sizeof(t_Open9xModelData_v202)); }
t_Open9xModelData_v202(ModelData&);
}) Open9xModelData_v202;
PACK(typedef struct t_Open9xModelData_v203 {
@ -650,8 +593,6 @@ PACK(typedef struct t_Open9xModelData_v203 {
operator ModelData();
t_Open9xModelData_v203() { memset(this, 0, sizeof(t_Open9xModelData_v203)); }
t_Open9xModelData_v203(ModelData&);
}) Open9xModelData_v203;
PACK(typedef struct t_Open9xModelData_v204 {
@ -686,8 +627,6 @@ PACK(typedef struct t_Open9xModelData_v204 {
operator ModelData();
t_Open9xModelData_v204() { memset(this, 0, sizeof(t_Open9xModelData_v204)); }
t_Open9xModelData_v204(ModelData&);
}) Open9xModelData_v204;
PACK(typedef struct t_Open9xModelData_v205 {
@ -723,8 +662,6 @@ PACK(typedef struct t_Open9xModelData_v205 {
operator ModelData();
t_Open9xModelData_v205() { memset(this, 0, sizeof(t_Open9xModelData_v205)); }
t_Open9xModelData_v205(ModelData&);
}) Open9xModelData_v205;
PACK(typedef struct t_Open9xModelData_v208 {
@ -764,8 +701,6 @@ PACK(typedef struct t_Open9xModelData_v208 {
operator ModelData();
t_Open9xModelData_v208() { memset(this, 0, sizeof(t_Open9xModelData_v208)); }
t_Open9xModelData_v208(ModelData&);
}) Open9xModelData_v208;
PACK(typedef struct t_Open9xModelData_v209 {
@ -806,8 +741,6 @@ PACK(typedef struct t_Open9xModelData_v209 {
operator ModelData();
t_Open9xModelData_v209() { memset(this, 0, sizeof(t_Open9xModelData_v209)); }
t_Open9xModelData_v209(ModelData&);
}) Open9xModelData_v209;
PACK(typedef struct t_Open9xModelData_v210 {
@ -846,8 +779,6 @@ PACK(typedef struct t_Open9xModelData_v210 {
operator ModelData();
t_Open9xModelData_v210() { memset(this, 0, sizeof(t_Open9xModelData_v210)); }
t_Open9xModelData_v210(ModelData&);
}) Open9xModelData_v210;
PACK(typedef struct t_Open9xModelData_v211 {
@ -884,8 +815,6 @@ PACK(typedef struct t_Open9xModelData_v211 {
operator ModelData();
t_Open9xModelData_v211() { memset(this, 0, sizeof(t_Open9xModelData_v211)); }
t_Open9xModelData_v211(ModelData&);
}) Open9xModelData_v211;
#endif

View file

@ -14,9 +14,9 @@
*
*/
#include "open9xGruvin9xsimulator.h"
#include "open9xinterface.h"
#include "open9xeeprom.h"
#include "opentxGruvin9xsimulator.h"
#include "opentxinterface.h"
#include "opentxeeprom.h"
#define SIMU
#define SIMU_EXCEPTIONS

View file

@ -14,9 +14,9 @@
*
*/
#include "open9xM128simulator.h"
#include "open9xinterface.h"
#include "open9xeeprom.h"
#include "opentxM128simulator.h"
#include "opentxinterface.h"
#include "opentxeeprom.h"
#define SIMU
#define SIMU_EXCEPTIONS

View file

@ -14,8 +14,8 @@
*
*/
#include "open9xSky9xsimulator.h"
#include "open9xinterface.h"
#include "opentxSky9xsimulator.h"
#include "opentxinterface.h"
#define SIMU
#define SIMU_EXCEPTIONS

View file

@ -15,7 +15,7 @@
*/
#include "opentxTaranisSimulator.h"
#include "open9xinterface.h"
#include "opentxinterface.h"
#define SIMU
#define SIMU_EXCEPTIONS

View file

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <algorithm>
#include "helpers.h"
#include "open9xeeprom.h"
#include "opentxeeprom.h"
#include <QObject>
#define IS_DBLEEPROM(board, version) ((board==BOARD_GRUVIN9X || board==BOARD_M128) && version >= 213)
@ -18,10 +18,11 @@
#define MAX_PHASES(board, version) (IS_ARM(board) ? 9 : (IS_DBLRAM(board, version) ? 6 : 5))
#define MAX_MIXERS(board, version) (IS_ARM(board) ? 64 : 32)
#define MAX_CHANNELS(board, version) (IS_ARM(board) ? 32 : 16)
#define MAX_EXPOS(board, version) (IS_ARM(board) ? 32 : (IS_DBLRAM(board, version) ? 16 : 14))
#define MAX_EXPOS(board, version) (IS_ARM(board) ? ((IS_TARANIS(board) && version >= 216) ? 64 : 32) : (IS_DBLRAM(board, version) ? 16 : 14))
#define MAX_CUSTOM_SWITCHES(board, version) (IS_ARM(board) ? 32 : (IS_DBLEEPROM(board, version) ? 15 : 12))
#define MAX_CUSTOM_FUNCTIONS(board, version) (IS_ARM(board) ? 32 : (IS_DBLEEPROM(board, version) ? 24 : 16))
#define MAX_CURVES(board) (IS_ARM(board) ? O9X_ARM_MAX_CURVES : O9X_MAX_CURVES)
#define MAX_CURVES(board, version) (IS_ARM(board) ? ((IS_TARANIS(board) && version >= 216) ? 32 : 16) : O9X_MAX_CURVES)
#define MAX_GVARS(board, version) ((IS_ARM(board) && version >= 216) ? 9 : 5)
#define IS_RELEASE_21_MARCH_2013(board, version) (version >= 214 || (!IS_ARM(board) && version >= 213))
#define IS_RELEASE_23_MARCH_2013(board, version) (version >= 214 || (board==BOARD_STOCK && version >= 213))
@ -352,6 +353,15 @@ class SourceField: public ConversionField< UnsignedField<N> > {
unsigned int _source;
};
class CurveReferenceField: public StructField {
public:
CurveReferenceField(CurveReference & curve, BoardEnum board, unsigned int version)
{
Append(new UnsignedField<8>((unsigned int &)curve.type));
Append(new SignedField<8>(curve.value));
}
};
class HeliField: public StructField {
public:
HeliField(SwashRingData & heli, BoardEnum board, unsigned int version, unsigned int variant)
@ -409,7 +419,7 @@ class PhaseField: public TransformedField {
}
if (board != BOARD_STOCK && (board != BOARD_M128 || version < 215)) {
for (int i=0; i<O9X_MAX_GVARS; i++) {
for (int i=0; i<MAX_GVARS(board, version); i++) {
internalField.Append(new SignedField<16>(phase.gvars[i]));
}
}
@ -595,7 +605,25 @@ class MixField: public TransformedField {
board(board),
version(version)
{
if (IS_ARM(board)) {
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new UnsignedField<8>(_destCh));
internalField.Append(new UnsignedField<16>(mix.phases));
internalField.Append(new UnsignedField<8>((unsigned int &)mix.mltpx));
internalField.Append(new SignedField<16>(_weight));
internalField.Append(new SwitchField<8>(mix.swtch, board, version));
internalField.Append(new CurveReferenceField(mix.curve, board, version));
internalField.Append(new UnsignedField<4>(mix.mixWarn));
internalField.Append(new UnsignedField<4>(mix.srcVariant));
internalField.Append(new UnsignedField<8>(mix.delayUp));
internalField.Append(new UnsignedField<8>(mix.delayDown));
internalField.Append(new UnsignedField<8>(mix.speedUp));
internalField.Append(new UnsignedField<8>(mix.speedDown));
internalField.Append(new SourceField<8>(mix.srcRaw, board, version, FLAG_NOTELEMETRY));
internalField.Append(new SignedField<16>(_offset));
internalField.Append(new ZCharField<8>(mix.name));
internalField.Append(new SpareBitsField<8>());
}
else if (IS_ARM(board)) {
internalField.Append(new UnsignedField<8>(_destCh));
internalField.Append(new UnsignedField<16>(mix.phases));
internalField.Append(new BoolField<1>(_curveMode));
@ -680,8 +708,18 @@ class MixField: public TransformedField {
{
if (mix.destCh && mix.srcRaw.type != SOURCE_TYPE_NONE) {
_destCh = mix.destCh - 1;
_curveMode = mix.curve;
_curveParam = (mix.curve ? mix.curve : smallGvarToEEPROM(mix.differential));
if (mix.curve.type == CurveReference::CURVE_REF_CUSTOM) {
_curveMode = true;
_curveParam = 6 + mix.curve.value;
}
else if (mix.curve.type == CurveReference::CURVE_REF_FUNC) {
_curveMode = true;
_curveParam = mix.curve.value;
}
else if (mix.curve.type == CurveReference::CURVE_REF_DIFF) {
_curveMode = 0;
_curveParam = smallGvarToEEPROM(mix.curve.value);
}
}
else {
mix.clear();
@ -707,12 +745,14 @@ class MixField: public TransformedField {
{
if (mix.srcRaw.type != SOURCE_TYPE_NONE) {
mix.destCh = _destCh + 1;
mix.curve = 0;
mix.differential = 0;
if (_curveMode)
mix.curve = _curveParam;
if (!IS_ARM(board) || version < 216) {
if (!_curveMode)
mix.curve = CurveReference(CurveReference::CURVE_REF_DIFF, smallGvarToC9x(_curveParam));
else if (_curveParam > 6)
mix.curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, _curveParam-6);
else
mix.differential = smallGvarToC9x(_curveParam);
mix.curve = CurveReference(CurveReference::CURVE_REF_FUNC, _curveParam);
}
}
if (IS_ARM(board)) {
@ -748,22 +788,30 @@ class ExpoField: public TransformedField {
TransformedField(internalField),
internalField("Expo"),
expo(expo),
board(board)
board(board),
version(version)
{
if (IS_ARM(board)) {
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new SourceField<8>(expo.srcRaw, board, version, 0));
internalField.Append(new UnsignedField<16>(expo.scale));
internalField.Append(new UnsignedField<8>(expo.chn));
internalField.Append(new SwitchField<8>(expo.swtch, board, version));
internalField.Append(new UnsignedField<16>(expo.phases));
internalField.Append(new SignedField<8>(_weight));
internalField.Append(new SignedField<8>(expo.carryTrim));
internalField.Append(new ZCharField<8>(expo.name));
internalField.Append(new SignedField<8>(expo.offset));
internalField.Append(new CurveReferenceField(expo.curve, board, version));
internalField.Append(new SpareBitsField<8>());
}
else if (IS_ARM(board)) {
internalField.Append(new UnsignedField<8>(expo.mode));
internalField.Append(new UnsignedField<8>(expo.chn));
internalField.Append(new SwitchField<8>(expo.swtch, board, version));
internalField.Append(new UnsignedField<16>(expo.phases));
internalField.Append(new SignedField<8>(_weight));
internalField.Append(new BoolField<8>(_curveMode));
if (HAS_LARGE_LCD(board)) {
internalField.Append(new ZCharField<8>(expo.name));
internalField.Append(new SpareBitsField<16>());
}
else {
internalField.Append(new ZCharField<6>(expo.name));
}
internalField.Append(new SignedField<8>(_curveParam));
}
else if (IS_DBLRAM(board, version) && IS_RELEASE_23_MARCH_2013(board, version)) {
@ -789,22 +837,41 @@ class ExpoField: public TransformedField {
virtual void beforeExport()
{
_curveMode = (expo.curveMode && expo.curveParam);
_weight = smallGvarToEEPROM(expo.weight);
_curveParam = smallGvarToEEPROM(expo.curveParam);
if (!IS_TARANIS(board) || version < 216) {
if (expo.curve.type==CurveReference::CURVE_REF_FUNC && expo.curve.value) {
_curveMode = true;
_curveParam = expo.curve.value;
}
else if (expo.curve.type==CurveReference::CURVE_REF_CUSTOM && expo.curve.value) {
_curveMode = true;
_curveParam = expo.curve.value+6;
}
else {
_curveMode = false;
_curveParam = smallGvarToEEPROM(expo.curve.value);
}
}
}
virtual void afterImport()
{
expo.curveMode = _curveMode;
expo.weight = smallGvarToC9x(_weight);
expo.curveParam = smallGvarToC9x(_curveParam);
if (!IS_TARANIS(board) || version < 216) {
if (!_curveMode)
expo.curve = CurveReference(CurveReference::CURVE_REF_EXPO, smallGvarToC9x(_curveParam));
else if (_curveParam > 6)
expo.curve = CurveReference(CurveReference::CURVE_REF_CUSTOM, _curveParam-6);
else
expo.curve = CurveReference(CurveReference::CURVE_REF_FUNC, _curveParam);
}
}
protected:
StructField internalField;
ExpoData & expo;
BoardEnum board;
unsigned int version;
bool _curveMode;
int _weight;
int _curveParam;
@ -812,36 +879,55 @@ class ExpoField: public TransformedField {
class LimitField: public StructField {
public:
LimitField(LimitData & limit, BoardEnum board):
LimitField(LimitData & limit, BoardEnum board, unsigned int version):
StructField("Limit")
{
if (IS_ARM(board) && version >= 216) {
Append(new ConversionField< SignedField<16> >(limit.min, +1000));
Append(new ConversionField< SignedField<16> >(limit.max, -1000));
}
else {
Append(new ConversionField< SignedField<8> >(limit.min, +100));
Append(new ConversionField< SignedField<8> >(limit.max, -100));
}
Append(new SignedField<8>(limit.ppmCenter));
Append(new SignedField<14>(limit.offset));
Append(new BoolField<1>(limit.symetrical));
Append(new BoolField<1>(limit.revert));
if (HAS_LARGE_LCD(board))
if (HAS_LARGE_LCD(board)) {
Append(new ZCharField<6>(limit.name));
}
if (IS_TARANIS(board) && version >= 216) {
Append(new SignedField<8>(limit.curve.value));
}
}
};
class CurvesField: public TransformedField {
public:
CurvesField(CurveData * curves, BoardEnum board):
CurvesField(CurveData * curves, BoardEnum board, unsigned int version):
TransformedField(internalField),
internalField("Curves"),
curves(curves),
board(board),
maxCurves(MAX_CURVES(board)),
maxCurves(MAX_CURVES(board, version)),
maxPoints(IS_ARM(board) ? O9X_ARM_NUM_POINTS : O9X_NUM_POINTS)
{
for (int i=0; i<maxCurves; i++) {
if (IS_ARM(board))
if (IS_TARANIS(board) && version >= 216) {
internalField.Append(new UnsignedField<3>((unsigned int &)curves[i].type));
internalField.Append(new BoolField<1>(curves[i].smooth));
internalField.Append(new SpareBitsField<4>());
internalField.Append(new ConversionField< SignedField<8> >(curves[i].count, -5));
}
else if (IS_ARM(board)) {
internalField.Append(new SignedField<16>(_curves[i]));
else
}
else {
internalField.Append(new SignedField<8>(_curves[i]));
}
}
for (int i=0; i<maxPoints; i++) {
internalField.Append(new SignedField<8>(_points[i]));
}
@ -855,7 +941,7 @@ class CurvesField: public TransformedField {
int offset = 0;
for (int i=0; i<maxCurves; i++) {
CurveData *curve = &curves[i];
offset += (curve->custom ? curve->count * 2 - 2 : curve->count) - 5;
offset += (curve->type == CurveData::CURVE_TYPE_CUSTOM ? curve->count * 2 - 2 : curve->count) - 5;
if (offset > maxPoints - 5 * maxCurves) {
EEPROMWarnings += ::QObject::tr("openTx only accepts %1 points in all curves").arg(maxPoints) + "\n";
break;
@ -864,7 +950,7 @@ class CurvesField: public TransformedField {
for (int j=0; j<curve->count; j++) {
*cur++ = curve->points[j].y;
}
if (curve->custom) {
if (curve->type == CurveData::CURVE_TYPE_CUSTOM) {
for (int j=1; j<curve->count-1; j++) {
*cur++ = curve->points[j].x;
}
@ -881,15 +967,15 @@ class CurvesField: public TransformedField {
int size = next - cur;
if (size % 2 == 0) {
curve->count = (size / 2) + 1;
curve->custom = true;
curve->type = CurveData::CURVE_TYPE_CUSTOM;
}
else {
curve->count = size;
curve->custom = false;
curve->type = CurveData::CURVE_TYPE_STANDARD;
}
for (int j=0; j<curve->count; j++)
curve->points[j].y = cur[j];
if (curve->custom) {
if (curve->type == CurveData::CURVE_TYPE_CUSTOM) {
curve->points[0].x = -100;
for (int j=1; j<curve->count-1; j++)
curve->points[j].x = cur[curve->count+j-1];
@ -908,8 +994,8 @@ class CurvesField: public TransformedField {
BoardEnum board;
int maxCurves;
int maxPoints;
int _curves[O9X_ARM_MAX_CURVES];
int _points[O9X_ARM_NUM_POINTS];
int _curves[C9X_MAX_CURVES];
int _points[C9X_MAX_CURVES*C9X_MAX_POINTS*2];
};
class CustomSwitchesFunctionsTable: public ConversionTable {
@ -1551,7 +1637,14 @@ class FrskyField: public StructField {
Append(new UnsignedField<8>(frsky.channels[i].multiplier, 0, 5, "Multiplier"));
}
Append(new UnsignedField<8>(frsky.usrProto));
if (version >= 216) {
Append(new UnsignedField<7>(frsky.voltsSource));
// TODO altitude displayed
Append(new SpareBitsField<1>());
}
else {
Append(new UnsignedField<8>(frsky.voltsSource));
}
Append(new UnsignedField<8>(frsky.blades));
Append(new UnsignedField<8>(frsky.currentSource));
@ -1575,6 +1668,12 @@ class FrskyField: public StructField {
Append(new ConversionField< UnsignedField<2> >(frsky.rssiAlarms[i].level, &rssiConversionTable[i], "RSSI"));
Append(new ConversionField< SignedField<6> >(frsky.rssiAlarms[i].value, -45+i*3));
}
if (version >= 216) {
// TODO uint16_t mAhPersistent:1;
// uint16_t storedMah:15;
// int8_t fasOffset;
Append(new SpareBitsField<24>());
}
}
else {
for (int i=0; i<2; i++) {
@ -1607,6 +1706,10 @@ class FrskyField: public StructField {
Append(new SignedField<5>(frsky.varioCenterMin));
Append(new UnsignedField<3>(frsky.currentSource));
Append(new SignedField<8>(frsky.varioCenterMax));
if (version >= 216) {
// TODO int8_t fasOffset;
Append(new SpareBitsField<8>());
}
}
}
@ -1658,9 +1761,16 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
for (int i=0; i<O9X_MAX_TIMERS; i++) {
internalField.Append(new TimerModeField(modelData.timers[i].mode, board, version));
if (release21March2013) {
if ((IS_ARM(board) || IS_2560(board)) && version >= 216) {
internalField.Append(new UnsignedField<16>(modelData.timers[i].val));
internalField.Append(new BoolField<2>(modelData.timers[i].countdownBeep));
internalField.Append(new BoolField<1>(modelData.timers[i].minuteBeep));
internalField.Append(new BoolField<1>(modelData.timers[i].persistent));
internalField.Append(new SpareBitsField<4>());
internalField.Append(new SignedField<16>(modelData.timers[i].pvalue));
}
else if (release21March2013) {
internalField.Append(new UnsignedField<12>(modelData.timers[i].val));
internalField.Append(new BoolField<1>(modelData.timers[i].countdownBeep));
internalField.Append(new BoolField<1>(modelData.timers[i].minuteBeep));
if (HAS_PERSISTENT_TIMERS(board)) {
@ -1688,7 +1798,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new BoolField<1>(modelData.thrTrim));
if (IS_TARANIS(board))
if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216))
internalField.Append(new SpareBitsField<4>());
else
internalField.Append(new ConversionField< SignedField<4> >(modelData.moduleData[0].channelsCount, &channelsConversionTable, "Channels number", ::QObject::tr("OpenTX doesn't allow this number of channels")));
@ -1696,7 +1806,7 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new UnsignedField<3>(modelData.trimInc));
internalField.Append(new BoolField<1>(modelData.disableThrottleWarning));
if (IS_TARANIS(board))
if (IS_TARANIS(board) || (IS_ARM(board) && version >= 216))
internalField.Append(new SpareBitsField<1>());
else
internalField.Append(new BoolField<1>(modelData.moduleData[0].ppmPulsePol));
@ -1704,7 +1814,10 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new BoolField<1>(modelData.extendedLimits));
internalField.Append(new BoolField<1>(modelData.extendedTrims));
internalField.Append(new BoolField<1>(modelData.throttleReversed));
if (!IS_ARM(board) || version < 216) {
internalField.Append(new ConversionField< SignedField<8> >(modelData.moduleData[0].ppmDelay, exportPpmDelay, importPpmDelay));
}
if (IS_ARM(board) || board==BOARD_GRUVIN9X)
internalField.Append(new UnsignedField<16>(modelData.beepANACenter));
@ -1714,10 +1827,10 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
for (int i=0; i<MAX_MIXERS(board, version); i++)
internalField.Append(new MixField(modelData.mixData[i], board, version));
for (int i=0; i<MAX_CHANNELS(board, version); i++)
internalField.Append(new LimitField(modelData.limitData[i], board));
internalField.Append(new LimitField(modelData.limitData[i], board, version));
for (int i=0; i<MAX_EXPOS(board, version); i++)
internalField.Append(new ExpoField(modelData.expoData[i], board, version));
internalField.Append(new CurvesField(modelData.curves, board));
internalField.Append(new CurvesField(modelData.curves, board, version));
for (int i=0; i<MAX_CUSTOM_SWITCHES(board, version); i++)
internalField.Append(new CustomSwitchField(modelData.customSw[i], board, version, variant));
for (int i=0; i<MAX_CUSTOM_FUNCTIONS(board, version); i++)
@ -1725,11 +1838,16 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new HeliField(modelData.swashRingData, board, version, variant));
for (int i=0; i<MAX_PHASES(board, version); i++)
internalField.Append(new PhaseField(modelData.phaseData[i], i, board, version));
if (!IS_ARM(board) || version < 216) {
internalField.Append(new SignedField<8>(modelData.moduleData[0].ppmFrameLength));
}
internalField.Append(new UnsignedField<8>(modelData.thrTraceSrc));
if (!release21March2013)
if (!release21March2013) {
internalField.Append(new UnsignedField<8>(modelData.modelId));
}
if (IS_TARANIS(board))
internalField.Append(new UnsignedField<16>(modelData.switchWarningStates));
@ -1737,15 +1855,19 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
internalField.Append(new SwitchesWarningField<8>(modelData.switchWarningStates, board, version));
if ((board == BOARD_STOCK || (board == BOARD_M128 && version >= 215)) && (variant & GVARS_VARIANT)) {
for (int i=0; i<O9X_MAX_GVARS; i++) {
for (int i=0; i<MAX_GVARS(board, version); i++) {
// on M64 GVARS are common to all phases, and there is no name
internalField.Append(new SignedField<16>(modelData.phaseData[0].gvars[i]));
}
}
if (board != BOARD_STOCK && (board != BOARD_M128 || version < 215)) {
for (int i=0; i<O9X_MAX_GVARS; i++) {
for (int i=0; i<MAX_GVARS(board, version); i++) {
internalField.Append(new ZCharField<6>(modelData.gvars_names[i]));
if (version >= 216) {
internalField.Append(new BoolField<1>(modelData.gvars_popups[i]));
internalField.Append(new SpareBitsField<7>());
}
}
}
@ -1783,10 +1905,17 @@ Open9xModelDataNew::Open9xModelDataNew(ModelData & modelData, BoardEnum board, u
}
if (IS_TARANIS(board)) {
for (int i=0; i<MAX_CURVES(board); i++) {
for (int i=0; i<MAX_CURVES(board, version); i++) {
internalField.Append(new ZCharField<6>(modelData.curves[i].name));
}
}
if (IS_TARANIS(board) && version >= 216) {
// TODO ScriptData scriptsData[MAX_SCRIPTS];
internalField.Append(new SpareBitsField<720>());
// TODO char inputNames[MAX_INPUTS][4];
internalField.Append(new SpareBitsField<1024>());
}
}
void Open9xModelDataNew::beforeExport()

View file

@ -42,7 +42,6 @@
#define O9X_NUM_FSW 16 // number of functions assigned to switches
#define O9X_MAX_CURVES 8
#define O9X_NUM_POINTS (112-O9X_MAX_CURVES)
#define O9X_MAX_GVARS 5
#define O9X_ARM_MAX_PHASES 9
#define O9X_ARM_MAX_MIXERS 64
@ -50,7 +49,6 @@
#define O9X_ARM_NUM_CHNOUT 32 // number of real output channels CH1-CH16
#define O9X_ARM_NUM_CSW 32 // number of custom switches
#define O9X_ARM_NUM_FSW 32 // number of functions assigned to switches
#define O9X_ARM_MAX_CURVES 16
#define O9X_ARM_NUM_POINTS 512
#define O9X_ARM_MAX_CSFUNCOLD 13
#define O9X_ARM_MAX_CSFUNC 15

View file

@ -16,14 +16,14 @@
#include <iostream>
#include <QMessageBox>
#include "open9xinterface.h"
#include "open9xeeprom.h"
#include "opentxinterface.h"
#include "opentxeeprom.h"
#include "open9xGruvin9xeeprom.h"
#include "open9xSky9xeeprom.h"
#include "open9xsimulator.h"
#include "open9xM128simulator.h"
#include "open9xGruvin9xsimulator.h"
#include "open9xSky9xsimulator.h"
#include "opentxsimulator.h"
#include "opentxM128simulator.h"
#include "opentxGruvin9xsimulator.h"
#include "opentxSky9xsimulator.h"
#include "opentxTaranisSimulator.h"
#include "file.h"
@ -278,15 +278,7 @@ bool Open9xInterface::saveGeneral(GeneralSettings &settings, BoardEnum board, ui
}
template <class T>
bool Open9xInterface::saveModel(unsigned int index, ModelData &model)
{
T open9xModel(model);
int sz = efile->writeRlc2(FILE_MODEL(index), FILE_TYP_MODEL, (uint8_t*)&open9xModel, sizeof(T));
return (sz == sizeof(T));
}
template <class T>
bool Open9xInterface::saveModelVariant(unsigned int index, ModelData &model, unsigned int version, unsigned int variant)
bool Open9xInterface::saveModel(unsigned int index, ModelData &model, unsigned int version, unsigned int variant)
{
T open9xModel(model, board, version, variant);
// open9xModel.Dump();
@ -371,16 +363,16 @@ int Open9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t varian
case BOARD_TARANIS:
case BOARD_TARANIS_REV4a:
case BOARD_SKY9X:
version = 215;
version = 216;
break;
case BOARD_GRUVIN9X:
version = 214;
version = 216;
break;
case BOARD_M128:
version = 215;
version = 216;
break;
case BOARD_STOCK:
version = 213;
version = 216;
break;
}
}
@ -389,81 +381,21 @@ int Open9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t varian
efile->EeFsCreate(eeprom, size, board);
int result = 0;
if (board == BOARD_M128) {
variant |= M128_VARIANT;
}
result = saveGeneral<Open9xGeneralDataNew>(radioData.generalSettings, board, version, variant);
if (!result)
int result = saveGeneral<Open9xGeneralDataNew>(radioData.generalSettings, board, version, variant);
if (!result) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
result = 0;
switch(version) {
case 202:
result = saveModel<Open9xModelData_v202>(i, radioData.models[i]);
break;
case 203:
result = saveModel<Open9xModelData_v203>(i, radioData.models[i]);
break;
case 204:
result = saveModel<Open9xModelData_v204>(i, radioData.models[i]);
break;
case 205:
result = saveModel<Open9xModelData_v205>(i, radioData.models[i]);
break;
case 207:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v207>(i, radioData.models[i]);
break;
case 208:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v208>(i, radioData.models[i]);
else if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v208>(i, radioData.models[i]);
else
result = saveModel<Open9xModelData_v208>(i, radioData.models[i]);
break;
case 209:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v209>(i, radioData.models[i]);
else if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v209>(i, radioData.models[i]);
else
result = saveModel<Open9xModelData_v209>(i, radioData.models[i]);
break;
case 210:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v210>(i, radioData.models[i]);
else if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v210>(i, radioData.models[i]);
else
result = saveModel<Open9xModelData_v210>(i, radioData.models[i]);
break;
case 211:
if (board == BOARD_GRUVIN9X)
result = saveModel<Open9xGruvin9xModelData_v211>(i, radioData.models[i]);
else if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v211>(i, radioData.models[i]);
else
result = saveModel<Open9xModelData_v211>(i, radioData.models[i]);
break;
case 212:
if (board == BOARD_SKY9X)
result = saveModel<Open9xArmModelData_v212>(i, radioData.models[i]);
else
result = saveModelVariant<Open9xModelDataNew>(i, radioData.models[i], version, variant);
break;
default:
result = saveModelVariant<Open9xModelDataNew>(i, radioData.models[i], version, variant);
break;
result = saveModel<Open9xModelDataNew>(i, radioData.models[i], version, variant);
if (!result) {
return 0;
}
if (!result)
return false;
}
}
@ -565,13 +497,12 @@ int Open9xInterface::getCapability(const Capability capability)
case FlightPhasesHaveFades:
return 1;
case Gvars:
return 5;
return IS_ARM(board) ? 9 : 5;
case FlightModesName:
case GvarsName:
return (IS_TARANIS(board) ? 10 : 6);
case GvarsInCS:
case GvarsAsWeight:
case ExpoIsCurve:
case HasFAIMode:
return 1;
case GvarsAreNamed:
@ -667,13 +598,6 @@ int Open9xInterface::getCapability(const Capability capability)
return 0;
case ExtraInputs:
return 1;
case HasNegCurves:
return 1;
case HasExpoCurves:
return true;
case ExpoCurve5:
case ExpoCurve9:
return 4;
case ExtendedTrims:
return 500;
case ExtraTrims:
@ -684,8 +608,6 @@ int Open9xInterface::getCapability(const Capability capability)
return 1;
case FSSwitch:
return 1;
case CustomCurves:
return 1;
case MixesWithoutExpo:
return 1;
case NumCurves:
@ -732,8 +654,6 @@ int Open9xInterface::getCapability(const Capability capability)
return 1;
case TelemetryMaxMultiplier:
return (IS_ARM(board) ? 32 : 8);
case DiffMixers:
return 1;
case PPMCenter:
return 1;
case SYMLimits:

View file

@ -67,10 +67,7 @@ class Open9xInterface : public EEPROMInterface
bool loadModel(uint8_t version, ModelData &model, uint8_t *data, int index, unsigned int variant, unsigned int stickMode=0);
template <class T>
bool saveModel(unsigned int index, ModelData &model);
template <class T>
bool saveModelVariant(unsigned int index, ModelData &model, unsigned int version, unsigned int variant);
bool saveModel(unsigned int index, ModelData &model, unsigned int version, unsigned int variant);
template <class T>
bool loadGeneral(GeneralSettings &settings, unsigned int version);

View file

@ -14,9 +14,9 @@
*
*/
#include "open9xsimulator.h"
#include "open9xinterface.h"
#include "open9xeeprom.h"
#include "opentxsimulator.h"
#include "opentxinterface.h"
#include "opentxeeprom.h"
#define HELI
#define SIMU

View file

@ -29,15 +29,6 @@ t_Th9xTrainerMix::t_Th9xTrainerMix()
memset(this, 0, sizeof(t_Th9xTrainerMix));
}
t_Th9xTrainerMix::t_Th9xTrainerMix(TrainerMix &c9x)
{
memset(this, 0, sizeof(t_Th9xTrainerMix));
srcChn = c9x.src;
swtch = th9xFromSwitch(c9x.swtch);
studWeight = (8 * c9x.weight) / 25;
mode = c9x.mode;
}
t_Th9xTrainerMix::operator TrainerMix()
{
TrainerMix c9x;
@ -53,15 +44,6 @@ t_Th9xTrainerData::t_Th9xTrainerData()
memset(this, 0, sizeof(t_Th9xTrainerData));
}
t_Th9xTrainerData::t_Th9xTrainerData(TrainerData &c9x)
{
memset(this, 0, sizeof(t_Th9xTrainerData));
for (int i=0; i<NUM_STICKS; i++) {
calib[i] = c9x.calib[i];
mix[i] = c9x.mix[i];
}
}
t_Th9xTrainerData::operator TrainerData ()
{
TrainerData c9x;
@ -77,48 +59,6 @@ t_Th9xGeneral::t_Th9xGeneral()
memset(this, 0, sizeof(t_Th9xGeneral));
}
t_Th9xGeneral::t_Th9xGeneral(GeneralSettings &c9x)
{
memset(this, 0, sizeof(t_Th9xGeneral));
myVers = MDVERS;
for (int i=0; i<NUM_STICKSnPOTS; i++) {
calibMid[i] = c9x.calibMid[i];
calibSpanNeg[i] = c9x.calibSpanNeg[i];
calibSpanPos[i] = c9x.calibSpanPos[i];
}
inactivityMin = c9x.inactivityTimer;
// iTrimSwitch =
// iTrimTme1
// iTrimTme2
currModel = c9x.currModel;
contrast = c9x.contrast;
vBatWarn = c9x.vBatWarn;
vBatCalib = c9x.vBatCalib;
// lightSw = th9xFromSwitch(c9x.lightSw);
trainer = c9x.trainer;
adcFilt = c9x.filterInput;
// keySpeed
disableThrottleWarning = c9x.disableThrottleWarning;
disableSwitchWarning = (c9x.switchWarning != -1);
disableMemoryWarning = c9x.disableMemoryWarning;
if (c9x.beeperMode == e_quiet)
beeperVal = 0;
else if (c9x.beeperMode < e_all)
beeperVal = 1;
else if (c9x.beeperLength < 2)
beeperVal = 2;
else
beeperVal = 3;
view = c9x.view;
stickMode = c9x.stickMode;
// naviMode
}
Th9xGeneral::operator GeneralSettings ()
{
GeneralSettings result;
@ -167,35 +107,25 @@ t_Th9xExpoData::t_Th9xExpoData()
memset(this, 0, sizeof(t_Th9xExpoData));
}
t_Th9xExpoData::t_Th9xExpoData(ExpoData &c9x)
{
memset(this, 0, sizeof(t_Th9xLimitData));
exp5 = c9x.expo;
mode3 = c9x.mode;
weight6 = c9x.weight;
chn = c9x.chn;
drSw = th9xFromSwitch(c9x.swtch);
if (c9x.curveMode==1)
curve = c9x.curveParam;
else
curve = 0;
}
t_Th9xExpoData::operator ExpoData ()
{
ExpoData c9x;
c9x.expo = exp5;
if (exp5) {
c9x.curve.type = CurveReference::CURVE_REF_EXPO;
c9x.curve.value = exp5;
}
else if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
c9x.mode = mode3;
c9x.weight = weight6;
c9x.chn = chn;
c9x.swtch = th9xToSwitch(drSw);
if (curve) {
c9x.curveMode=1;
c9x.curveParam = curve;
} else {
c9x.curveMode = 0;
c9x.curveParam = exp5;
}
return c9x;
}
@ -204,15 +134,6 @@ t_Th9xLimitData::t_Th9xLimitData()
memset(this, 0, sizeof(t_Th9xLimitData));
}
t_Th9xLimitData::t_Th9xLimitData(LimitData &c9x)
{
memset(this, 0, sizeof(t_Th9xLimitData));
min = c9x.min+100;
max = c9x.max-100;
revert = c9x.revert;
offset = c9x.offset;
}
t_Th9xLimitData::operator LimitData ()
{
LimitData c9x;
@ -223,36 +144,11 @@ t_Th9xLimitData::operator LimitData ()
return c9x;
}
t_Th9xMixData::t_Th9xMixData()
{
memset(this, 0, sizeof(t_Th9xMixData));
}
t_Th9xMixData::t_Th9xMixData(MixData &c9x)
{
memset(this, 0, sizeof(t_Th9xMixData));
destCh = c9x.destCh;
mixMode = c9x.mltpx;
if (c9x.srcRaw.type == SOURCE_TYPE_STICK)
srcRaw = c9x.srcRaw.index;
else if (c9x.srcRaw.type == SOURCE_TYPE_MAX)
srcRaw = 10;
else if (c9x.srcRaw.type == SOURCE_TYPE_PPM)
srcRaw = 24 + c9x.srcRaw.index;
else if (c9x.srcRaw.type == SOURCE_TYPE_CH)
srcRaw = 12 + c9x.srcRaw.index;
else
srcRaw = 0; // TODO
switchMode = 1;
curveNeg = 0;
weight = c9x.weight;
swtch = th9xFromSwitch(c9x.swtch);
curve = c9x.curve;
speedUp = c9x.speedUp;
speedDown = c9x.speedDown;
}
t_Th9xMixData::operator MixData ()
{
MixData c9x;
@ -271,41 +167,20 @@ t_Th9xMixData::operator MixData ()
c9x.srcRaw = RawSource(SOURCE_TYPE_PPM, srcRaw-24);
c9x.weight = weight;
c9x.swtch = th9xToSwitch(swtch);
c9x.curve = curve;
if (curve > 6) {
c9x.curve.type = CurveReference::CURVE_REF_CUSTOM;
c9x.curve.value = curve - 6;
}
else if (curve > 0) {
c9x.curve.type = CurveReference::CURVE_REF_FUNC;
c9x.curve.value = curve;
}
c9x.speedUp = speedUp;
c9x.speedDown = speedDown;
c9x.mltpx = (MltpxValue)mixMode;
return c9x;
}
t_Th9xCustomSwData::t_Th9xCustomSwData(CustomSwData &c9x)
{
opCmp = c9x.func;
val1 = c9x.val1;
val2 = c9x.val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
val1 = fromSource(RawSource(c9x.val1));
}
if (c9x.func >= CS_FN_EQUAL) {
val2 = fromSource(RawSource(c9x.val2));
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
val1 = th9xFromSwitch(RawSwitch(c9x.val1));
val2 = th9xFromSwitch(RawSwitch(c9x.val2));
}
if (opCmp>TH9X_MAX_CSFUNC ) {
EEPROMWarnings += ::QObject::tr("th9x does not support Custom Switch function %1").arg(getFuncName(opCmp)) + "\n";
opCmp=0;
val1=0;
val2=0;
}
}
t_Th9xCustomSwData::operator CustomSwData ()
{
CustomSwData c9x;
@ -386,76 +261,6 @@ t_Th9xModelData::t_Th9xModelData()
memset(this, 0, sizeof(t_Th9xModelData));
}
t_Th9xModelData::t_Th9xModelData(ModelData &c9x)
{
memset(this, 0, sizeof(t_Th9xModelData));
if (c9x.used) {
setEEPROMString(name, c9x.name, sizeof(name));
mdVers = MDVERS;
if (c9x.timers[0].mode == TMRMODE_ABS)
tmrMode = 1;
if (c9x.timers[0].mode == TMRMODE_THs)
tmrMode = 2;
if (c9x.timers[0].mode == TMRMODE_THp)
tmrMode = 3;
else
tmrMode = 0;
// TODO tmrDir = c9x.timers[0].dir;
tmrVal = c9x.timers[0].val;
//protocol = c9x.protocol;
/*
ppmNCH = (c9x.moduleData[0].channelsCount - 8) / 2;
thrTrim = c9x.thrTrim;
thrExpo = c9x.thrExpo;
trimInc = c9x.trimInc;
ppmDelay = (c9x.moduleData[0].ppmDelay - 300) / 50;
for (unsigned int i=0; i<C9X_MAX_CUSTOM_FUNCTIONS; i++)
if (c9x.funcSw[i].func == FuncTrims2Offsets && c9x.funcSw[i].swtch) trimSw = c9x.funcSw[i].swtch;
beepANACenter = c9x.beepANACenter;
pulsePol = c9x.pulsePol;*/
for (int i=0; i<TH9X_NUM_CHNOUT; i++)
limitData[i] = c9x.limitData[i];
for (int i=0; i<TH9X_MAX_EXPOS; i++)
expoTab[i] = c9x.expoData[i];
for (int i=0; i<TH9X_MAX_MIXERS; i++)
mixData[i] = c9x.mixData[i];
for (int i=0; i<NUM_STICKS; i++)
trimData[i].itrim = std::max(-30, std::min(30, c9x.phaseData[0].trim[i]));
for (int i=0; i<TH9X_MAX_CURVES3; i++)
if (c9x.curves[i].count==3) {
if (c9x.curves[i].custom)
EEPROMWarnings += QObject::tr("th9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1) + "\n";
for (int j=0; j<3; j++)
curves3[i][j] = c9x.curves[i].points[j].y;
} else {
EEPROMWarnings += QObject::tr("th9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i].count).arg(i+1) + "\n";
}
for (int i=0; i<TH9X_MAX_CURVES5; i++)
if (c9x.curves[i+TH9X_MAX_CURVES3].count==5) {
if (c9x.curves[i+TH9X_MAX_CURVES3].custom)
EEPROMWarnings += QObject::tr("th9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+TH9X_MAX_CURVES3) + "\n";
for (int j=0; j<5; j++)
curves5[i][j] = c9x.curves[i+TH9X_MAX_CURVES3].points[j].y;
} else {
EEPROMWarnings += QObject::tr("th9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+TH9X_MAX_CURVES3].count).arg(i+1+TH9X_MAX_CURVES3) + "\n";
}
for (int i=0; i<TH9X_MAX_CURVES9; i++)
if (c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count==9) {
if (c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].custom)
EEPROMWarnings += QObject::tr("th9x doesn't support custom curves as curve%1, curve as been exported as fixed point ").arg(i+1+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5) + "\n";
for (int j=0; j<9; j++)
curves5[i][j] = c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].y;
} else {
EEPROMWarnings += QObject::tr("th9x doesn't support curve with %1 point as curve%2 ").arg(c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count).arg(i+1+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5) + "\n";
}
/*for (int i=0; i<TH9X_NUM_CSW; i++)
customSw[i] = c9x.customSw[i];*/
}
}
t_Th9xModelData::operator ModelData ()
{
ModelData c9x;
@ -505,7 +310,6 @@ t_Th9xModelData::operator ModelData ()
for (int i=0; i<NUM_STICKS; i++)
c9x.phaseData[0].trim[i] = trimData[i].itrim;
for (int i=0; i<TH9X_MAX_CURVES3; i++) {
c9x.curves[i].custom = false;
c9x.curves[i].count = 3;
for (int j=0; j<3; j++) {
c9x.curves[i].points[j].x = -100 + 100*i;
@ -513,7 +317,6 @@ t_Th9xModelData::operator ModelData ()
}
}
for (int i=0; i<TH9X_MAX_CURVES5; i++) {
c9x.curves[i+TH9X_MAX_CURVES3].custom = false;
c9x.curves[i+TH9X_MAX_CURVES3].count = 5;
for (int j=0; j<5; j++) {
c9x.curves[i+TH9X_MAX_CURVES3].points[j].x = -100 + 50*i;
@ -521,15 +324,12 @@ t_Th9xModelData::operator ModelData ()
}
}
for (int i=0; i<TH9X_MAX_CURVES9; i++) {
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].custom = false;
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].count = 5;
for (int j=0; j<9; j++) {
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].x = -100 + 50*i;
c9x.curves[i+TH9X_MAX_CURVES3+TH9X_MAX_CURVES5].points[j].y = curves9[i][j];
}
}
/*for (int i=0; i<TH9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i];*/
return c9x;
}

View file

@ -42,8 +42,6 @@ PACK(typedef struct t_Th9xTrainerMix {
operator TrainerMix();
t_Th9xTrainerMix();
t_Th9xTrainerMix(TrainerMix&);
}) Th9xTrainerMix; //
PACK(typedef struct t_Th9xTrainerData {
@ -52,8 +50,6 @@ PACK(typedef struct t_Th9xTrainerData {
operator TrainerData();
t_Th9xTrainerData();
t_Th9xTrainerData(TrainerData&);
}) Th9xTrainerData;
PACK(typedef struct t_Th9xGeneral {
@ -84,8 +80,6 @@ PACK(typedef struct t_Th9xGeneral {
operator GeneralSettings();
t_Th9xGeneral();
t_Th9xGeneral(GeneralSettings&);
}) Th9xGeneral;
/*
@ -104,7 +98,6 @@ PACK(typedef struct t_Th9xExpoData {
operator ExpoData();
t_Th9xExpoData();
t_Th9xExpoData(ExpoData&);
}) Th9xExpoData;
@ -118,7 +111,6 @@ PACK(typedef struct t_Th9xLimitData {
operator LimitData();
t_Th9xLimitData();
t_Th9xLimitData(LimitData&);
}) Th9xLimitData;
#define MLTPX_ADD 0
@ -144,7 +136,6 @@ PACK(typedef struct t_Th9xMixData {
operator MixData();
t_Th9xMixData();
t_Th9xMixData(MixData&);
}) Th9xMixData;
PACK(typedef struct t_Th9xCustomSwData {
@ -156,7 +147,6 @@ PACK(typedef struct t_Th9xCustomSwData {
operator CustomSwData();
t_Th9xCustomSwData() { memset(this, 0, sizeof(t_Th9xCustomSwData)); }
t_Th9xCustomSwData(CustomSwData &);
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Th9xCustomSwData;
@ -187,9 +177,6 @@ PACK(typedef struct t_Th9xModelData {
Th9xTrimData trimData[NUM_STICKS]; // 3*4 -> 1*4
operator ModelData();
t_Th9xModelData();
t_Th9xModelData(ModelData&);
}) Th9xModelData;
#endif
/*eof*/

View file

@ -124,56 +124,20 @@ bool Th9xInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize,
int Th9xInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t variant, uint8_t version)
{
EEPROMWarnings.clear();
std::cout << "NO!\n";
// TODO a warning
efile->EeFsCreate(eeprom, getEEpromSize(), BOARD_STOCK);
Th9xGeneral th9xGeneral(radioData.generalSettings);
int sz = efile->writeRlc2(FILE_GENERAL, FILE_TYP_GENERAL, (uint8_t*)&th9xGeneral, sizeof(Th9xGeneral));
if(sz != sizeof(Th9xGeneral)) {
return 0;
}
for (int i=0; i<getMaxModels(); i++) {
if (!radioData.models[i].isempty()) {
Th9xModelData th9xModel(radioData.models[i]);
sz = efile->writeRlc2(FILE_MODEL(i), FILE_TYP_MODEL, (uint8_t*)&th9xModel, sizeof(Th9xModelData));
if(sz != sizeof(Th9xModelData)) {
return 0;
}
}
}
return getEEpromSize();
}
int Th9xInterface::getSize(ModelData &model)
{
if (model.isempty())
return 0;
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Th9xModelData th9xModel(model);
int sz = efile->writeRlc2(0, FILE_TYP_MODEL, (uint8_t*)&th9xModel, sizeof(Th9xModelData));
if(sz != sizeof(Th9xModelData)) {
return -1;
}
return efile->size(0);
}
int Th9xInterface::getSize(GeneralSettings &settings)
{
uint8_t tmp[2*EESIZE_STOCK];
efile->EeFsCreate(tmp, getEEpromSize(), BOARD_STOCK);
Th9xGeneral th9xGeneral(settings);
int sz = efile->writeRlc2(0, FILE_TYP_GENERAL, (uint8_t*)&th9xGeneral, sizeof(Th9xGeneral));
if(sz != sizeof(th9xGeneral)) {
return -1;
}
return efile->size(0);
return 0;
}
int Th9xInterface::getCapability(const Capability capability)
@ -181,12 +145,6 @@ int Th9xInterface::getCapability(const Capability capability)
switch (capability) {
case Mixes:
return TH9X_MAX_MIXERS;
case NumCurves3:
return TH9X_MAX_CURVES3;
case NumCurves5:
return TH9X_MAX_CURVES5;
case NumCurves9:
return TH9X_MAX_CURVES9;
case OwnerName:
return 0;
case Timers:

View file

@ -480,68 +480,57 @@ void populatePhasesCB(QComboBox *b, int value)
b->setCurrentIndex(value + GetEepromInterface()->getCapability(FlightPhases));
}
void populateCurvesCB(QComboBox *b, int value)
void populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags)
{
b->clear();
int numcurves=GetEepromInterface()->getCapability(NumCurves);
if (numcurves==0) {
numcurves=16;
}
for (int i = -(numcurves)*GetEepromInterface()->getCapability(HasNegCurves); i < CURVE_BASE + numcurves; i++) {
if ((i==0) && GetEepromInterface()->getCapability(DiffMixers)) {
b->addItem(QObject::tr("Diff"));
} else {
b->addItem(getCurveStr(i));
}
}
b->setCurrentIndex(value+numcurves*GetEepromInterface()->getCapability(HasNegCurves));
b->setMaxVisibleItems(10);
}
curveTypeCB->clear();
curveTypeCB->addItem(QObject::tr("Diff"));
curveTypeCB->addItem(QObject::tr("Expo"));
curveTypeCB->addItem(QObject::tr("Func"));
curveTypeCB->addItem(QObject::tr("Curve"));
curveTypeCB->setCurrentIndex(curve.type);
void populateExpoCurvesCB(QComboBox *b, int value)
if (curve.type == CurveReference::CURVE_REF_DIFF || curve.type == CurveReference::CURVE_REF_EXPO) {
curveGVarCB->show();
if (curve.value>100 || curve.value<-100) {
curveGVarCB->setChecked(true);
populateGVCB(curveValueCB, curve.value);
curveValueCB->show();
curveValueSB->hide();
}
else {
curveGVarCB->setChecked(false);
curveValueSB->setMinimum(-100);
curveValueSB->setMaximum(100);
curveValueSB->setValue(curve.value);
curveValueSB->show();
curveValueCB->hide();
}
}
else {
curveGVarCB->hide();
curveValueSB->hide();
curveValueCB->show();
curveValueCB->setMaxVisibleItems(10);
switch (curve.type) {
case CurveReference::CURVE_REF_FUNC:
for (int i=0; i<=6/*TODO constant*/; i++) {
curveValueCB->addItem(CurveReference(CurveReference::CURVE_REF_FUNC, i).toString());
}
curveValueCB->setCurrentIndex(curve.value);
break;
case CurveReference::CURVE_REF_CUSTOM:
{
b->clear();
int numcurves = GetEepromInterface()->getCapability(NumCurves);
if (numcurves==0) {
numcurves=16;
for (int i=-numcurves; i<numcurves; i++) {
curveValueCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, i).toString());
}
if (GetEepromInterface()->getCapability(ExpoIsCurve)) {
b->addItem(QObject::tr("Expo"));
} else {
b->addItem(getCurveStr(0));
curveValueCB->setCurrentIndex(curve.value+numcurves);
break;
}
for (int i = 1; i < CURVE_BASE + numcurves; i++)
b->addItem(getCurveStr(i));
b->setCurrentIndex(value);
b->setMaxVisibleItems(10);
/* TODO
if (GetEepromInterface()->getCapability(ExpoCurve5)) {
int curve5=GetEepromInterface()->getCapability(ExpoCurve5);
for (int i=CURVE_BASE+curve5; i < CURVE_BASE + MAX_CURVE5; i++) {
// Get the index of the value to disable
QModelIndex index = b->model()->index(i, 0);
// This is the effective 'disable' flag
QVariant v(0);
//the magic
b->model()->setData(index, v, Qt::UserRole - 1);
default:
break;
}
}
if (GetEepromInterface()->getCapability(ExpoCurve9)) {
int curve9=GetEepromInterface()->getCapability(ExpoCurve9);
for (int i=CURVE_BASE+MAX_CURVE5+curve9; i < CURVE_BASE + MAX_CURVE5+ MAX_CURVE9; i++) {
// Get the index of the value to disable
QModelIndex index = b->model()->index(i, 0);
// This is the effective 'disable' flag
QVariant v(0);
//the magic
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
*/
}
void populateTrimUseCB(QComboBox *b, unsigned int phase)
@ -1017,12 +1006,6 @@ QString getSignedStr(int value)
return value > 0 ? QString("+%1").arg(value) : QString("%1").arg(value);
}
QString getCurveStr(int curve)
{
QString crvStr = "!c16!c15!c14!c13!c12!c11!c10!c9 !c8 !c7 !c6 !c5 !c4 !c3 !c2 !c1 ----x>0 x<0 |x| f>0 f<0 |f| c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16 ";
return crvStr.mid((curve+C9X_MAX_CURVES) * 4, 4).remove(' ').replace("c", QObject::tr("Curve") + " ");
}
QString getGVarString(int16_t val, bool sign)
{
if (val >= -10000 && val <= 10000)

View file

@ -42,9 +42,9 @@ void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QS
void populatePhasesCB(QComboBox *b, int value);
void populateTrimUseCB(QComboBox *b, unsigned int phase);
void populateGvarUseCB(QComboBox *b, unsigned int phase);
void populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueSB, CurveReference & curve, unsigned int flags);
void populateCurvesCB(QComboBox *b, int value);
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
void populateExpoCurvesCB(QComboBox *b, int value);
void populateTimerSwitchCB(QComboBox *b, int value);
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model);
QString getProtocolStr(const int proto);
@ -71,7 +71,6 @@ QString getCSWFunc(int val);
QString getFuncName(unsigned int val);
QString getRepeatString(unsigned int val);
QString getSignedStr(int value);
QString getCurveStr(int curve);
QString getGVarString(int16_t val, bool sign=false);
QString image2qstring(QImage image);
QImage qstring2image(QString imagestr);

View file

@ -59,7 +59,7 @@
#include "burndialog.h"
#include "hexinterface.h"
#include "warnings.h"
#include "firmwares/opentx/open9xinterface.h" // TODO get rid of this include
#include "firmwares/opentx/opentxinterface.h" // TODO get rid of this include
#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2"
#ifdef __APPLE__

View file

@ -89,6 +89,7 @@ Curves::Curves(QWidget * parent, ModelData & model):
for (int i=0; i<GetEepromInterface()->getCapability(NumCurves); i++) {
visibleCurves[i] = false;
// The reset curve button
QPushButton * reset = new QPushButton(this);
reset->setProperty("index", i);
@ -117,8 +118,6 @@ Curves::Curves(QWidget * parent, ModelData & model):
ui->curvesLayout->addWidget(plot, i, 2, 1, 1);
}
visibleCurves[0] = true;
for (int i=0; i<C9X_MAX_POINTS; i++) {
spny[i] = new QSpinBox(this);
spny[i]->setProperty("index", i);
@ -183,7 +182,7 @@ void Curves::update()
for (int i=0; i<count; i++) {
spny[i]->show();
spny[i]->setValue(model.curves[currentCurve].points[i].y);
if (model.curves[currentCurve].custom) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
spnx[i]->show();
if (i==0 || i==model.curves[currentCurve].count-1) {
spnx[i]->setDisabled(true);
@ -218,7 +217,7 @@ void Curves::setCurrentCurve(int index)
void Curves::updateCurveType()
{
int index = model.curves[currentCurve].custom;
int index = (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM ? 1 : 0);
if (model.curves[currentCurve].count==5)
index += 2;
else if (model.curves[currentCurve].count==9)
@ -256,10 +255,10 @@ void Curves::updateCurve()
int numcurves = GetEepromInterface()->getCapability(NumCurves);
for (int k=0; k<numcurves; k++) {
pen.setColor(colors[k]);
if (currentCurve!=k && visibleCurves[k]) {
if (currentCurve==k || visibleCurves[k]) {
int numpoints = model.curves[k].count;
for (int i=0; i<numpoints-1; i++) {
if (model.curves[k].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);
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);
@ -273,7 +272,7 @@ void Curves::updateCurve()
nodex = new Node();
nodex->setProperty("index", i);
nodex->setColor(colors[currentCurve]);
if (model.curves[currentCurve].custom) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
if (i>0 && i<numpoints-1) {
nodex->setFixedX(false);
nodex->setMinX(model.curves[currentCurve].points[i-1].x);
@ -339,7 +338,7 @@ void Curves::onNodeUnfocus()
void Curves::on_curvetype_CB_currentIndexChanged(int index)
{
static const int numpoint[] = {3,3,5,5,9,9,17,17};
static const bool custom[] = {false,true,false,true,false,true,false,true};
static const CurveData::CurveType types[] = {CurveData::CURVE_TYPE_STANDARD, CurveData::CURVE_TYPE_CUSTOM, CurveData::CURVE_TYPE_STANDARD, CurveData::CURVE_TYPE_CUSTOM, CurveData::CURVE_TYPE_STANDARD, CurveData::CURVE_TYPE_CUSTOM, CurveData::CURVE_TYPE_STANDARD, CurveData::CURVE_TYPE_CUSTOM};
if (!lock) {
lock = true;
@ -352,13 +351,13 @@ void Curves::on_curvetype_CB_currentIndexChanged(int index)
for (int i=0; i<numcurves; i++) {
if (i!=currentCurve) {
totalpoints += model.curves[i].count;
if (model.curves[i].custom) {
if (model.curves[i].type == CurveData::CURVE_TYPE_CUSTOM) {
totalpoints += model.curves[i].count-2;
}
}
}
totalpoints += numpoint[index];
if (custom[index]) {
if (types[index] == CurveData::CURVE_TYPE_CUSTOM) {
totalpoints += numpoint[index]-2;
}
@ -373,7 +372,7 @@ void Curves::on_curvetype_CB_currentIndexChanged(int index)
}
model.curves[currentCurve].count = numpoint[index];
model.curves[currentCurve].custom = custom[index];
model.curves[currentCurve].type = types[index];
// TODO something better!
for (int i=0; i<C9X_MAX_POINTS; i++) {
@ -461,7 +460,7 @@ void ModelEdit::on_ca_apply_PB_clicked()
a=(ui->ca_ymax_SB->value()-ui->ca_ymin_SB->value())/200.0;
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].custom) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=(model.curves[currentCurve].points[i].x+100);
} else {
x=(200.0/(numpoints-1))*i;
@ -486,7 +485,7 @@ void ModelEdit::on_ca_apply_PB_clicked()
} else if (index==1) {
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].custom) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=((model.curves[currentCurve].points[i].x)+100)/2.0;
} else {
x=(100.0/(numpoints-1))*i;
@ -518,7 +517,7 @@ void ModelEdit::on_ca_apply_PB_clicked()
} else if (index==2) {
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].custom) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=(model.curves[currentCurve].points[i].x);
} else {
x=-100.0+(200.0/(numpoints-1))*i;
@ -560,7 +559,7 @@ void ModelEdit::on_ca_apply_PB_clicked()
} else if (index==3) {
int numpoints=model.curves[currentCurve].count;
for (int i=0; i<numpoints; i++) {
if (model.curves[currentCurve].custom) {
if (model.curves[currentCurve].type == CurveData::CURVE_TYPE_CUSTOM) {
x=(model.curves[currentCurve].points[i].x);
} else {
x=-100.0+(200.0/(numpoints-1))*i;
@ -606,49 +605,6 @@ void ModelEdit::clearCurves(bool ask)
if(res!=QMessageBox::Yes) return;
}
curvesLock=true;
if (!GetEepromInterface()->getCapability(CustomCurves)){
ui->curvetype_CB->setDisabled(true);
int count=0;
for (int j=0; j< GetEepromInterface()->getCapability(NumCurves3); j++) {
model.curves[count].count=3;
model.curves[count].custom=false;
memset(model.curves[j].name,0,sizeof(model.curves[j].name));
for (int i=0; i<17; i++) {
model.curves[count].points[i].x=0;
model.curves[count].points[i].y=0;
}
count++;
}
for (int j=0; j< GetEepromInterface()->getCapability(NumCurves5); j++) {
model.curves[count].count=5;
model.curves[count].custom=false;
memset(model.curves[j].name,0,sizeof(model.curves[j].name));
for (int i=0; i<17; i++) {
model.curves[count].points[i].x=0;
model.curves[count].points[i].y=0;
}
count++;
}
for (int j=0; j< GetEepromInterface()->getCapability(NumCurves9); j++) {
model.curves[count].count=9;
model.curves[count].custom=false;
memset(model.curves[j].name,0,sizeof(model.curves[j].name));
for (int i=0; i<17; i++) {
model.curves[count].points[i].x=0;
model.curves[count].points[i].y=0;
}
count++;
}
for (int j=count; j<16; j++) {
model.curves[j].count=5;
model.curves[j].custom=false;
memset(model.curves[j].name,0,sizeof(model.curves[j].name));
for (int i=0; i<17; i++) {
model.curves[j].points[i].x=0;
model.curves[j].points[i].y=0;
}
}
} else {
for (int j=0; j<16; j++) {
model.curves[j].count = 5;
model.curves[j].custom = false;
@ -658,7 +614,6 @@ void ModelEdit::clearCurves(bool ask)
model.curves[j].points[i].y = 0;
}
}
}
for (int i=0; i<17; i++) {
spnx[i]->setMinimum(-100);
spnx[i]->setMaximum(100);
@ -667,11 +622,7 @@ void ModelEdit::clearCurves(bool ask)
}
currentCurve=0;
curvesLock=false;
if (GetEepromInterface()->getCapability(NumCurves3)>0) {
ui->curvetype_CB->setCurrentIndex(0);
} else {
ui->curvetype_CB->setCurrentIndex(2);
}
ui->cname_LE->clear();
updateSettings();
drawCurve();

View file

@ -28,19 +28,24 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
ui->expoGV->setDisabled(true);
ui->weightGV->setDisabled(true);
ui->expoCurveGV->setDisabled(true);
/* TODO
if (ed->expo>100) {
ed->expo=0;
}
*/
if (ed->weight>100 || ed->weight<-100) {
ed->weight=100;
}
/* TODO
if (ed->curveParam>100 || ed->curveParam<-100) {
ed->curveParam=0;
}
*/
}
populateGVCB(ui->expoCB,ed->expo);
// TODO populateGVCB(ui->expoCB, ed->expo);
populateGVCB(ui->weightCB, ed->weight);
populateGVCB(ui->expoCurveCB,ed->curveParam);
// TODO populateGVCB(ui->expoCurveCB, ed->curveParam);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
@ -54,14 +59,15 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
ui->weightSB->show();
ui->weightCB->hide();
}
/* TODO
ui->expoSB->setMinimum(-100);
ui->expoSB->setMaximum(100);
if (ed->expo>100 || ed->expo<-100) {
ui->expoGV->setChecked(true);
ui->expoSB->hide();
ui->expoCB->show();
} else {
}
else {
ui->expoGV->setChecked(false);
ui->expoSB->setValue(ed->expo);
ui->expoSB->show();
@ -74,49 +80,45 @@ ExpoDialog::ExpoDialog(QWidget *parent, ExpoData *expoData, int stickMode) :
ui->expoCurveGV->setChecked(true);
ui->expoCurveSB->hide();
ui->expoCurveCB->show();
} else {
}
else {
ui->expoCurveGV->setChecked(false);
ui->expoCurveSB->setValue(ed->curveParam);
ui->expoCurveSB->show();
ui->expoCurveCB->hide();
}
} else {
ui->expoGV->hide();
*/
}
else {
// TODO ui->expoGV->hide();
ui->weightGV->hide();
ui->expoCurveGV->hide();
ui->expoSB->setMinimum(-100);
ui->expoSB->setMaximum(100);
ui->expoSB->setValue(ed->expo);
ui->expoCurveSB->setMinimum(-100);
ui->expoCurveSB->setMaximum(100);
ui->expoCurveSB->setValue(ed->curveParam);
// TODO ui->expoCurveGV->hide();
// TODO ui->expoSB->setMinimum(-100);
// TODO ui->expoSB->setMaximum(100);
// TODO ui->expoSB->setValue(ed->expo);
// TODO ui->expoCurveSB->setMinimum(-100);
// TODO ui->expoCurveSB->setMaximum(100);
// TODO ui->expoCurveSB->setValue(ed->curveParam);
ui->weightSB->setMinimum(0);
ui->weightSB->setMaximum(100);
ui->weightSB->setValue(ed->weight);
}
populateSwitchCB(ui->switchesCB,ed->swtch);
if (ed->curveMode==0) {
/* if (ed->curveMode==0) {
populateExpoCurvesCB(ui->curvesCB,0); // TODO capacity for er9x
} else {
}
else {
populateExpoCurvesCB(ui->curvesCB,ed->curveParam); // TODO capacity for er9x
}
*/
ui->modeCB->setCurrentIndex(ed->mode-1);
if (!GetEepromInterface()->getCapability(HasExpoCurves)) {
ui->label_curves->hide();
ui->curvesCB->hide();
ed->curveMode=1;
}
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();
ui->label_curves->setText(tr("Curve"));
} else {
ui->label_expo->hide();
ui->expoCB->hide();
ui->expoGV->hide();
ui->expoSB->hide();
}
// TODO ui->expoCB->hide();
// TODO ui->expoGV->hide();
// TODO ui->expoSB->hide();
if (!GetEepromInterface()->getCapability(FlightPhases)) {
ui->label_phases->hide();
for (int i=0; i<9; i++) {
@ -194,15 +196,6 @@ void ExpoDialog::widgetChanged()
gvars=1;
}
if (gvars==1) {
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
if (ui->expoGV->isChecked()) {
ui->expoCB->show();
ui->expoSB->hide();
} else {
ui->expoCB->hide();
ui->expoSB->show();
}
} else {
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
@ -210,7 +203,6 @@ void ExpoDialog::widgetChanged()
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
}
}
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
@ -229,45 +221,24 @@ void ExpoDialog::valuesChanged()
{
QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };
if (ui->curvesCB->currentIndex()==0) {
if (GetEepromInterface()->getCapability(ExpoIsCurve)) {
ed->curveMode = 0;
// TODO ed->curveMode = 0;
ui->expoCurveGV->show();
if (ui->expoCurveGV->isChecked()) {
ui->expoCurveCB->show();
ui->expoCurveSB->hide();
ed->curveParam = ui->expoCurveCB->itemData(ui->expoCurveCB->currentIndex()).toInt();
} else {
// TODO ed->curveParam = ui->expoCurveCB->itemData(ui->expoCurveCB->currentIndex()).toInt();
}
else {
ui->expoCurveCB->hide();
ui->expoCurveSB->show();
ed->curveParam = ui->expoCurveSB->value();
// TODO ed->curveParam = ui->expoCurveSB->value();
}
ed->expo = ed->curveParam;
} else {
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();
ed->curveMode = 0;
if (ui->expoGV->isChecked()) {
ed->expo = ui->expoCB->itemData(ui->expoCB->currentIndex()).toInt();
} else {
ed->expo = ui->expoSB->value();
}
ed->curveParam = ed->expo;
}
} else {
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
ed->curveMode = 1;
ed->curveParam = ui->curvesCB->currentIndex();
if (ui->expoGV->isChecked()) {
ed->expo = ui->expoCB->itemData(ui->expoCB->currentIndex()).toInt();
} else {
ed->expo = ui->expoSB->value();
}
} else {
ed->curveMode = 1;
ed->curveParam = ui->curvesCB->currentIndex();
ed->expo = 0;
// TODO ed->expo = ed->curveParam;
}
else {
// TODO ed->curveMode = 1;
// TODO ed->curveParam = ui->curvesCB->currentIndex();
// TODO ed->expo = 0;
ui->expoCurveCB->hide();
ui->expoCurveSB->hide();
ui->expoCurveGV->hide();

View file

@ -1,6 +1,6 @@
#include "flightmodes.h"
#include "ui_flightmode.h"
#include "firmwares/opentx/open9xeeprom.h" // TODO shouldn't be there
// #include "firmwares/opentx/opentxeeprom.h" // TODO shouldn't be there
#include "helpers.h"
#include <QComboBox>
#include <QGridLayout>

View file

@ -83,13 +83,12 @@ void InputsPanel::update()
};
str += tr("Weight") + getGVarString(md->weight).rightJustified(6, ' ');
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
if (md->expo!=0)
str += " " + tr("Expo") + getGVarString(md->expo, true).rightJustified(7, ' ');
} else {
if (md->curveMode==0 && md->curveParam!=0)
str += " " + tr("Expo") + getGVarString(md->curveParam, true).rightJustified(7, ' ');
QString curveStr = md->curve.toString();
if (!curveStr.isEmpty()) {
str += " " + curveStr;
}
if (GetEepromInterface()->getCapability(FlightPhases)) {
if(md->phases) {
if (md->phases!=(unsigned int)(1<<GetEepromInterface()->getCapability(FlightPhases))-1) {
@ -120,14 +119,14 @@ void InputsPanel::update()
mask <<=1;
}
str += QString(")");
} else {
}
else {
str += tr("DISABLED")+QString(" !!!");
}
}
}
if (md->swtch.type != SWITCH_TYPE_NONE) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
if (md->curveMode)
if (md->curveParam) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curveParam));
if (GetEepromInterface()->getCapability(HasExpoNames)) {
QString ExpoName;
ExpoName.append(md->name);

View file

@ -17,7 +17,9 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
this->setWindowTitle(tr("DEST -> X%1").arg(md->destCh-GetEepromInterface()->getCapability(Outputs)));
else
this->setWindowTitle(tr("DEST -> CH%1%2").arg(md->destCh/10).arg(md->destCh%10));
populateSourceCB(ui->sourceCB, md->srcRaw, POPULATE_SOURCES | POPULATE_SWITCHES | (GetEepromInterface()->getCapability(ExtraTrims) ? POPULATE_TRIMS : 0) | (GetEepromInterface()->getCapability(GvarsAsSources) ? POPULATE_GVARS : 0));
ui->sourceCB->removeItem(0);
int limit=GetEepromInterface()->getCapability(OffsetWeight);
if (GetEepromInterface()->getCapability(GvarsAsWeight)) {
@ -32,20 +34,15 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
if (gvars==0) {
ui->offsetGV->setDisabled(true);
ui->weightGV->setDisabled(true);
ui->differentialGV->setDisabled(true);
if (md->weight>limit || md->weight<-limit) {
md->weight=100;
}
if (md->sOffset>limit || md->sOffset<-limit) {
md->sOffset=0;
}
if (md->differential>100 || md->weight<-100) {
md->differential=0;
}
}
populateGVCB(ui->offsetCB,md->sOffset);
populateGVCB(ui->weightCB,md->weight);
populateGVCB(ui->differentialCB,md->differential);
ui->weightSB->setMinimum(-limit);
ui->weightSB->setMaximum(limit);
if (md->weight>limit || md->weight<-limit) {
@ -65,57 +62,33 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
ui->offsetGV->setChecked(true);
ui->offsetSB->hide();
ui->offsetCB->show();
} else {
}
else {
ui->offsetGV->setChecked(false);
ui->offsetSB->setValue(md->sOffset);
ui->offsetSB->show();
ui->offsetCB->hide();
}
ui->differentialSB->setMinimum(-100);
ui->differentialSB->setMaximum(100);
if (md->differential>100 || md->differential<-100) {
ui->differentialGV->setChecked(true);
ui->differentialSB->hide();
ui->differentialCB->show();
} else {
ui->differentialGV->setChecked(false);
ui->differentialSB->setValue(md->differential);
ui->differentialSB->show();
ui->differentialCB->hide();
}
} else {
else {
ui->offsetGV->hide();
ui->weightGV->hide();
ui->differentialGV->hide();
ui->offsetSB->setMinimum(-limit);
ui->offsetSB->setMaximum(limit);
ui->offsetSB->setValue(md->sOffset);
ui->differentialSB->setMinimum(-100);
ui->differentialSB->setMaximum(100);
ui->differentialSB->setValue(md->differential);
ui->weightSB->setMinimum(-limit);
ui->weightSB->setMaximum(limit);
ui->weightSB->setValue(md->weight);
}
populateCurveReference(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, md->curve, 0);
ui->FixOffsetChkB->setChecked(md->lateOffset);
ui->MixDR_CB->setChecked(md->noExpo==0);
if (md->enableFmTrim==1) {
ui->label_4->setText(tr("FM Trim Value"));
}
else {
ui->label_4->setText(tr("Offset"));
}
if (!GetEepromInterface()->getCapability(MixesWithoutExpo)) {
ui->MixDR_CB->hide();
ui->label_MixDR->hide();
}
if (!GetEepromInterface()->getCapability(MixFmTrim)) {
ui->FMtrimChkB->hide();
ui->label_FMtrim->hide();
ui->label_4->setText(tr("Offset"));
}
if (!GetEepromInterface()->getCapability(HasFixOffset)) {
ui->FixOffsetChkB->hide();
ui->label_FixOffset->hide();
@ -127,12 +100,6 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
ui->trimCB->addItem(tr("Ail"),4);
}
ui->trimCB->setCurrentIndex((-md->carryTrim)+1);
if (!GetEepromInterface()->getCapability(DiffMixers)) {
ui->differentialGV->hide();
ui->differentialSB->hide();
ui->differentialCB->hide();
ui->label_curve->setText(tr("Curve"));
}
int namelength=GetEepromInterface()->getCapability(HasMixerNames);
if (!namelength) {
ui->label_name->hide();
@ -146,7 +113,8 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
lb_fp[i]->hide();
cb_fp[i]->hide();
}
} else {
}
else {
int mask=1;
for (int i=0; i<9 ; i++) {
if ((md->phases & mask)==0) {
@ -159,9 +127,10 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
cb_fp[i]->hide();
}
}
ui->mixerName->setValidator(new QRegExpValidator(rx, this));
ui->mixerName->setText(md->name);
populateCurvesCB(ui->curvesCB,md->curve);
populateSwitchCB(ui->switchesCB,md->swtch);
ui->warningCB->setCurrentIndex(md->mixWarn);
ui->mltpxCB->setCurrentIndex(md->mltpx);
@ -190,18 +159,19 @@ MixerDialog::MixerDialog(QWidget *parent, MixData *mixdata, int stickMode) :
connect(ui->sourceCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->weightCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->offsetCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->differentialCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveTypeCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveGVarCB,SIGNAL(stateChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveValueCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->curveValueSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->weightSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->offsetSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->differentialSB,SIGNAL(editingFinished()),this,SLOT(valuesChanged()));
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->weightGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged())); // TODO why the same slot?
connect(ui->offsetGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->differentialGV,SIGNAL(stateChanged(int)),this,SLOT(widgetChanged()));
connect(ui->trimCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->MixDR_CB,SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
connect(ui->FMtrimChkB,SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
connect(ui->FixOffsetChkB,SIGNAL(toggled(bool)),this,SLOT(valuesChanged()));
connect(ui->curvesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->switchesCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->warningCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
connect(ui->mltpxCB,SIGNAL(currentIndexChanged(int)),this,SLOT(valuesChanged()));
@ -243,15 +213,6 @@ void MixerDialog::widgetChanged()
gvars=1;
}
if (gvars==1) {
if (!GetEepromInterface()->getCapability(DiffMixers)) {
if (ui->differentialGV->isChecked()) {
ui->differentialCB->show();
ui->differentialSB->hide();
} else {
ui->differentialCB->hide();
ui->differentialSB->show();
}
}
if (ui->weightGV->isChecked()) {
ui->weightCB->show();
ui->weightSB->hide();
@ -301,28 +262,15 @@ void MixerDialog::valuesChanged()
md->carryTrim = -(ui->trimCB->currentIndex()-1);
md->noExpo = ui->MixDR_CB->checkState() ? 0 : 1;
md->lateOffset = ui->FixOffsetChkB->checkState() ? 1 : 0;
md->enableFmTrim = ui->FMtrimChkB->checkState() ? 1 : 0;
int numcurves=GetEepromInterface()->getCapability(NumCurves);
if (numcurves==0) {
numcurves=16;
}
if (GetEepromInterface()->getCapability(DiffMixers) && (ui->curvesCB->currentIndex()-(numcurves)*GetEepromInterface()->getCapability(HasNegCurves))==0){
ui->differentialGV->show();
if (ui->differentialGV->isChecked()) {
ui->differentialSB->hide();
ui->differentialCB->show();
} else {
ui->differentialSB->show();
ui->differentialCB->hide();
}
} else {
ui->differentialGV->hide();
ui->differentialGV->setChecked(false);
ui->differentialSB->hide();
ui->differentialSB->setValue(0);
ui->differentialCB->hide();
}
md->curve = ui->curvesCB->currentIndex()-(numcurves)*GetEepromInterface()->getCapability(HasNegCurves);
// TODO md->curve = ui->curvesCB->currentIndex()-(numcurves)*GetEepromInterface()->getCapability(HasNegCurves);
// TODO if (ui->differentialGV->isChecked()) {
// TODO md->differential = ui->differentialCB->itemData(ui->differentialCB->currentIndex()).toInt();
// TODO } else {
// TODO md->differential = ui->differentialSB->value();
// TODO }
// populateCurveReference(QComboBox *curveTypeCB, QCheckBox *curveGVarCB, QComboBox *curveValueCB, QSpinBox *curveValueCB, CurveReference & curve, unsigned int flags)
md->swtch = RawSwitch(ui->switchesCB->itemData(ui->switchesCB->currentIndex()).toInt());
md->mixWarn = ui->warningCB->currentIndex();
md->mltpx = (MltpxValue)ui->mltpxCB->currentIndex();
@ -331,16 +279,7 @@ void MixerDialog::valuesChanged()
md->delayUp = round(ui->delayUpSB->value()*scale);
md->speedDown = round(ui->slowDownSB->value()*scale);
md->speedUp = round(ui->slowUpSB->value()*scale);
if (ui->differentialGV->isChecked()) {
md->differential = ui->differentialCB->itemData(ui->differentialCB->currentIndex()).toInt();
} else {
md->differential = ui->differentialSB->value();
}
if (GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1) {
ui->label_4->setText(tr("FM Trim Value"));
} else {
ui->label_4->setText(tr("Offset"));
}
int i=0;
for (i=0; i<ui->mixerName->text().toAscii().length(); i++) {
md->name[i]=ui->mixerName->text().toAscii().at(i);

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>367</width>
<height>475</height>
<width>342</width>
<height>434</height>
</rect>
</property>
<property name="sizePolicy">
@ -20,7 +20,7 @@
<string>Dialog</string>
</property>
<property name="windowIcon">
<iconset resource="companion9x.qrc">
<iconset resource="../companion9x.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_3">
@ -178,7 +178,142 @@ p, li { white-space: pre-wrap; }
</item>
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0,0">
<item row="12" column="1" colspan="2">
<item row="6" column="0">
<widget class="QLabel" name="label_MixDR">
<property name="text">
<string>Include DR/Expo</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="FixOffsetChkB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_phases">
<property name="text">
<string>Flight modes</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Include Trim</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Switch</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="MixDR_CB">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="curveTypeCB">
<property name="whatsThis">
<string>The curve used by the mix</string>
</property>
</widget>
</item>
<item row="10" column="1" colspan="2">
<widget class="QComboBox" name="warningCB">
<property name="whatsThis">
<string>Mixer warning.
Setting this value will cause a beep to be emmitted when this value is active.</string>
</property>
<item>
<property name="text">
<string>OFF</string>
</property>
</item>
<item>
<property name="text">
<string>1 Beep</string>
</property>
</item>
<item>
<property name="text">
<string>2 Beep</string>
</property>
</item>
<item>
<property name="text">
<string>3 Beep</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_FixOffset">
<property name="text">
<string>Fix Offset</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="trimCB">
<item>
<property name="text">
<string>No</string>
</property>
</item>
<item>
<property name="text">
<string>Yes</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0,1">
<item>
<widget class="QCheckBox" name="offsetGV">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="offsetCB">
<property name="whatsThis">
<string>The source for the mixer</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="offsetSB"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="11" column="1" colspan="2">
<widget class="QComboBox" name="mltpxCB">
<property name="whatsThis">
<string>Multiplexer
@ -213,7 +348,7 @@ This determines how mixer values are added.
</property>
</widget>
</item>
<item row="9" column="1" colspan="2">
<item row="8" column="1" colspan="2">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="lb_FP0">
@ -370,14 +505,14 @@ This determines how mixer values are added.
</item>
</layout>
</item>
<item row="11" column="0">
<item row="10" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Warning</string>
</property>
</widget>
</item>
<item row="12" column="0">
<item row="11" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Multiplex</string>
@ -415,162 +550,10 @@ This determines how mixer values are added.
<item row="4" column="0">
<widget class="QLabel" name="label_curve">
<property name="text">
<string>Curve/Differential</string>
<string>Curve</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Include Trim</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_FMtrim">
<property name="text">
<string>Enable FM Trim</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_phases">
<property name="text">
<string>Flight modes</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Switch</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_MixDR">
<property name="text">
<string>Include DR/Expo</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_FixOffset">
<property name="text">
<string>Fix Offset</string>
</property>
</widget>
</item>
<item row="11" column="1" colspan="2">
<widget class="QComboBox" name="warningCB">
<property name="whatsThis">
<string>Mixer warning.
Setting this value will cause a beep to be emmitted when this value is active.</string>
</property>
<item>
<property name="text">
<string>OFF</string>
</property>
</item>
<item>
<property name="text">
<string>1 Beep</string>
</property>
</item>
<item>
<property name="text">
<string>2 Beep</string>
</property>
</item>
<item>
<property name="text">
<string>3 Beep</string>
</property>
</item>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="curvesCB">
<property name="whatsThis">
<string>The curve used by the mix</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="MixDR_CB">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="FixOffsetChkB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="FMtrimChkB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,0,1">
<item>
<widget class="QCheckBox" name="offsetGV">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="offsetCB">
<property name="whatsThis">
<string>The source for the mixer</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="offsetSB"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="trimCB">
<item>
<property name="text">
<string>No</string>
</property>
</item>
<item>
<property name="text">
<string>Yes</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,1">
<item>
@ -605,7 +588,7 @@ Setting this value will cause a beep to be emmitted when this value is active.</
</item>
</layout>
</item>
<item row="10" column="1" colspan="2">
<item row="9" column="1" colspan="2">
<widget class="QComboBox" name="switchesCB">
<property name="whatsThis">
<string>Switch used by the mix.
@ -623,21 +606,21 @@ If blank then the mix is considered to be &quot;ON&quot; all the time.</string>
<item row="4" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,0,0">
<item>
<widget class="QCheckBox" name="differentialGV">
<widget class="QCheckBox" name="curveGVarCB">
<property name="text">
<string>GV</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="differentialCB">
<widget class="QComboBox" name="curveValueCB">
<property name="whatsThis">
<string>The source for the mixer</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="differentialSB"/>
<widget class="QSpinBox" name="curveValueSB"/>
</item>
</layout>
</item>
@ -646,7 +629,7 @@ If blank then the mix is considered to be &quot;ON&quot; all the time.</string>
</layout>
</widget>
<resources>
<include location="companion9x.qrc"/>
<include location="../companion9x.qrc"/>
</resources>
<connections>
<connection>

View file

@ -152,13 +152,14 @@ void MixesPanel::update()
if(md->noExpo) {
str += " " +tr("No DR/Expo");
}
if (GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1) {
if (md->sOffset) str += " " + tr("FMTrim") + QString("(%1%)").arg(md->sOffset);
} else {
if (md->sOffset) str += " " + tr("Offset") + getGVarString(md->sOffset);
QString curveStr = md->curve.toString();
if (!curveStr.isEmpty()) {
str += " " + curveStr;
}
if (md->differential) str += " " + tr("Diff") + getGVarString(md->differential);
if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve));
int scale=GetEepromInterface()->getCapability(SlowScale);
if (scale==0)
scale=1;
@ -188,7 +189,8 @@ void MixesPanel::update()
if (curDest > outputs) {
str = tr("X%1 ").arg(curDest-outputs);
} else {
}
else {
str = tr("CH%1%2").arg(curDest/10).arg(curDest%10);
if (GetEepromInterface()->getCapability(HasChNames) && showNames) {
QString name=model.limitData[curDest-1].name;

View file

@ -261,23 +261,8 @@ void printDialog::printExpo()
};
str += tr("Weight") + QString("%1").arg(getGVarString(ed->weight,true)).rightJustified(6, ' ');
if (!GetEepromInterface()->getCapability(ExpoIsCurve)) {
if (ed->expo!=0) {
if (ed->expo<126) {
str += " " + tr("Expo") + QString("%1").arg(getGVarString(ed->expo)).rightJustified(7, ' ');
} else {
str += " " + tr("Expo") + QString("%1").arg(getGVarString(ed->expo)).rightJustified(7, ' ');
}
}
} else {
if (ed->curveMode==0 && ed->curveParam!=0) {
if (ed->curveParam<126) {
str += " " + tr("Expo") + QString("%1").arg(getGVarString(ed->curveParam)).rightJustified(7, ' ');
} else {
str += " " + tr("Expo") + QString("%1").arg(getGVarString(ed->curveParam)).rightJustified(7, ' ');
}
}
}
str += ed->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (GetEepromInterface()->getCapability(FlightPhases)) {
if(ed->phases) {
if (ed->phases!=(unsigned int)(1<<GetEepromInterface()->getCapability(FlightPhases))-1) {
@ -316,9 +301,7 @@ void printDialog::printExpo()
}
if (ed->swtch.type)
str += " " + tr("Switch") + QString("(%1)").arg(ed->swtch.toString());
if (ed->curveMode)
if (ed->curveParam)
str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(ed->curveParam).replace("<", "&lt;").replace(">", "&gt;"));
str += ed->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
if (GetEepromInterface()->getCapability(HasExpoNames)) {
QString ExpoName;
ExpoName.append(ed->name);
@ -370,13 +353,8 @@ void printDialog::printMixes()
str += md->srcRaw.toString();
if (md->swtch.type) str += " " + tr("Switch") + QString("(%1)").arg(md->swtch.toString());
if (md->carryTrim) str += " " + tr("noTrim");
if(GetEepromInterface()->getCapability(MixFmTrim) && md->enableFmTrim==1){
if (md->sOffset) str += " "+ tr("FMTrim") + QString(" %1").arg(getGVarString(md->sOffset));
} else {
if (md->sOffset) str += " "+ tr("Offset") + QString(" %1").arg(getGVarString(md->sOffset));
}
if (md->differential) str += " "+ tr("Diff") + QString(" %1").arg(getGVarString(md->differential));
if (md->curve) str += " " + tr("Curve") + QString("(%1)").arg(getCurveStr(md->curve).replace("<", "&lt;").replace(">", "&gt;"));
str += md->curve.toString().replace("<", "&lt;").replace(">", "&gt;");
float scale=GetEepromInterface()->getCapability(SlowScale);
if (md->delayDown || md->delayUp) str += tr(" Delay(u%1:d%2)").arg(md->delayUp/scale).arg(md->delayDown/scale);
if (md->speedDown || md->speedUp) str += tr(" Slow(u%1:d%2)").arg(md->speedUp/scale).arg(md->speedDown/scale);
@ -566,101 +544,7 @@ void printDialog::printCurves()
if (numcurves==0) {
numcurves=16;
}
if (!GetEepromInterface()->getCapability(CustomCurves)) {
QImage qi(ISIZE+1,ISIZE+1,QImage::Format_RGB32);
QPainter painter(&qi);
painter.setBrush(QBrush("#FFFFFF"));
painter.setPen(QColor(0,0,0));
painter.drawRect(0,0,ISIZE,ISIZE);
str.append("<table border=1 cellspacing=0 cellpadding=3 width=\"100%\"><tr><td colspan=2><b>"+tr("5 Points Curves")+QString("</b></td></tr><tr><td width=\"200\"><img src=\"%1\" border=0></td><td><table border=1 cellspacing=0 cellpadding=3 width=\"100%\">").arg(curvefile5));
str.append("<tr>");
str.append(doTC("&nbsp;"));
for(i=0; i<5; i++)
str.append(doTC(tr("pt %1").arg(i+1), "", true));
str.append("</tr>");
for(i=0; i<8; i++) {
pen.setColor(*qplot_color[i]);
painter.setPen(pen);
qplot_color[i]->getRgb(&r,&g,&b);
c=r;
c*=256;
c+=g;
c*=256;
c+=b;
sprintf(buffer,"%06x",c);
str.append("<tr>");
str.append(QString("<td width=\"70\"><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td>").arg(i+1));
count=0;
for(int j=0; j<5; j++) {
if (g_model->curves[i].points[j].y!=0)
count++;
}
for(int j=0; j<5; j++) {
str.append(doTR(QString::number(g_model->curves[i].points[j].y),"green"));
if (j>0 && count!=0) {
painter.drawLine(ISIZE*(j-1)/4,ISIZE/2-(ISIZE*g_model->curves[i].points[j-1].y)/200,ISIZE*(j)/4,ISIZE/2-(ISIZE*g_model->curves[i].points[j].y)/200);
}
}
str.append("</tr>");
}
str.append("</table></td></tr></table></td></tr><tr><td>");
painter.setPen(QColor(0,0,0));
painter.drawLine(0,ISIZE/2,ISIZE,ISIZE/2);
painter.drawLine(ISIZE/2,0,ISIZE/2,ISIZE);
for(i=0; i<5; i++) {
painter.drawLine(ISIZE/2-2,(ISIZE*i)/4,ISIZE/2+2,(ISIZE*i)/4);
painter.drawLine((ISIZE*i)/4,ISIZE/2-2,(ISIZE*i)/4,ISIZE/2+2);
}
qi.save(curvefile5, "png",100);
str.append("<table border=1 cellspacing=0 cellpadding=3 width=\"100%\"><tr><td colspan=2><b>"+tr("9 Points Curves")+QString("</b></td></tr><tr><td width=\"200\"><img src=\"%1\" border=0></td><td><table border=1 cellspacing=0 cellpadding=3 width=\"100%\">").arg(curvefile9));
str.append("<tr><td width=\"70\">&nbsp;</td>");
for(i=0; i<9; i++) str.append(doTC(tr("pt %1").arg(i+1), "", true));
str.append("</tr>");
painter.setBrush(QBrush("#FFFFFF"));
painter.setPen(QColor(0,0,0));
painter.drawRect(0,0,ISIZE,ISIZE);
for(i=0; i<9; i++) {
painter.drawLine(ISIZE/2-2,(ISIZE*i)/8,ISIZE/2+2,(ISIZE*i)/8);
painter.drawLine((ISIZE*i)/8,ISIZE/2-2,(ISIZE*i)/8,ISIZE/2+2);
}
for(i=0; i<8; i++) {
pen.setColor(*qplot_color[i]);
painter.setPen(pen);
qplot_color[i]->getRgb(&r,&g,&b);
c=r;
c*=256;
c+=g;
c*=256;
c+=b;
sprintf(buffer,"%06x",c);
str.append("<tr>");
str.append(QString("<td width=\"70\"><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td>").arg(i+9));
count=0;
for(int j=0; j<9; j++) {
if (g_model->curves[i].points[j].y!=0)
count++;
}
for(int j=0; j<9; j++) {
str.append(doTR(QString::number(g_model->curves[i].points[j].y),"green"));
if (j>0 && count!=0) {
painter.drawLine(ISIZE*(j-1)/8,ISIZE/2-(ISIZE*g_model->curves[i+8].points[j-1].y)/200,ISIZE*(j)/8,ISIZE/2-(ISIZE*g_model->curves[i+8].points[j].y)/200);
}
}
str.append("</tr>");
}
str.append("</table></td></tr></table></td></tr></table>");
str.append("<br>");
painter.setPen(QColor(0,0,0));
painter.drawLine(0,ISIZE/2,ISIZE,ISIZE/2);
painter.drawLine(ISIZE/2,0,ISIZE/2,ISIZE);
for(i=0; i<9; i++) {
painter.drawLine(ISIZE/2-2,(ISIZE*i)/8,ISIZE/2+2,(ISIZE*i)/8);
painter.drawLine((ISIZE*i)/8,ISIZE/2-2,(ISIZE*i)/8,ISIZE/2+2);
}
qi.save(curvefile9, "png",100);
} else {
{
QImage qi(ISIZEW+1,ISIZEW+1,QImage::Format_RGB32);
QPainter painter(&qi);
painter.setBrush(QBrush("#FFFFFF"));
@ -703,11 +587,10 @@ void printDialog::printCurves()
sprintf(buffer,"%06x",c);
str.append("<tr>");
int curvepoints=g_model->curves[i].count;
if (!g_model->curves[i].custom) {
str.append(QString("<td width=\"70\"><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td><td width=5>Y</td>").arg(i+1));
} else {
if (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)
str.append(QString("<td width=\"70\" rowspan=2 valign=middle><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td><td width=5>Y</td>").arg(i+1));
}
else
str.append(QString("<td width=\"70\"><font color=#%1><b>").arg(buffer)+tr("Curve")+QString(" %1</b></font></td><td width=5>Y</td>").arg(i+1));
count=0;
for(int j=0; j<curvepoints; j++) {
if (g_model->curves[i].points[j].y!=0)
@ -716,18 +599,17 @@ void printDialog::printCurves()
for(int j=0; j<curvepoints; j++) {
str.append(doTR(QString::number(g_model->curves[i].points[j].y),"green"));
if (j>0 && count!=0) {
if (!g_model->curves[i].custom) {
painter.drawLine(ISIZEW*(j-1)/(curvepoints-1),ISIZEW/2-(ISIZEW*g_model->curves[i].points[j-1].y)/200,ISIZEW*(j)/(curvepoints-1),ISIZEW/2-(ISIZEW*g_model->curves[i].points[j].y)/200);
} else {
if (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM)
painter.drawLine(ISIZEW/2+(ISIZEW*g_model->curves[i].points[j-1].x)/200,ISIZEW/2-(ISIZEW*g_model->curves[i].points[j-1].y)/200,ISIZEW/2+(ISIZEW*g_model->curves[i].points[j].x)/200,ISIZEW/2-(ISIZEW*g_model->curves[i].points[j].y)/200);
}
else
painter.drawLine(ISIZEW*(j-1)/(curvepoints-1),ISIZEW/2-(ISIZEW*g_model->curves[i].points[j-1].y)/200,ISIZEW*(j)/(curvepoints-1),ISIZEW/2-(ISIZEW*g_model->curves[i].points[j].y)/200);
}
}
for(int j=curvepoints; j<numpoint; j++) {
str.append(doTR("","green"));
}
str.append("</tr>");
if (g_model->curves[i].custom) {
if (g_model->curves[i].type == CurveData::CURVE_TYPE_CUSTOM) {
str.append("<tr><td width=5>X</td>");
for(int j=0; j<curvepoints; j++) {
str.append(doTR(QString::number(g_model->curves[i].points[j].x),"green"));

View file

@ -56,11 +56,11 @@
#elif defined(PCBSKY9X)
#define EEPROM_VER 216
#elif defined(CPUM2560) || defined(CPUM2561)
#define EEPROM_VER 215
#define EEPROM_VER 216
#elif defined(CPUM128)
#define EEPROM_VER 216
#else
#define EEPROM_VER 214
#define EEPROM_VER 216
#endif
#ifndef PACK
@ -274,12 +274,12 @@ PACK(typedef struct t_ScriptData {
TRAINER_MODULE
};
#define MODELDATA_BITMAP char bitmap[LEN_BITMAP_NAME];
#define MODELDATA_EXTRA uint8_t externalModule; uint8_t trainerMode; ModuleData moduleData[NUM_MODULES+1]; char curveNames[MAX_CURVES][6]; ScriptData scriptsData[MAX_SCRIPTS]; char inputNames[MAX_INPUTS][4]; uint8_t nPotsToWarn; int8_t potPosition[NUM_POTS];
#define MODELDATA_EXTRA uint8_t externalModule; uint8_t trainerMode; ModuleData moduleData[NUM_MODULES+1]; char curveNames[MAX_CURVES][6]; ScriptData scriptsData[MAX_SCRIPTS]; char inputNames[MAX_INPUTS][4];
#define LIMITDATA_EXTRA char name[LEN_CHANNEL_NAME]; int8_t curve;
#define swstate_t uint16_t
#elif defined(PCBSKY9X)
#define MODELDATA_BITMAP
#define MODELDATA_EXTRA ModuleData moduleData[NUM_MODULES]; uint8_t nPotsToWarn; int8_t potPosition[NUM_POTS];
#define MODELDATA_EXTRA ModuleData moduleData[NUM_MODULES];
#define LIMITDATA_EXTRA
#define swstate_t uint8_t
#else
@ -397,7 +397,7 @@ PACK(typedef struct t_ExpoData {
char name[LEN_EXPOMIX_NAME];
int8_t offset;
CurveRef curve;
uint8_t spare[2];
uint8_t spare;
}) ExpoData;
#define MIN_EXPO_WEIGHT -100
#define EXPO_VALID(ed) ((ed)->srcRaw)
@ -508,7 +508,7 @@ PACK(typedef struct t_MixData {
uint8_t srcRaw;
int16_t offset;
char name[LEN_EXPOMIX_NAME];
uint8_t spare[2];
uint8_t spare;
}) MixData;
#else
PACK(typedef struct t_MixData {
@ -988,8 +988,7 @@ PACK(typedef struct t_FrSkyData {
FrSkyRSSIAlarm rssiAlarms[2];
uint16_t mAhPersistent:1;
uint16_t storedMah:15;
int8_t fasOffset:5;
uint8_t spare:3;
int8_t fasOffset;
}) FrSkyData;
#else
#define MAX_FRSKY_SCREENS 2
@ -1007,8 +1006,7 @@ PACK(typedef struct t_FrSkyData {
int8_t varioCenterMin:5;
uint8_t currentSource:3;
int8_t varioCenterMax:5;
int8_t fasOffset:5;
uint8_t spare:3;
int8_t fasOffset;
}) FrSkyData;
#endif
@ -1412,24 +1410,28 @@ PACK(typedef struct t_ModelHeader {
}) ModelHeader;
#if defined (CPUARM)
#define ARM_OR_AVR(x, y) x
#define ARM_FIELD(x) x;
#define AVR_FIELD(x)
#else
#define ARM_OR_AVR(x, y) y
#define ARM_FIELD(x)
#define AVR_FIELD(x) x;
#endif
PACK(typedef struct t_ModelData {
ModelHeader header;
TimerData timers[MAX_TIMERS];
uint8_t protocol:3;
uint8_t protocol:3; // not used on Taranis
uint8_t thrTrim:1; // Enable Throttle Trim
int8_t ppmNCH:4; /* spare on ARM */
AVR_FIELD(int8_t ppmNCH:4)
ARM_FIELD(int8_t spare2:4)
uint8_t trimInc:3; // Trim Increments
uint8_t disableThrottleWarning:1;
uint8_t ARM_OR_AVR(displayText, pulsePol):1;
ARM_FIELD(uint8_t displayText:1)
AVR_FIELD(uint8_t pulsePol:1)
uint8_t extendedLimits:1;
uint8_t extendedTrims:1;
uint8_t throttleReversed:1;
int8_t ppmDelay; /* spare on ARM */
AVR_FIELD(int8_t ppmDelay)
BeepANACenter beepANACenter; // 1<<0->A1.. 1<<6->A7
MixData mixData[MAX_MIXERS];
LimitData limitData[NUM_CHNOUT];
@ -1443,11 +1445,10 @@ PACK(typedef struct t_ModelData {
SwashRingData swashR;
PhaseData phaseData[MAX_PHASES];
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5ms increments
AVR_FIELD(int8_t ppmFrameLength) // 0=22.5ms (10ms-30ms) 0.5ms increments
uint8_t thrTraceSrc;
swstate_t switchWarningStates;
uint8_t nSwToWarn;
MODEL_GVARS_DATA