Merge branch 'origin/next'

This commit is contained in:
Kjell Kernen
2014-02-08 17:03:48 +01:00
74 changed files with 3564 additions and 3159 deletions
+7 -57
View File
@@ -83,7 +83,6 @@ void compareDialog::printDiff()
printCurves();
printGvars();
printSwitches();
printSafetySwitches();
printFSwitches();
printFrSky();
te->scrollToAnchor("1");
@@ -1040,9 +1039,9 @@ void compareDialog::printSwitches()
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">";
str.append("<tr><td><h2>"+tr("Logical Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=1 cellspacing=0 cellpadding=1 width=\"100%\">");
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
QString sw1 = getCustomSwitchStr(&g_model1->customSw[i], *g_model1);
QString sw2 = getCustomSwitchStr(&g_model2->customSw[i], *g_model2);
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
QString sw1 = g_model1->customSw[i].toString(*g_model1);
QString sw2 = g_model2->customSw[i].toString(*g_model2);
if (!(sw1.isEmpty() && sw2.isEmpty())) {
str.append("<tr>");
color=getColor1(sw1,sw2);
@@ -1096,8 +1095,8 @@ void compareDialog::printFSwitches()
str.append("<tr>");
if (g_model1->funcSw[i].swtch.type) {
str.append(doTC(g_model1->funcSw[i].swtch.toString(),color1));
str.append(doTC(getFuncName(g_model1->funcSw[i].func),color1));
str.append(doTC(FuncParam(g_model1->funcSw[i].func,g_model1->funcSw[i].param,g_model1->funcSw[i].paramarm, g_model1->funcSw[i].adjustMode),color1));
str.append(doTC(g_model1->funcSw[i].funcToString(),color1));
str.append(doTC(g_model1->funcSw[i].paramToString(),color1));
int index=g_model1->funcSw[i].func;
if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
str.append(doTC(QString("%1").arg(g_model1->funcSw[i].repeatParam),color1));
@@ -1115,8 +1114,8 @@ void compareDialog::printFSwitches()
str.append(doTC(tr("CF")+QString("%1").arg(i+1),"",true));
if (g_model2->funcSw[i].swtch.type) {
str.append(doTC(g_model2->funcSw[i].swtch.toString(),color2));
str.append(doTC(getFuncName(g_model2->funcSw[i].func),color2));
str.append(doTC(FuncParam(g_model2->funcSw[i].func,g_model2->funcSw[i].param,g_model2->funcSw[i].paramarm, g_model2->funcSw[i].adjustMode),color2));
str.append(doTC(g_model2->funcSw[i].funcToString(),color2));
str.append(doTC(g_model2->funcSw[i].paramToString(),color2));
int index=g_model2->funcSw[i].func;
if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
str.append(doTC(QString("%1").arg(g_model2->funcSw[i].repeatParam),color2));
@@ -1142,55 +1141,6 @@ void compareDialog::printFSwitches()
te->append(str);
}
void compareDialog::printSafetySwitches()
{
QString color1;
QString color2;
int sc=0;
QString str = "<table border=1 cellspacing=0 cellpadding=3 style=\"page-break-before:always;\" width=\"100%\">";
str.append("<tr><td><h2>"+tr("Safety Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=1 cellspacing=0 cellpadding=1 width=\"100%\"><tr>");
str.append("<td width=\"8%\" align=\"center\"><b>"+tr("Switch")+"</b></td>");
str.append("<td width=\"37%\" align=\"center\"><b>"+tr("Value")+"</b></td>");
str.append("<td width=\"10%\">&nbsp;</td>");
str.append("<td width=\"8%\" align=\"center\"><b>"+tr("Switch")+"</b></td>");
str.append("<td width=\"37%\" align=\"center\"><b>"+tr("Value")+"</b></td>");
str.append("</tr>");
for(int i=0; i<GetEepromInterface()->getCapability(Outputs); i++)
{
if ((g_model1->safetySw[i].swtch.type!=SWITCH_TYPE_NONE)||(g_model2->safetySw[i].swtch.type!=SWITCH_TYPE_NONE)) {
if ((g_model1->safetySw[i].swtch!=g_model2->safetySw[i].swtch)||(g_model1->safetySw[i].val!=g_model2->safetySw[i].val)) {
color1="green";
color2="red";
} else {
color1="grey";
color2="grey";
}
str.append("<tr>");
if (g_model1->safetySw[i].swtch.type) {
str.append(doTC(g_model1->safetySw[i].swtch.toString(),color1));
str.append(doTC(QString::number(g_model1->safetySw[i].val),color1));
}
else {
str.append("<td>&nbsp;</td><td>&nbsp;</td>");
}
str.append(doTC(tr("CH")+QString("%1").arg(i+1),"",true));
if (g_model2->safetySw[i].swtch.type) {
str.append(doTC(g_model2->safetySw[i].swtch.toString(),color2));
str.append(doTC(QString::number(g_model2->safetySw[i].val),color2));
} else {
str.append("<td>&nbsp;</td><td>&nbsp;</td>");
}
str.append("</tr>");
sc++;
}
}
str.append("</table></td></tr></table>");
str.append("<br>");
if (sc!=0)
te->append(str);
}
void compareDialog::printFrSky()
{
QString color;
+16 -3
View File
@@ -93,6 +93,17 @@ class DataField {
const char *name;
};
class ProxyField: public DataField {
public:
ProxyField():
DataField("Proxy")
{
}
virtual DataField * getField() = 0;
};
template<int N>
class UnsignedField: public DataField {
public:
@@ -273,9 +284,10 @@ class SpareBitsField: public UnsignedField<N> {
template<int N>
class CharField: public DataField {
public:
CharField(char *field):
CharField(char *field, bool truncate=true):
DataField("Char"),
field(field)
field(field),
truncate(truncate)
{
}
@@ -283,7 +295,7 @@ class CharField: public DataField {
{
output.resize(N*8);
int b = 0;
int len = strlen(field);
int len = truncate ? strlen(field) : N;
for (int i=0; i<N; i++) {
int idx = (i>=len ? 0 : field[i]);
for (int j=0; j<8; j++, b++) {
@@ -313,6 +325,7 @@ class CharField: public DataField {
protected:
char * field;
bool truncate;
};
int8_t char2idx(char c);
+435 -63
View File
@@ -268,62 +268,52 @@ QString RawSwitch::toString()
QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26")
};
switch(type) {
case SWITCH_TYPE_SWITCH:
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1) : QString("!") + CHECK_IN_ARRAY(switchesX9D, -index-1);
else
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1) : QString("!") + CHECK_IN_ARRAY(switches9X, -index-1);
case SWITCH_TYPE_VIRTUAL:
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1) : QString("!") + CHECK_IN_ARRAY(virtualSwitches, -index-1);
case SWITCH_TYPE_MULTIPOS_POT:
return CHECK_IN_ARRAY(multiposPots, index);
case SWITCH_TYPE_ON:
return QObject::tr("ON");
case SWITCH_TYPE_ONM:
if (index==0) {
return QObject::tr("ONE");
}
else if (index==1) {
return QObject::tr("!ONE");
}
break;
case SWITCH_TYPE_TRN:
if (index==0) {
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return SwitchDn('H')+"s";
else
return QObject::tr("TRNs");
} else if (index==1) {
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return SwitchDn('H')+"l";
else
return QObject::tr("TRNl");
}
break;
case SWITCH_TYPE_REA:
if (index==0) {
if (GetEepromInterface()->getBoard() == BOARD_SKY9X)
return QObject::tr("REAs");
} else if (index==1) {
if (GetEepromInterface()->getBoard() == BOARD_SKY9X)
return QObject::tr("REAl");
}
break;
case SWITCH_TYPE_OFF:
return QObject::tr("OFF");
case SWITCH_TYPE_MOMENT_SWITCH:
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(switchesX9D, -index-1)+QString("t");
else
return index > 0 ? CHECK_IN_ARRAY(switches9X, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(switches9X, -index-1)+QString("t");
case SWITCH_TYPE_MOMENT_VIRTUAL:
return index > 0 ? CHECK_IN_ARRAY(virtualSwitches, index-1)+QString("t") : QString("!")+CHECK_IN_ARRAY(virtualSwitches, -index-1)+QString("t");
default:
break;
}
static const QString trimsSwitches[] = {
QObject::tr("RudTrim Left"), QObject::tr("RudTrim Right"),
QObject::tr("EleTrim Down"), QObject::tr("EleTrim Up"),
QObject::tr("ThrTrim Down"), QObject::tr("ThrTrim Up"),
QObject::tr("AilTrim Left"), QObject::tr("AilTrim Right")
};
return QObject::tr("----");
static const QString rotaryEncoders[] = {
QObject::tr("REa"), QObject::tr("REb")
};
static const QString timerModes[] = {
QObject::tr("OFF"), QObject::tr("ABS"),
QObject::tr("THs"), QObject::tr("TH%"), QObject::tr("THt")
};
if (index < 0) {
return QString("!") + RawSwitch(type, -index).toString();
}
else {
switch(type) {
case SWITCH_TYPE_SWITCH:
if (IS_TARANIS(GetEepromInterface()->getBoard()))
return CHECK_IN_ARRAY(switchesX9D, index-1);
else
return CHECK_IN_ARRAY(switches9X, index-1);
case SWITCH_TYPE_VIRTUAL:
return CHECK_IN_ARRAY(virtualSwitches, index-1);
case SWITCH_TYPE_MULTIPOS_POT:
return CHECK_IN_ARRAY(multiposPots, index-1);
case SWITCH_TYPE_TRIM:
return CHECK_IN_ARRAY(trimsSwitches, index-1);
case SWITCH_TYPE_ROTARY_ENCODER:
return CHECK_IN_ARRAY(rotaryEncoders, index-1);
case SWITCH_TYPE_ON:
return QObject::tr("ON");
case SWITCH_TYPE_OFF:
return QObject::tr("OFF");
case SWITCH_TYPE_NONE:
return QObject::tr("----");
case SWITCH_TYPE_TIMER_MODE:
return CHECK_IN_ARRAY(timerModes, index);
default:
return QObject::tr("???");
}
}
}
QString CurveReference::toString()
@@ -345,6 +335,390 @@ QString CurveReference::toString()
}
}
CSFunctionFamily LogicalSwitchData::getFunctionFamily()
{
if (func == LS_FN_STAY)
return LS_FAMILY_STAY;
else if (func == LS_FN_TIMER)
return LS_FAMILY_TIMER;
else if (func == LS_FN_STICKY)
return LS_FAMILY_STICKY;
else if (func < LS_FN_AND || func > LS_FN_ELESS)
return LS_FAMILY_VOFS;
else if (func < LS_FN_EQUAL)
return LS_FAMILY_VBOOL;
else
return LS_FAMILY_VCOMP;
}
QString LogicalSwitchData::funcToString()
{
switch (func) {
case LS_FN_OFF:
return QObject::tr("---");
case LS_FN_VPOS:
return QObject::tr("a>x");
case LS_FN_VNEG:
return QObject::tr("a<x");
case LS_FN_APOS:
return QObject::tr("|a|>x");
case LS_FN_ANEG:
return QObject::tr("|a|<x");
case LS_FN_AND:
return QObject::tr("AND");
case LS_FN_OR:
return QObject::tr("OR");
case LS_FN_XOR:
return QObject::tr("XOR");
case LS_FN_EQUAL:
return QObject::tr("a=b");
case LS_FN_NEQUAL:
return QObject::tr("a!=b");
case LS_FN_GREATER:
return QObject::tr("a>b");
case LS_FN_LESS:
return QObject::tr("a<b");
case LS_FN_EGREATER:
return QObject::tr("a>=b");
case LS_FN_ELESS:
return QObject::tr("a<=b");
case LS_FN_DPOS:
return QObject::tr("d>=x");
case LS_FN_DAPOS:
return QObject::tr("|d|>=x");
case LS_FN_VEQUAL:
return QObject::tr("a~x");
case LS_FN_TIMER:
return QObject::tr("Timer");
case LS_FN_STICKY:
return QObject::tr("Sticky");
case LS_FN_STAY:
return QObject::tr("Stay");
default:
return QObject::tr("Unknown");
}
}
QString LogicalSwitchData::toString(const ModelData & model)
{
QString result = "";
if (!func)
return result;
if (andsw!=0) {
result +="( ";
}
switch (getFunctionFamily()) {
case LS_FAMILY_STAY:
result = QObject::tr("STAY(%1, [%2:%3])").arg(RawSwitch(val1).toString()).arg(ValToTim(val2)).arg(ValToTim(val2+val3));
break;
case LS_FAMILY_STICKY:
result = QObject::tr("STICKY(%1, %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString());
break;
case LS_FAMILY_TIMER:
result = QObject::tr("TIMER(%1, %2)").arg(ValToTim(val1)).arg(ValToTim(val2));
break;
case LS_FAMILY_VOFS: {
RawSource source = RawSource(val1, &model);
RawSourceRange range = source.getRange();
if (val1)
result += source.toString();
else
result += "0";
result.remove(" ");
if (func == LS_FN_APOS || func == LS_FN_ANEG)
result = "|" + result + "|";
else if (func == LS_FN_DAPOS)
result = "|d(" + result + ")|";
else if (func == LS_FN_DPOS) result = "d(" + result + ")";
if (func == LS_FN_APOS || func == LS_FN_VPOS || func == LS_FN_DAPOS || func == LS_FN_DPOS)
result += " &gt; ";
else if (func == LS_FN_ANEG || func == LS_FN_VNEG)
result += " &lt; ";
result += QString::number(range.step * (val2 /*TODO+ source.getRawOffset(model)*/) + range.offset);
break;
}
case LS_FAMILY_VBOOL:
result = RawSwitch(val1).toString();
switch (func) {
case LS_FN_AND:
result += " AND ";
break;
case LS_FN_OR:
result += " OR ";
break;
case LS_FN_XOR:
result += " XOR ";
break;
default:
break;
}
result += RawSwitch(val2).toString();
break;
case LS_FAMILY_VCOMP:
if (val1)
result += RawSource(val1).toString();
else
result += "0";
switch (func) {
case LS_FN_EQUAL:
result += " = ";
break;
case LS_FN_NEQUAL:
result += " != ";
break;
case LS_FN_GREATER:
result += " &gt; ";
break;
case LS_FN_LESS:
result += " &lt; ";
break;
case LS_FN_EGREATER:
result += " &gt;= ";
break;
case LS_FN_ELESS:
result += " &lt;= ";
break;
default:
break;
}
if (val2)
result += RawSource(val2).toString();
else
result += "0";
break;
}
if (andsw!=0) {
result +=" ) AND ";
result += RawSwitch(andsw).toString();
}
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
if (delay)
result += QObject::tr(" Delay %1 sec").arg(delay/2.0);
if (duration)
result += QObject::tr(" Duration %1 sec").arg(duration/2.0);
}
return result;
}
#if 0
QStringList FuncSwData::toStringList()
{
QStringList result;
QStringList qs;
result << swtch.toString();
result << funcToString();
if (func < FuncInstantTrim) {
result << QString("%1").arg(param);
}
else if (func==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
if (param>=0 && param<(int)qs.count())
result << qs.at(param);
else
result << QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
if (param>=0 && param<(int)qs.count())
result << qs.at(param);
else
result << QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
if (param>=0 && param<(int)qs.count())
result << qs.at(param);
else
result << QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if ((func==FuncVolume)|| (func==FuncPlayValue)) {
RawSource item(param);
result << item.toString();
}
else if ((func==FuncPlayPrompt) || (func==FuncPlayBoth)) {
if ( GetEepromInterface()->getCapability(VoicesAsNumbers)) {
result << QString("%1").arg(param);
} else {
result << paramarm;
}
}
else if ((func>FuncBackgroundMusicPause) && (func<FuncCount)) {
switch (adjustMode) {
case 0:
result << QObject::tr("Value ")+QString("%1").arg(param);
break;
case 1:
result << RawSource(param).toString();
break;
case 2:
result << RawSource(param).toString();
break;
case 3:
if (param==0) {
result << QObject::tr("Decr:")+QString(" -1");
}
else {
result << QObject::tr("Incr:")+QString(" +1");
}
break;
default:
break;
}
}
if (func==FuncPlaySound || func==FuncPlayHaptic || func==FuncPlayValue || func==FuncPlayPrompt || func==FuncPlayBoth || func==FuncBackgroundMusic) {
str.append(doTC(QString("%1").arg(g_model->funcSw[i].repeatParam),"green"));
} else {
str.append(doTC( "&nbsp;","green"));
}
if ((index<=FuncInstantTrim) || (index>FuncBackgroundMusicPause)) {
str.append(doTC((g_model->funcSw[i].enabled ? "ON" : "OFF"),"green"));
} else {
str.append(doTC( "---","green"));
}
return result;
}
#endif
QString FuncSwData::funcToString()
{
if (func >= FuncSafetyCh1 && func <= FuncSafetyCh32)
return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, func).toString());
else if (func == FuncTrainer)
return QObject::tr("Trainer");
else if (func == FuncTrainerRUD)
return QObject::tr("Trainer RUD");
else if (func == FuncTrainerELE)
return QObject::tr("Trainer ELE");
else if (func == FuncTrainerTHR)
return QObject::tr("Trainer THR");
else if (func == FuncTrainerAIL)
return QObject::tr("Trainer AIL");
else if (func == FuncInstantTrim)
return QObject::tr("Instant Trim");
else if (func == FuncPlaySound)
return QObject::tr("Play Sound");
else if (func == FuncPlayHaptic)
return QObject::tr("Play Haptic");
else if (func == FuncReset)
return QObject::tr("Reset");
else if (func == FuncVario)
return QObject::tr("Vario");
else if (func == FuncPlayPrompt)
return QObject::tr("Play Track");
else if (func == FuncPlayBoth)
return QObject::tr("Play Both");
else if (func == FuncPlayValue)
return QObject::tr("Play Value");
else if (func == FuncLogs)
return QObject::tr("Start Logs");
else if (func == FuncVolume)
return QObject::tr("Volume");
else if (func == FuncBacklight)
return QObject::tr("Backlight");
else if (func == FuncBackgroundMusic)
return QObject::tr("Background Music");
else if (func == FuncBackgroundMusicPause)
return QObject::tr("Background Music Pause");
else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast)
return QObject::tr("Adjust GV%1").arg(func-FuncAdjustGV1+1);
else {
return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is)
}
}
QString FuncSwData::paramToString()
{
QStringList qs;
if (func <= FuncInstantTrim) {
return QString("%1").arg(param);
}
else if (func==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
if (param>=0 && param<(int)qs.count())
return qs.at(param);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
if (param>=0 && param<(int)qs.count())
return qs.at(param);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
if (param>=0 && param<(int)qs.count())
return qs.at(param);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if ((func==FuncVolume)|| (func==FuncPlayValue)) {
RawSource item(param);
return item.toString();
}
else if ((func==FuncPlayPrompt) || (func==FuncPlayBoth)) {
if ( GetEepromInterface()->getCapability(VoicesAsNumbers)) {
return QString("%1").arg(param);
} else {
return paramarm;
}
}
else if ((func>FuncBackgroundMusicPause) && (func<FuncCount)) {
switch (adjustMode) {
case 0:
return QObject::tr("Value ")+QString("%1").arg(param);
break;
case 1:
return RawSource(param).toString();
break;
case 2:
return RawSource(param).toString();
break;
case 3:
if (param==0) {
return QObject::tr("Decr:")+QString(" -1");
}
else {
return QObject::tr("Incr:")+QString(" +1");
}
break;
default:
return "";
}
}
return "";
}
QString FuncSwData::repeatToString()
{
if (repeatParam==0) {
return QObject::tr("No repeat");
}
else {
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10;
return QObject::tr("%1 sec").arg(step*repeatParam);
}
}
GeneralSettings::GeneralSettings()
{
memset(this, 0, sizeof(GeneralSettings));
@@ -497,7 +871,8 @@ void ModelData::clear()
if (IS_TARANIS(board)) {
moduleData[0].protocol=PXX_XJT_X16;
moduleData[1].protocol=OFF;
} else {
}
else {
moduleData[0].protocol=PPM;
moduleData[1].protocol=OFF;
}
@@ -505,20 +880,17 @@ void ModelData::clear()
phaseData[i].clear();
clearInputs();
clearMixes();
for(int i=0; i<4; i++){
mixData[i].destCh = i+1;
mixData[i].srcRaw = RawSource(SOURCE_TYPE_STICK, i);
mixData[i].weight = 100;
}
for (int i=0; i<C9X_NUM_CHNOUT; i++)
limitData[i].clear();
for (int i=0; i<NUM_STICKS; i++)
expoData[i].clear();
for (int i=0; i<C9X_NUM_CSW; i++)
customSw[i].clear();
for (int i=0; i<C9X_MAX_CURVES; i++) {
for (int i=0; i<C9X_MAX_CURVES; i++)
curves[i].clear(5);
}
for (int i=0; i<2; i++)
timers[i].clear();
swashRingData.clear();
frsky.clear();
+66 -91
View File
@@ -72,7 +72,6 @@ const uint8_t modn12x3[4][4]= {
#define C9X_MAX_POINTS 17
#define C9X_MAX_GVARS 9
#define C9X_MAX_ENCODERS 2
#define NUM_SAFETY_CHNOUT 16
#define C9X_NUM_CHNOUT 32 // number of real output channels
#define C9X_NUM_CSW 32 // number of custom switches
#define C9X_MAX_CUSTOM_FUNCTIONS 32 // number of functions assigned to switches
@@ -147,44 +146,6 @@ enum EnumKeys {
#endif
};
enum CSFunction {
CS_FN_OFF,
CS_FN_VPOS,
CS_FN_VNEG,
CS_FN_APOS,
CS_FN_ANEG,
CS_FN_AND,
CS_FN_OR,
CS_FN_XOR,
CS_FN_EQUAL,
CS_FN_NEQUAL,
CS_FN_GREATER,
CS_FN_LESS,
CS_FN_EGREATER,
CS_FN_ELESS,
CS_FN_DPOS,
CS_FN_DAPOS,
CS_FN_VEQUAL, // added at the end to avoid everything renumbered
CS_FN_TIM,
CS_FN_MAXF
};
enum CSFunctionFamily {
CS_FAMILY_VOFS,
CS_FAMILY_VBOOL,
CS_FAMILY_VCOMP,
CS_FAMILY_TIMERS
};
inline CSFunctionFamily getCSFunctionFamily(int fn)
{
if (fn==CS_FN_TIM) {
return (CS_FAMILY_TIMERS);
} else {
return ((fn<CS_FN_AND || fn>CS_FN_ELESS) ? CS_FAMILY_VOFS : (fn<CS_FN_EQUAL ? CS_FAMILY_VBOOL : CS_FAMILY_VCOMP));
}
}
#define CHAR_FOR_NAMES " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-."
#define CHAR_FOR_NAMES_REGEX "[ A-Za-z0-9_.-,]*"
@@ -357,13 +318,11 @@ enum RawSwitchType {
SWITCH_TYPE_SWITCH,
SWITCH_TYPE_VIRTUAL,
SWITCH_TYPE_MULTIPOS_POT,
SWITCH_TYPE_MOMENT_SWITCH,
SWITCH_TYPE_MOMENT_VIRTUAL,
SWITCH_TYPE_TRIM,
SWITCH_TYPE_ROTARY_ENCODER,
SWITCH_TYPE_ON,
SWITCH_TYPE_OFF,
SWITCH_TYPE_ONM,
SWITCH_TYPE_TRN,
SWITCH_TYPE_REA,
SWITCH_TYPE_TIMER_MODE
};
class RawSwitch {
@@ -617,30 +576,63 @@ class MixData {
void clear() { memset(this, 0, sizeof(MixData)); }
};
class CustomSwData { // Custom Switches data
public:
CustomSwData() { clear(); }
int val1; //input
int val2; //offset
unsigned int func;
unsigned int delay;
unsigned int duration;
unsigned int andsw;
void clear() { memset(this, 0, sizeof(CustomSwData)); }
enum CSFunction {
LS_FN_OFF,
LS_FN_VPOS,
LS_FN_VNEG,
LS_FN_APOS,
LS_FN_ANEG,
LS_FN_AND,
LS_FN_OR,
LS_FN_XOR,
LS_FN_EQUAL,
LS_FN_NEQUAL,
LS_FN_GREATER,
LS_FN_LESS,
LS_FN_EGREATER,
LS_FN_ELESS,
LS_FN_DPOS,
LS_FN_DAPOS,
LS_FN_VEQUAL, // added at the end to avoid everything renumbered
LS_FN_TIMER,
LS_FN_STICKY,
LS_FN_STAY,
// later ... LS_FN_RANGE,
LS_FN_MAX
};
class SafetySwData { // Custom Switches data
public:
SafetySwData() { clear(); }
RawSwitch swtch;
int val;
enum CSFunctionFamily {
LS_FAMILY_VOFS,
LS_FAMILY_VBOOL,
LS_FAMILY_VCOMP,
LS_FAMILY_TIMER,
LS_FAMILY_STICKY,
LS_FAMILY_STAY,
};
void clear() { memset(this, 0, sizeof(SafetySwData)); }
class LogicalSwitchData { // Custom Switches data
public:
LogicalSwitchData(unsigned int func=0)
{
clear();
this->func = func;
}
unsigned int func;
int val1;
int val2;
int val3;
unsigned int delay;
unsigned int duration;
int andsw;
void clear() { memset(this, 0, sizeof(LogicalSwitchData)); }
CSFunctionFamily getFunctionFamily();
QString funcToString();
QString toString(const ModelData & model);
};
enum AssignFunc {
FuncSafetyCh1 = 0,
FuncSafetyCh16 = FuncSafetyCh1+15,
FuncSafetyCh32 = FuncSafetyCh1+C9X_NUM_CHNOUT-1,
FuncTrainer,
FuncTrainerRUD,
FuncTrainerELE,
@@ -666,7 +658,7 @@ enum AssignFunc {
class FuncSwData { // Function Switches data
public:
FuncSwData() { clear(); }
FuncSwData(AssignFunc func=FuncSafetyCh1) { clear(); this->func = func; }
RawSwitch swtch;
AssignFunc func;
int param;
@@ -675,6 +667,10 @@ class FuncSwData { // Function Switches data
unsigned int adjustMode;
int repeatParam;
void clear() { memset(this, 0, sizeof(FuncSwData)); }
QString funcToString();
QString paramToString();
QString repeatToString();
QStringList toStringList();
};
class PhaseData {
@@ -809,32 +805,17 @@ class MavlinkData {
void clear() { memset(this, 0, sizeof(MavlinkData)); }
};
enum TimerMode {
TMRMODE_OFF=0,
TMRMODE_ABS,
TMRMODE_THs,
TMRMODE_THp,
TMRMODE_THt,
TMRMODE_FIRST_SWITCH,
TMRMODE_FIRST_MOMENT_SWITCH = TMRMODE_FIRST_SWITCH+64,
TMRMODE_FIRST_CHPERC = TMRMODE_FIRST_MOMENT_SWITCH+64,
TMRMODE_FIRST_NEG_SWITCH=-TMRMODE_FIRST_SWITCH,
TMRMODE_FIRST_NEG_MOMENT_SWITCH=-TMRMODE_FIRST_MOMENT_SWITCH,
/* sw/!sw, !m_sw/!m_sw */
};
class TimerData {
public:
TimerData() { clear(); }
TimerMode mode; // timer trigger source -> off, abs, THs, TH%, THt, sw/!sw, !m_sw/!m_sw
RawSwitch mode;
bool minuteBeep;
unsigned int countdownBeep;
bool dir; // 0=>Count Down, 1=>Count Up
unsigned int val;
bool persistent;
int pvalue;
void clear() { memset(this, 0, sizeof(TimerData)); }
void clear() { memset(this, 0, sizeof(TimerData)); mode = RawSwitch(SWITCH_TYPE_TIMER_MODE, 0); }
};
enum Protocol {
@@ -895,13 +876,11 @@ class ModelData {
ExpoData expoData[C9X_MAX_EXPOS];
CurveData curves[C9X_MAX_CURVES];
CustomSwData customSw[C9X_NUM_CSW];
LogicalSwitchData customSw[C9X_NUM_CSW];
FuncSwData funcSw[C9X_MAX_CUSTOM_FUNCTIONS];
SafetySwData safetySw[C9X_NUM_CHNOUT];
SwashRingData swashRingData;
unsigned int thrTraceSrc;
int8_t traineron; // 0 disable trainer, 1 allow trainer
int8_t t2throttle; // Start timer2 using throttle
unsigned int modelId;
unsigned int switchWarningStates;
// TODO structure
@@ -963,10 +942,10 @@ enum Capability {
Pots,
Switches,
SwitchesPositions,
CustomSwitches,
LogicalSwitches,
CustomAndSwitches,
HasNegAndSwitches,
CustomSwitchesExt,
LogicalSwitchesExt,
RotaryEncoders,
Outputs,
ChannelsName,
@@ -1100,10 +1079,6 @@ class EEPROMInterface
virtual int isAvailable(Protocol proto, int port=0) = 0;
virtual bool isAvailable(const RawSwitch & swtch, UseContext context) { return true; }
virtual bool isAvailable(const RawSource & source, UseContext context) { return true; }
virtual SimulatorInterface * getSimulator() = 0;
virtual const int getEEpromSize() = 0;
@@ -1185,14 +1160,14 @@ inline void applyStickModeToModel(ModelData &model, unsigned int mode)
// virtual switches
for (int i=0; i<C9X_NUM_CSW; i++) {
RawSource source;
switch (getCSFunctionFamily(model.customSw[i].func)) {
case CS_FAMILY_VCOMP:
switch (model.customSw[i].getFunctionFamily()) {
case LS_FAMILY_VCOMP:
source = RawSource(model.customSw[i].val2);
if (source.type == SOURCE_TYPE_STICK)
source.index = applyStickMode(source.index + 1, mode) - 1;
model.customSw[i].val2 = source.toValue();
// no break
case CS_FAMILY_VOFS:
case LS_FAMILY_VOFS:
source = RawSource(model.customSw[i].val1);
if (source.type == SOURCE_TYPE_STICK)
source.index = applyStickMode(source.index + 1, mode) - 1;
+16 -21
View File
@@ -17,9 +17,9 @@ RawSwitch er9xToSwitch(int8_t sw)
else if (sw == -22)
return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 22+9)
return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-22 : sw+22);
return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-22 : sw+22);
else
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9);
return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9);
}
t_Er9xTrainerMix::t_Er9xTrainerMix()
@@ -269,22 +269,22 @@ RawSource er9xToSource(int8_t value)
}
}
Er9xCustomSwData::operator CustomSwData ()
Er9xLogicalSwitchData::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = er9xToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = er9xToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = er9xToSwitch(v1).toValue();
c9x.val2 = er9xToSwitch(v2).toValue();
}
@@ -298,14 +298,6 @@ t_Er9xSafetySwData::t_Er9xSafetySwData()
memset(this, 0, sizeof(t_Er9xSafetySwData));
}
t_Er9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = er9xToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData()
{
memset(this, 0, sizeof(t_Er9xFrSkyChannelData));
@@ -343,10 +335,11 @@ t_Er9xFrSkyData::operator FrSkyData ()
return c9x;
}
TimerMode getEr9xTimerMode(int mode)
RawSwitch getEr9xTimerMode(int mode)
{
/*
if (mode <= -33)
return TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+33));
return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+33));
else if (mode <= -1)
return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 16)
@@ -354,7 +347,9 @@ TimerMode getEr9xTimerMode(int mode)
else if (mode < 16+21)
return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16));
else
return TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-16-21));
return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16-21));
*/
return RawSwitch();
}
t_Er9xModelData::operator ModelData ()
@@ -381,7 +376,7 @@ t_Er9xModelData::operator ModelData ()
break;
}
c9x.traineron= traineron;
c9x.t2throttle = t2throttle;
// c9x.t2throttle = t2throttle;
c9x.moduleData[0].ppmFrameLength=ppmFrameLength;
c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
c9x.thrTrim = thrTrim;
@@ -471,8 +466,8 @@ t_Er9xModelData::operator ModelData ()
for (int i=0; i<ER9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i];
// for (int i=0; i<ER9X_NUM_CHNOUT; i++)
// c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto;
+5 -6
View File
@@ -154,21 +154,20 @@ PACK(typedef struct t_Er9xMixData {
}) Er9xMixData;
PACK(typedef struct t_Er9xCustomSwData { // Custom Switches data
PACK(typedef struct t_Er9xLogicalSwitchData { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func:4;
uint8_t andsw:4;
operator CustomSwData();
t_Er9xCustomSwData() { memset(this, 0, sizeof(t_Er9xCustomSwData)); }
}) Er9xCustomSwData;
operator LogicalSwitchData();
t_Er9xLogicalSwitchData() { memset(this, 0, sizeof(t_Er9xLogicalSwitchData)); }
}) Er9xLogicalSwitchData;
PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data
int8_t swtch;
int8_t val;
operator SafetySwData();
t_Er9xSafetySwData();
}) Er9xSafetySwData;
@@ -242,7 +241,7 @@ PACK(typedef struct t_Er9xModelData {
int8_t trim[4];
int8_t curves5[ER9X_MAX_CURVE5][5];
int8_t curves9[ER9X_MAX_CURVE9][9];
Er9xCustomSwData customSw[ER9X_NUM_CSW];
Er9xLogicalSwitchData customSw[ER9X_NUM_CSW];
uint8_t frSkyVoltThreshold ;
int8_t tmrModeB;
uint8_t numVoice;
@@ -75,11 +75,11 @@ inline void applyStickModeToModel(Er9xModelData & model, unsigned int mode)
for (int i=0; i<ER9X_MAX_MIXERS; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ER9X_NUM_CSW; i++) {
switch (getCSFunctionFamily(model.customSw[i].func)) {
case CS_FAMILY_VCOMP:
switch (LogicalSwitchData(model.customSw[i].func).getFunctionFamily()) {
case LS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break
case CS_FAMILY_VOFS:
case LS_FAMILY_VOFS:
model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode);
break;
default:
@@ -239,7 +239,7 @@ int Er9xInterface::getCapability(const Capability capability)
return 9;
case CustomFunctions:
return 0;
case CustomSwitches:
case LogicalSwitches:
return 12;
case CustomAndSwitches:
return 5;
@@ -5,14 +5,12 @@
extern RawSwitch er9xToSwitch(int8_t sw);
TimerMode getErSky9xTimerMode(int mode)
RawSwitch getErSky9xTimerMode(int mode)
{
if (mode<4)
return TimerMode(mode);
else if (mode < 20)
return TimerMode(TMRMODE_FIRST_CHPERC+(mode-4));
return RawSwitch(SWITCH_TYPE_TIMER_MODE, mode);
else
return TimerMode(0);
return RawSwitch();
}
RawSwitch ersky9xToSwitch(int8_t sw)
@@ -29,9 +27,9 @@ RawSwitch ersky9xToSwitch(int8_t sw)
else if (sw == -34)
return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 34+9)
return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-34 : sw+34);
return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-34 : sw+34);
else
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-34-9 : sw+34+9);
return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-34-9 : sw+34+9);
}
t_Ersky9xTrainerMix::t_Ersky9xTrainerMix()
@@ -355,22 +353,22 @@ RawSource ersky9xToSource_v11(int8_t value)
}
}
Ersky9xCustomSwData_v10::operator CustomSwData ()
Ersky9xLogicalSwitchData_v10::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = ersky9xToSource_v10(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = ersky9xToSource_v10(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = er9xToSwitch(v1).toValue();
c9x.val2 = er9xToSwitch(v2).toValue();
}
@@ -378,22 +376,22 @@ Ersky9xCustomSwData_v10::operator CustomSwData ()
return c9x;
}
Ersky9xCustomSwData_v11::operator CustomSwData ()
Ersky9xLogicalSwitchData_v11::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = ersky9xToSource_v11(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = ersky9xToSource_v11(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = er9xToSwitch(v1).toValue();
c9x.val2 = er9xToSwitch(v2).toValue();
}
@@ -406,27 +404,11 @@ t_Ersky9xSafetySwData_v10::t_Ersky9xSafetySwData_v10()
memset(this, 0, sizeof(t_Ersky9xSafetySwData_v10));
}
t_Ersky9xSafetySwData_v10::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = er9xToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Ersky9xSafetySwData_v11::t_Ersky9xSafetySwData_v11()
{
memset(this, 0, sizeof(t_Ersky9xSafetySwData_v11));
}
t_Ersky9xSafetySwData_v11::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = ersky9xToSwitch(opt.ss.swtch);
c9x.val = opt.ss.val;
return c9x;
}
t_Ersky9xFrSkyChannelData_v10::t_Ersky9xFrSkyChannelData_v10()
{
memset(this, 0, sizeof(t_Ersky9xFrSkyChannelData_v10));
@@ -612,8 +594,8 @@ t_Ersky9xModelData_v10::operator ModelData ()
for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++)
c9x.customSw[i] = customSw[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V10; i++)
c9x.safetySw[i] = safetySw[i];
// for (int i=0; i<ERSKY9X_NUM_CHNOUT_V10; i++)
// c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto;
@@ -733,8 +715,8 @@ t_Ersky9xModelData_v11::operator ModelData ()
for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++)
c9x.customSw[i] = customSw[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++)
c9x.safetySw[i] = safetySw[i];
// for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++)
// c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto;
+11 -14
View File
@@ -19,8 +19,7 @@
#include <inttypes.h>
#include "eeprominterface.h"
extern TimerMode getEr9xTimerMode(int mode);
extern int setEr9xTimerMode(TimerMode mode);
extern RawSwitch getEr9xTimerMode(int mode);
//eeprom data
#define ERSKY9X_MAX_MIXERS_V10 32
@@ -186,31 +185,30 @@ PACK(typedef struct t_Ersky9xMixData_v11 {
t_Ersky9xMixData_v11();
}) Ersky9xMixData_v11;
PACK(typedef struct t_Ersky9xCustomSwData_v10 { // Custom Switches data
PACK(typedef struct t_Ersky9xLogicalSwitchData_v10 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Ersky9xCustomSwData_v10() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v10)); }
}) Ersky9xCustomSwData_v10;
operator LogicalSwitchData();
t_Ersky9xLogicalSwitchData_v10() { memset(this, 0, sizeof(t_Ersky9xLogicalSwitchData_v10)); }
}) Ersky9xLogicalSwitchData_v10;
PACK(typedef struct t_Ersky9xCustomSwData_v11 { // Custom Switches data
PACK(typedef struct t_Ersky9xLogicalSwitchData_v11 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
uint8_t andsw;
uint8_t res ;
operator CustomSwData();
t_Ersky9xCustomSwData_v11() { memset(this, 0, sizeof(t_Ersky9xCustomSwData_v11)); }
}) Ersky9xCustomSwData_v11;
operator LogicalSwitchData();
t_Ersky9xLogicalSwitchData_v11() { memset(this, 0, sizeof(t_Ersky9xLogicalSwitchData_v11)); }
}) Ersky9xLogicalSwitchData_v11;
PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data
int8_t swtch;
int8_t val;
operator SafetySwData();
t_Ersky9xSafetySwData_v10();
}) Ersky9xSafetySwData_v10;
@@ -230,7 +228,6 @@ PACK(typedef struct t_Ersky9xSafetySwData_v11 { // Custom Switches data
} vs ;
} opt ;
operator SafetySwData();
t_Ersky9xSafetySwData_v11();
}) Ersky9xSafetySwData_v11;
@@ -363,7 +360,7 @@ PACK(typedef struct t_Ersky9xModelData_v10 {
int8_t trim[4];
int8_t curves5[ERSKY9X_MAX_CURVE5][5];
int8_t curves9[ERSKY9X_MAX_CURVE9][9];
Ersky9xCustomSwData_v10 customSw[ERSKY9X_NUM_CSW_V10];
Ersky9xLogicalSwitchData_v10 customSw[ERSKY9X_NUM_CSW_V10];
uint8_t frSkyVoltThreshold ;
uint8_t res3[2];
Ersky9xSafetySwData_v10 safetySw[ERSKY9X_NUM_CHNOUT_V10];
@@ -412,7 +409,7 @@ PACK(typedef struct t_Ersky9xModelData_v11 {
int8_t curves5[ERSKY9X_MAX_CURVE5][5];
int8_t curves9[ERSKY9X_MAX_CURVE9][9];
int8_t curvexy[18];
Ersky9xCustomSwData_v11 customSw[ERSKY9X_NUM_CSW_V11];
Ersky9xLogicalSwitchData_v11 customSw[ERSKY9X_NUM_CSW_V11];
uint8_t frSkyVoltThreshold ;
uint8_t bt_telemetry;
uint8_t numVoice; // 0-16, rest are Safety switches
@@ -74,11 +74,11 @@ inline void applyStickModeToModel(Ersky9xModelData_v10 & model, unsigned int mod
for (int i=0; i<ERSKY9X_MAX_MIXERS_V10; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++) {
switch (getCSFunctionFamily(model.customSw[i].func)) {
case CS_FAMILY_VCOMP:
switch (LogicalSwitchData(model.customSw[i].func).getFunctionFamily()) {
case LS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break
case CS_FAMILY_VOFS:
case LS_FAMILY_VOFS:
model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode);
break;
default:
@@ -106,11 +106,11 @@ inline void applyStickModeToModel(Ersky9xModelData_v11 & model, unsigned int mod
for (int i=0; i<ERSKY9X_MAX_MIXERS_V11; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++) {
switch (getCSFunctionFamily(model.customSw[i].func)) {
case CS_FAMILY_VCOMP:
switch (LogicalSwitchData(model.customSw[i].func).getFunctionFamily()) {
case LS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break
case CS_FAMILY_VOFS:
case LS_FAMILY_VOFS:
model.customSw[i].v1 = applyStickMode(model.customSw[i].v1, mode);
break;
default:
@@ -285,7 +285,7 @@ int Ersky9xInterface::getCapability(const Capability capability)
return 9;
case CustomFunctions:
return 0;
case CustomSwitches:
case LogicalSwitches:
return ERSKY9X_NUM_CSW_V11;
case CustomAndSwitches:
return 1;
@@ -301,22 +301,22 @@ RawSource gruvin9xToSource(int8_t value)
}
}
Gruvin9xCustomSwData::operator CustomSwData ()
Gruvin9xLogicalSwitchData::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = gruvin9xToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = gruvin9xToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = gruvin9xToSwitch(v1).toValue();
c9x.val2 = gruvin9xToSwitch(v2).toValue();
}
@@ -332,14 +332,6 @@ Gruvin9xFuncSwData::operator FuncSwData ()
return c9x;
}
t_Gruvin9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = gruvin9xToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Gruvin9xSwashRingData::t_Gruvin9xSwashRingData()
{
memset(this, 0, sizeof(t_Gruvin9xSwashRingData));
@@ -381,7 +373,7 @@ t_Gruvin9xPhaseData_v106::operator PhaseData ()
return c9x;
}
extern TimerMode getEr9xTimerMode(int mode);
extern RawSwitch getEr9xTimerMode(int mode);
t_Gruvin9xTimerData::operator TimerData ()
{
@@ -489,8 +481,8 @@ t_Gruvin9xModelData_v102::operator ModelData ()
for (int i=0; i<G9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i];
// for (int i=0; i<G9X_NUM_CHNOUT; i++)
// c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR;
c9x.frsky = frsky;
return c9x;
@@ -560,8 +552,8 @@ t_Gruvin9xModelData_v103::operator ModelData ()
for (int i=0; i<G9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i];
// for (int i=0; i<G9X_NUM_CHNOUT; i++)
// c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR;
c9x.frsky = frsky;
return c9x;
@@ -650,8 +642,8 @@ t_Gruvin9xModelData_v105::operator ModelData ()
c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_FSW; i++)
c9x.funcSw[i] = funcSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i];
// for (int i=0; i<G9X_NUM_CHNOUT; i++)
// c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR;
c9x.frsky = frsky;
@@ -734,8 +726,8 @@ t_Gruvin9xModelData_v106::operator ModelData ()
c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_FSW; i++)
c9x.funcSw[i] = funcSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i];
// for (int i=0; i<G9X_NUM_CHNOUT; i++)
// c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR;
c9x.frsky = frsky;
@@ -186,20 +186,19 @@ PACK(typedef struct t_Gruvin9xMixData {
t_Gruvin9xMixData();
}) Gruvin9xMixData;
PACK(typedef struct t_Gruvin9xCustomSwData { // Custom Switches data
PACK(typedef struct t_Gruvin9xLogicalSwitchData { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Gruvin9xCustomSwData() { memset(this, 0, sizeof(t_Gruvin9xCustomSwData)); }
}) Gruvin9xCustomSwData;
operator LogicalSwitchData();
t_Gruvin9xLogicalSwitchData() { memset(this, 0, sizeof(t_Gruvin9xLogicalSwitchData)); }
}) Gruvin9xLogicalSwitchData;
PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data
int8_t swtch;
int8_t val;
operator SafetySwData();
t_Gruvin9xSafetySwData() { memset(this, 0, sizeof(t_Gruvin9xSafetySwData)); }
}) Gruvin9xSafetySwData;
@@ -310,7 +309,7 @@ PACK(typedef struct t_Gruvin9xModelData_v102 {
Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW];
Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xSwashRingData swashR;
Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES];
@@ -342,7 +341,7 @@ PACK(typedef struct t_Gruvin9xModelData_v103 {
Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW];
Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xSwashRingData swashR;
Gruvin9xPhaseData_v102 phaseData[G9X_MAX_PHASES];
@@ -374,7 +373,7 @@ PACK(typedef struct t_Gruvin9xModelData_v105 {
Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW];
Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xFuncSwData funcSw[G9X_NUM_FSW];
Gruvin9xSwashRingData swashR;
@@ -406,7 +405,7 @@ PACK(typedef struct t_Gruvin9xModelData_v106 {
Gruvin9xExpoData expoData[G9X_MAX_EXPOS];
int8_t curves5[G9X_MAX_CURVE5][5];
int8_t curves9[G9X_MAX_CURVE9][9];
Gruvin9xCustomSwData customSw[G9X_NUM_CSW];
Gruvin9xLogicalSwitchData customSw[G9X_NUM_CSW];
Gruvin9xSafetySwData safetySw[G9X_NUM_CHNOUT];
Gruvin9xFuncSwData funcSw[G9X_NUM_FSW];
Gruvin9xSwashRingData swashR;
@@ -237,7 +237,7 @@ int Gruvin9xInterface::getCapability(const Capability capability)
return 9;
case CustomFunctions:
return 12;
case CustomSwitches:
case LogicalSwitches:
return 12;
case CSFunc:
return 13;
@@ -293,22 +293,22 @@ RawSource open9xV4209ToSource(int8_t value)
}
}
Open9xGruvin9xCustomSwData_v207::operator CustomSwData ()
Open9xGruvin9xLogicalSwitchData_v207::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xV4207ToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = open9xV4207ToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xStockToSwitch(v1).toValue();
c9x.val2 = open9xStockToSwitch(v2).toValue();
}
@@ -316,22 +316,22 @@ Open9xGruvin9xCustomSwData_v207::operator CustomSwData ()
return c9x;
}
Open9xGruvin9xCustomSwData_v209::operator CustomSwData ()
Open9xGruvin9xLogicalSwitchData_v209::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xV4209ToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) {
if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) {
c9x.val2 = open9xV4209ToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xStockToSwitch(v1).toValue();
c9x.val2 = open9xStockToSwitch(v2).toValue();
}
@@ -110,27 +110,27 @@ PACK(typedef struct t_Open9xGruvin9xMixData_v211 {
t_Open9xGruvin9xMixData_v211() { memset(this, 0, sizeof(t_Open9xGruvin9xMixData_v211)); }
}) Open9xGruvin9xMixData_v211;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v207 { // Custom Switches data
PACK(typedef struct t_Open9xGruvin9xLogicalSwitchData_v207 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xGruvin9xCustomSwData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v207)); }
operator LogicalSwitchData();
t_Open9xGruvin9xLogicalSwitchData_v207() { memset(this, 0, sizeof(t_Open9xGruvin9xLogicalSwitchData_v207)); }
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v207;
}) Open9xGruvin9xLogicalSwitchData_v207;
PACK(typedef struct t_Open9xGruvin9xCustomSwData_v209 { // Custom Switches data
PACK(typedef struct t_Open9xGruvin9xLogicalSwitchData_v209 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xGruvin9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xCustomSwData_v209)); }
operator LogicalSwitchData();
t_Open9xGruvin9xLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xGruvin9xLogicalSwitchData_v209)); }
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Open9xGruvin9xCustomSwData_v209;
}) Open9xGruvin9xLogicalSwitchData_v209;
PACK(typedef struct t_Open9xGruvin9xFuncSwData_v203 { // Function Switches data
int8_t swtch; // input
@@ -194,7 +194,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v207 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW];
Open9xGruvin9xLogicalSwitchData_v207 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v208 swashR;
Open9xGruvin9xPhaseData_v207 phaseData[O9X_MAX_PHASES];
@@ -228,7 +228,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v208 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xGruvin9xCustomSwData_v207 customSw[O9X_NUM_CSW];
Open9xGruvin9xLogicalSwitchData_v207 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v208 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
@@ -267,7 +267,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v209 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v209 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
@@ -307,7 +307,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v210 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS];
Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v209 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
@@ -345,7 +345,7 @@ PACK(typedef struct t_Open9xGruvin9xModelData_v211 {
Open9xExpoData_v211 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS];
Open9xGruvin9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xGruvin9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xGruvin9xSwashRingData_v209 swashR;
Open9xGruvin9xPhaseData_v208 phaseData[O9X_MAX_PHASES];
@@ -19,13 +19,13 @@ RawSwitch open9xArmToSwitch(int8_t sw)
else if (sw == 42)
return RawSwitch(SWITCH_TYPE_ON);
else if (sw == 84)
return RawSwitch(SWITCH_TYPE_ONM);
return RawSwitch(SWITCH_TYPE_ON);
else if (sw == -42)
return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 42+9)
return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-42 : sw+42);
return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-42 : sw+42);
else
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-42-9 : sw+42+9);
return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-42-9 : sw+42+9);
}
RawSource open9xArm208ToSource(int8_t value)
@@ -124,9 +124,9 @@ RawSource open9xArm210ToSource(int8_t value)
t_Open9xArmTimerData_v202::operator TimerData ()
{
TimerData c9x;
/*
if (mode <= -42)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+22));
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22));
else if (mode <= -1)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 5)
@@ -134,8 +134,8 @@ t_Open9xArmTimerData_v202::operator TimerData ()
else if (mode < 5+41)
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
else
c9x.mode = TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-5-21));
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
*/
c9x.val = val;
c9x.persistent = false;
c9x.dir = (val == 0);
@@ -501,22 +501,22 @@ t_Open9xArmMixData_v212::operator MixData ()
return c9x;
}
t_Open9xArmCustomSwData_v208::operator CustomSwData ()
t_Open9xArmLogicalSwitchData_v208::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xArm208ToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = open9xArm208ToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xArmToSwitch(v1).toValue();
c9x.val2 = open9xArmToSwitch(v2).toValue();
}
@@ -524,22 +524,22 @@ t_Open9xArmCustomSwData_v208::operator CustomSwData ()
return c9x;
}
t_Open9xArmCustomSwData_v209::operator CustomSwData ()
t_Open9xArmLogicalSwitchData_v209::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xArm209ToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = open9xArm209ToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xArmToSwitch(v1).toValue();
c9x.val2 = open9xArmToSwitch(v2).toValue();
}
@@ -547,24 +547,24 @@ t_Open9xArmCustomSwData_v209::operator CustomSwData ()
return c9x;
}
t_Open9xArmCustomSwData_v210::operator CustomSwData ()
t_Open9xArmLogicalSwitchData_v210::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
c9x.delay = delay;
c9x.duration = duration;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xArm210ToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) {
if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) {
c9x.val2 = open9xArm210ToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xArmToSwitch(v1).toValue();
c9x.val2 = open9xArmToSwitch(v2).toValue();
}
@@ -577,7 +577,7 @@ t_Open9xArmFuncSwData_v208::operator FuncSwData ()
FuncSwData c9x;
c9x.swtch = open9xArmToSwitch(swtch);
c9x.func = (AssignFunc)(func);
if (c9x.func <= FuncSafetyCh16) {
if (c9x.func <= FuncSafetyCh32) {
c9x.enabled=param & 0x01;
c9x.param = (param>>1)<<1;
}
@@ -190,34 +190,34 @@ PACK(typedef struct t_Open9xArmPhaseData_v212 {
t_Open9xArmPhaseData_v212() { memset(this, 0, sizeof(t_Open9xArmPhaseData_v212)); }
}) Open9xArmPhaseData_v212;
PACK(typedef struct t_Open9xArmCustomSwData_v208 { // Custom Switches data
PACK(typedef struct t_Open9xArmLogicalSwitchData_v208 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xArmCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v208)); }
}) Open9xArmCustomSwData_v208;
operator LogicalSwitchData();
t_Open9xArmLogicalSwitchData_v208() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v208)); }
}) Open9xArmLogicalSwitchData_v208;
PACK(typedef struct t_Open9xArmCustomSwData_v209 { // Custom Switches data
PACK(typedef struct t_Open9xArmLogicalSwitchData_v209 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xArmCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v209)); }
}) Open9xArmCustomSwData_v209;
operator LogicalSwitchData();
t_Open9xArmLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v209)); }
}) Open9xArmLogicalSwitchData_v209;
PACK(typedef struct t_Open9xArmCustomSwData_v210 { // Custom Switches data
PACK(typedef struct t_Open9xArmLogicalSwitchData_v210 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
uint8_t delay;
uint8_t duration;
operator CustomSwData();
t_Open9xArmCustomSwData_v210() { memset(this, 0, sizeof(t_Open9xArmCustomSwData_v210)); }
}) Open9xArmCustomSwData_v210;
operator LogicalSwitchData();
t_Open9xArmLogicalSwitchData_v210() { memset(this, 0, sizeof(t_Open9xArmLogicalSwitchData_v210)); }
}) Open9xArmLogicalSwitchData_v210;
PACK(typedef struct t_Open9xArmFuncSwData_v208 { // Function Switches data
int8_t swtch; // input
@@ -343,7 +343,7 @@ PACK(typedef struct t_Open9xArmModelData_v208 {
Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xArmCustomSwData_v208 customSw[O9X_ARM_NUM_CSW];
Open9xArmLogicalSwitchData_v208 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v208 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
@@ -382,7 +382,7 @@ PACK(typedef struct t_Open9xArmModelData_v209 {
Open9xArmExpoData_v208 expoData[O9X_ARM_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xArmCustomSwData_v209 customSw[O9X_ARM_NUM_CSW];
Open9xArmLogicalSwitchData_v209 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v208 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v209 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
@@ -422,7 +422,7 @@ PACK(typedef struct t_Open9xArmModelData_v210 {
Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v210 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v209 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
@@ -461,7 +461,7 @@ PACK(typedef struct t_Open9xArmModelData_v211 {
Open9xArmExpoData_v210 expoData[O9X_ARM_MAX_EXPOS];
int16_t curves[O9X_ARM_MAX_CURVES];
int8_t points[O9X_ARM_NUM_POINTS];
Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v209 swashR;
Open9xArmPhaseData_v208 phaseData[O9X_ARM_MAX_PHASES];
@@ -499,7 +499,7 @@ PACK(typedef struct t_Open9xArmModelData_v212 {
Open9xArmExpoData_v212 expoData[O9X_ARM_MAX_EXPOS];
int16_t curves[O9X_ARM_MAX_CURVES];
int8_t points[O9X_ARM_NUM_POINTS];
Open9xArmCustomSwData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmLogicalSwitchData_v210 customSw[O9X_ARM_NUM_CSW];
Open9xArmFuncSwData_v211 funcSw[O9X_ARM_NUM_FSW];
Open9xArmSwashRingData_v210 swashR;
Open9xArmPhaseData_v212 phaseData[O9X_ARM_MAX_PHASES];
@@ -74,13 +74,13 @@ RawSwitch open9xStockToSwitch(int8_t sw)
else if (sw == 22)
return RawSwitch(SWITCH_TYPE_ON);
else if (sw == 44)
return RawSwitch(SWITCH_TYPE_ONM);
return RawSwitch(SWITCH_TYPE_ON);
else if (sw == -22)
return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 22+9)
return RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, sw > 0 ? sw-22 : sw+22);
return RawSwitch(SWITCH_TYPE_SWITCH, sw > 0 ? sw-22 : sw+22);
else
return RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9);
return RawSwitch(SWITCH_TYPE_VIRTUAL, sw > 0 ? sw-22-9 : sw+22+9);
}
t_Open9xExpoData_v201::operator ExpoData ()
@@ -518,22 +518,22 @@ RawSource open9xStock209ToSource(int8_t value)
}
}
Open9xCustomSwData_v208::operator CustomSwData ()
Open9xLogicalSwitchData_v208::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9x208ToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = open9x208ToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xStockToSwitch(v1).toValue();
c9x.val2 = open9xStockToSwitch(v2).toValue();
}
@@ -541,22 +541,22 @@ Open9xCustomSwData_v208::operator CustomSwData ()
return c9x;
}
Open9xCustomSwData_v209::operator CustomSwData ()
Open9xLogicalSwitchData_v209::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = func;
c9x.val1 = v1;
c9x.val2 = v2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = open9xStock209ToSource(v1).toValue();
}
if (c9x.func >= CS_FN_EQUAL && c9x.func <= CS_FN_ELESS) {
if (c9x.func >= LS_FN_EQUAL && c9x.func <= LS_FN_ELESS) {
c9x.val2 = open9xStock209ToSource(v2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = open9xStockToSwitch(v1).toValue();
c9x.val2 = open9xStockToSwitch(v2).toValue();
}
@@ -662,14 +662,6 @@ t_Open9xFuncSwData_v210::operator FuncSwData ()
return c9x;
}
t_Open9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = open9xStockToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Open9xSwashRingData_v208::operator SwashRingData ()
{
SwashRingData c9x;
@@ -709,7 +701,7 @@ t_Open9xPhaseData_v201::operator PhaseData ()
t_Open9xTimerData_v201::operator TimerData ()
{
TimerData c9x;
c9x.mode = TMRMODE_OFF;
// c9x.mode = TMRMODE_OFF;
c9x.val = val;
c9x.persistent = persistent;
c9x.dir = dir;
@@ -719,9 +711,9 @@ t_Open9xTimerData_v201::operator TimerData ()
t_Open9xTimerData_v202::operator TimerData ()
{
TimerData c9x;
/*
if (mode <= -22)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+22));
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+22));
else if (mode <= -1)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 5)
@@ -729,8 +721,8 @@ t_Open9xTimerData_v202::operator TimerData ()
else if (mode < 5+21)
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
else
c9x.mode = TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-5-21));
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
*/
c9x.val = val;
c9x.persistent = false;
c9x.dir = (val == 0);
@@ -993,8 +985,8 @@ t_Open9xModelData_v201::operator ModelData ()
c9x.customSw[i] = customSw[i];
for (int i=0; i<12; i++)
c9x.funcSw[i] = funcSw[i];
for (int i=0; i<O9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i];
// for (int i=0; i<O9X_NUM_CHNOUT; i++)
// c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR;
c9x.frsky = frsky;
@@ -1067,8 +1059,8 @@ t_Open9xModelData_v202::operator ModelData ()
c9x.customSw[i] = customSw[i];
for (int i=0; i<12; i++)
c9x.funcSw[i] = funcSw[i];
for (int i=0; i<O9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i];
// for (int i=0; i<O9X_NUM_CHNOUT; i++)
// c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR;
c9x.frsky = frsky;
c9x.moduleData[0].ppmFrameLength = ppmFrameLength;
@@ -221,30 +221,29 @@ PACK(typedef struct t_Open9xMixData_v211 {
t_Open9xMixData_v211() { memset(this, 0, sizeof(t_Open9xMixData_v211)); }
}) Open9xMixData_v211;
PACK(typedef struct t_Open9xCustomSwData_v208 { // Custom Switches data
PACK(typedef struct t_Open9xLogicalSwitchData_v208 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xCustomSwData_v208() { memset(this, 0, sizeof(t_Open9xCustomSwData_v208)); }
t_Open9xCustomSwData_v208(CustomSwData&);
}) Open9xCustomSwData_v208;
operator LogicalSwitchData();
t_Open9xLogicalSwitchData_v208() { memset(this, 0, sizeof(t_Open9xLogicalSwitchData_v208)); }
t_Open9xLogicalSwitchData_v208(LogicalSwitchData&);
}) Open9xLogicalSwitchData_v208;
PACK(typedef struct t_Open9xCustomSwData_v209 { // Custom Switches data
PACK(typedef struct t_Open9xLogicalSwitchData_v209 { // Custom Switches data
int8_t v1; //input
int8_t v2; //offset
uint8_t func;
operator CustomSwData();
t_Open9xCustomSwData_v209() { memset(this, 0, sizeof(t_Open9xCustomSwData_v209)); }
}) Open9xCustomSwData_v209;
operator LogicalSwitchData();
t_Open9xLogicalSwitchData_v209() { memset(this, 0, sizeof(t_Open9xLogicalSwitchData_v209)); }
}) Open9xLogicalSwitchData_v209;
PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data
int8_t swtch;
int8_t val;
operator SafetySwData();
t_Open9xSafetySwData() { memset(this, 0, sizeof(t_Open9xSafetySwData)); }
}) Open9xSafetySwData;
@@ -517,7 +516,7 @@ PACK(typedef struct t_Open9xModelData_v201 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xSafetySwData safetySw[O9X_NUM_CHNOUT];
Open9xFuncSwData_v201 funcSw[12];
Open9xSwashRingData_v208 swashR;
@@ -548,7 +547,7 @@ PACK(typedef struct t_Open9xModelData_v202 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xSafetySwData safetySw[O9X_NUM_CHNOUT];
Open9xFuncSwData_v201 funcSw[12];
Open9xSwashRingData_v208 swashR;
@@ -582,7 +581,7 @@ PACK(typedef struct t_Open9xModelData_v203 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@@ -615,7 +614,7 @@ PACK(typedef struct t_Open9xModelData_v204 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@@ -648,7 +647,7 @@ PACK(typedef struct t_Open9xModelData_v205 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@@ -683,7 +682,7 @@ PACK(typedef struct t_Open9xModelData_v208 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v208 customSw[O9X_NUM_CSW];
Open9xLogicalSwitchData_v208 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v208 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@@ -722,7 +721,7 @@ PACK(typedef struct t_Open9xModelData_v209 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves5[O9X_209_MAX_CURVE5][5];
int8_t curves9[O9X_209_MAX_CURVE9][9];
Open9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v203 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v209 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@@ -762,7 +761,7 @@ PACK(typedef struct t_Open9xModelData_v210 {
Open9xExpoData_v201 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS];
Open9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v209 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
@@ -800,7 +799,7 @@ PACK(typedef struct t_Open9xModelData_v211 {
Open9xExpoData_v211 expoData[O9X_MAX_EXPOS];
int8_t curves[O9X_MAX_CURVES];
int8_t points[O9X_NUM_POINTS];
Open9xCustomSwData_v209 customSw[O9X_NUM_CSW];
Open9xLogicalSwitchData_v209 customSw[O9X_NUM_CSW];
Open9xFuncSwData_v210 funcSw[O9X_NUM_FSW];
Open9xSwashRingData_v209 swashR;
Open9xPhaseData_v201 phaseData[O9X_MAX_PHASES];
File diff suppressed because it is too large Load Diff
@@ -64,6 +64,7 @@ class Open9xGeneralDataNew: public TransformedField {
StructField internalField;
GeneralSettings & generalData;
BoardEnum board;
unsigned int version;
int inputsCount;
unsigned int chkSum;
};
@@ -57,19 +57,19 @@ const char * Open9xInterface::getName()
{
switch (board) {
case BOARD_STOCK:
return "openTx for 9X board";
return "OpenTX for 9X board";
case BOARD_M128:
return "openTx for M128 / 9X board";
return "OpenTX for M128 / 9X board";
case BOARD_GRUVIN9X:
return "openTx for Gruvin9x board / 9X";
return "OpenTX for Gruvin9x board / 9X";
case BOARD_TARANIS:
return "openTx for FrSky Taranis";
return "OpenTX for FrSky Taranis";
case BOARD_TARANIS_REV4a:
return "openTx for FrSky Taranis Rev4a";
return "OpenTX for FrSky Taranis Rev4a";
case BOARD_SKY9X:
return "openTx for Sky9x board / 9X";
return "OpenTX for Sky9x board / 9X";
default:
return "openTx for an unknown board";
return "OpenTX for an unknown board";
}
}
@@ -526,7 +526,7 @@ int Open9xInterface::getCapability(const Capability capability)
return 24;
else
return 16;
case CustomSwitches:
case LogicalSwitches:
if (IS_ARM(board))
return 32;
else if (board==BOARD_GRUVIN9X||board==BOARD_M128)
@@ -535,10 +535,10 @@ int Open9xInterface::getCapability(const Capability capability)
return 12;
case CustomAndSwitches:
if (IS_ARM(board))
return getCapability(CustomSwitches);
return getCapability(LogicalSwitches);
else
return 15/*4bits*/-9/*sw positions*/;
case CustomSwitchesExt:
case LogicalSwitchesExt:
return (IS_ARM(board) ? true : false);
case RotaryEncoders:
if (board == BOARD_GRUVIN9X)
@@ -1014,7 +1014,7 @@ void RegisterOpen9xFirmwares()
Option extr_options[] = { { "frsky", QObject::tr("Support for frsky telemetry mod"), FRSKY_VARIANT }, { "jeti", QObject::tr("Support for jeti telemetry mod"), 0 }, { "ardupilot", QObject::tr("Support for receiving ardupilot data"), 0 }, { "nmea", QObject::tr("Support for receiving NMEA data"), 0 }, { "mavlink", QObject::tr("Support for MAVLINK devices"), MAVLINK_VARIANT }, { NULL } };
Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } };
/* 9x board */
open9x = new Open9xFirmware("opentx-9x", QObject::tr("openTx for 9X board"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false);
open9x = new Open9xFirmware("opentx-9x", QObject::tr("OpenTX for 9X board"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK), getrnurl(BOARD_STOCK), false);
open9x->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@@ -1051,7 +1051,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x);
/* 9x board with M128 chip */
open9x = new Open9xFirmware("opentx-9x128", QObject::tr("openTx for M128 / 9X board"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false);
open9x = new Open9xFirmware("opentx-9x128", QObject::tr("OpenTX for M128 / 9X board"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false);
open9x->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@@ -1083,7 +1083,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x);
/* 9XR board */
open9x = new Open9xFirmware("opentx-9xr", QObject::tr("openTx for 9XR"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK),getrnurl(BOARD_STOCK), false);
open9x = new Open9xFirmware("opentx-9xr", QObject::tr("OpenTX for 9XR"), new Open9xInterface(BOARD_STOCK), geturl(BOARD_STOCK), getstamp(BOARD_STOCK),getrnurl(BOARD_STOCK), false);
open9x->addOptions(extr_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@@ -1117,7 +1117,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x);
/* 9XR board with M128 chip */
open9x = new Open9xFirmware("opentx-9xr128", QObject::tr("openTx for 9XR with M128 chip"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false);
open9x = new Open9xFirmware("opentx-9xr128", QObject::tr("OpenTX for 9XR with M128 chip"), new Open9xInterface(BOARD_M128), geturl(BOARD_M128), getstamp(BOARD_M128),getrnurl(BOARD_M128), false);
open9x->addOptions(extr_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@@ -1147,7 +1147,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x);
/* Gruvin9x board */
open9x = new Open9xFirmware("opentx-gruvin9x", QObject::tr("openTx for Gruvin9x board / 9X"), new Open9xInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false);
open9x = new Open9xFirmware("opentx-gruvin9x", QObject::tr("OpenTX for Gruvin9x board / 9X"), new Open9xInterface(BOARD_GRUVIN9X), geturl(BOARD_GRUVIN9X), getstamp(BOARD_GRUVIN9X),getrnurl(BOARD_GRUVIN9X), false);
open9x->setVariantBase(FRSKY_VARIANT);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@@ -1177,7 +1177,7 @@ void RegisterOpen9xFirmwares()
#ifndef __APPLE__
/* SKY9X board */
open9x = new Open9xFirmware("opentx-sky9x", QObject::tr("openTx for Sky9x board / 9X"), new Open9xInterface(BOARD_SKY9X), geturl(BOARD_SKY9X), getstamp(BOARD_SKY9X),getrnurl(BOARD_SKY9X), true);
open9x = new Open9xFirmware("opentx-sky9x", QObject::tr("OpenTX for Sky9x board / 9X"), new Open9xInterface(BOARD_SKY9X), geturl(BOARD_SKY9X), getstamp(BOARD_SKY9X),getrnurl(BOARD_SKY9X), true);
open9x->setVariantBase(FRSKY_VARIANT);
open9x->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@@ -1202,7 +1202,7 @@ void RegisterOpen9xFirmwares()
#endif
/* Taranis board */
open9x = new Open9xFirmware("opentx-taranis", QObject::tr("openTx for FrSky Taranis"), new Open9xInterface(BOARD_TARANIS), geturl(BOARD_TARANIS), getstamp(BOARD_TARANIS),getrnurl(BOARD_TARANIS), true);
open9x = new Open9xFirmware("opentx-taranis", QObject::tr("OpenTX for FrSky Taranis"), new Open9xInterface(BOARD_TARANIS), geturl(BOARD_TARANIS), getstamp(BOARD_TARANIS),getrnurl(BOARD_TARANIS), true);
open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu"));
open9x->addOption("nogvars", QObject::tr("Disable Global variables"));
@@ -1214,7 +1214,7 @@ void RegisterOpen9xFirmwares()
QSettings settings;
int rev4a = settings.value("rev4asupport",0).toInt();
if (rev4a) {
open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("openTx for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true);
open9x = new Open9xFirmware("opentx-taranisrev4a", QObject::tr("OpenTX for FrSky Taranis Rev4a"), new Open9xInterface(BOARD_TARANIS_REV4a), geturl(BOARD_TARANIS_REV4a), getstamp(BOARD_TARANIS_REV4a),getrnurl(BOARD_TARANIS), true);
open9x->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu"));
open9x->addOption("nogvars", QObject::tr("Disable Global variables"));
+9 -21
View File
@@ -2,18 +2,6 @@
#include "helpers.h"
#include "th9xeeprom.h"
int8_t th9xFromSwitch(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;
}
}
RawSwitch th9xToSwitch(int8_t sw)
{
if (sw == 0)
@@ -181,22 +169,22 @@ t_Th9xMixData::operator MixData ()
return c9x;
}
t_Th9xCustomSwData::operator CustomSwData ()
t_Th9xLogicalSwitchData::operator LogicalSwitchData ()
{
CustomSwData c9x;
LogicalSwitchData c9x;
c9x.func = opCmp;
c9x.val1 = val1;
c9x.val2 = val2;
if ((c9x.func >= CS_FN_VPOS && c9x.func <= CS_FN_ANEG) || c9x.func >= CS_FN_EQUAL) {
if ((c9x.func >= LS_FN_VPOS && c9x.func <= LS_FN_ANEG) || c9x.func >= LS_FN_EQUAL) {
c9x.val1 = toSource(val1).toValue();
}
if (c9x.func >= CS_FN_EQUAL) {
if (c9x.func >= LS_FN_EQUAL) {
c9x.val2 = toSource(val2).toValue();
}
if (c9x.func >= CS_FN_AND && c9x.func <= CS_FN_XOR) {
if (c9x.func >= LS_FN_AND && c9x.func <= LS_FN_XOR) {
c9x.val1 = th9xToSwitch(val1).toValue();
c9x.val2 = th9xToSwitch(val2).toValue();
}
@@ -204,7 +192,7 @@ t_Th9xCustomSwData::operator CustomSwData ()
return c9x;
}
int8_t t_Th9xCustomSwData::fromSource(RawSource source)
int8_t t_Th9xLogicalSwitchData::fromSource(RawSource source)
{
int v1 = 0;
if (source.type == SOURCE_TYPE_STICK)
@@ -228,7 +216,7 @@ int8_t t_Th9xCustomSwData::fromSource(RawSource source)
return v1;
}
RawSource t_Th9xCustomSwData::toSource(int8_t value)
RawSource t_Th9xLogicalSwitchData::toSource(int8_t value)
{
if (value == 0) {
return RawSource(SOURCE_TYPE_NONE);
@@ -266,7 +254,7 @@ t_Th9xModelData::operator ModelData ()
ModelData c9x;
c9x.used = true;
getEEPROMString(c9x.name, name, sizeof(name));
switch(tmrMode) {
/*switch(tmrMode) {
case 1:
c9x.timers[0].mode = TMRMODE_ABS;
break;
@@ -279,7 +267,7 @@ t_Th9xModelData::operator ModelData ()
default:
c9x.timers[0].mode = TMRMODE_OFF;
break;
}
}*/
// c9x.timers[0].dir = tmrDir;
c9x.timers[0].val = tmrVal;
/*c9x.protocol = (Protocol)protocol;
+5 -5
View File
@@ -138,18 +138,18 @@ PACK(typedef struct t_Th9xMixData {
t_Th9xMixData();
}) Th9xMixData;
PACK(typedef struct t_Th9xCustomSwData {
PACK(typedef struct t_Th9xLogicalSwitchData {
uint8_t sw:3; // 0..7
uint8_t opCmp:2; // < & | ^
uint8_t opRes:3; // 0 => 1=> 0=> !=> & | ^
int8_t val1;
int8_t val2;
operator CustomSwData();
t_Th9xCustomSwData() { memset(this, 0, sizeof(t_Th9xCustomSwData)); }
operator LogicalSwitchData();
t_Th9xLogicalSwitchData() { memset(this, 0, sizeof(t_Th9xLogicalSwitchData)); }
int8_t fromSource(RawSource source);
RawSource toSource(int8_t value);
}) Th9xCustomSwData;
}) Th9xLogicalSwitchData;
PACK(typedef struct t_Th9xTrimData {
int8_t itrim:6; //trim index
@@ -173,7 +173,7 @@ PACK(typedef struct t_Th9xModelData {
int8_t curves3[TH9X_MAX_CURVES3][3]; // 9 new143
int8_t curves5[TH9X_MAX_CURVES5][5]; // 10
int8_t curves9[TH9X_MAX_CURVES9][9]; // 18
Th9xCustomSwData switchTab[TH9X_MAX_SWITCHES];//
Th9xLogicalSwitchData switchTab[TH9X_MAX_SWITCHES];//
Th9xTrimData trimData[NUM_STICKS]; // 3*4 -> 1*4
operator ModelData();
t_Th9xModelData();
@@ -157,7 +157,7 @@ int Th9xInterface::getCapability(const Capability capability)
return 9;
case CustomFunctions:
return 0;
case CustomSwitches:
case LogicalSwitches:
return TH9X_MAX_SWITCHES;
case Outputs:
return 8;
+281 -263
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>620</width>
<height>663</height>
<height>658</height>
</rect>
</property>
<property name="sizePolicy">
@@ -32,26 +32,10 @@
<property name="margin">
<number>6</number>
</property>
<item row="24" column="4">
<widget class="QSpinBox" name="ProfSlot_SB">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
</widget>
</item>
<item row="21" column="2" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="21" column="5">
<widget class="QPushButton" name="voice_dnld">
<property name="text">
<string>Download Voice</string>
</property>
</widget>
</item>
@@ -62,17 +46,7 @@
</property>
</widget>
</item>
<item row="24" column="2" colspan="2">
<widget class="QLineEdit" name="ProfName_LE"/>
</item>
<item row="22" column="5">
<widget class="QPushButton" name="voice_dnld">
<property name="text">
<string>Download Voice</string>
</property>
</widget>
</item>
<item row="11" column="2">
<item row="10" column="2">
<widget class="QCheckBox" name="optionCheckBox_9">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -85,7 +59,7 @@
</property>
</widget>
</item>
<item row="11" column="3">
<item row="10" column="3">
<widget class="QCheckBox" name="optionCheckBox_10">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -98,14 +72,14 @@
</property>
</widget>
</item>
<item row="19" column="5">
<item row="18" column="5">
<widget class="QPushButton" name="fw_dnld">
<property name="text">
<string>Download FW</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Options</string>
@@ -119,7 +93,7 @@
</property>
</widget>
</item>
<item row="13" column="4">
<item row="12" column="4">
<widget class="QCheckBox" name="optionCheckBox_19">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -132,7 +106,7 @@
</property>
</widget>
</item>
<item row="10" column="5">
<item row="9" column="5">
<widget class="QCheckBox" name="optionCheckBox_8">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -145,21 +119,8 @@
</property>
</widget>
</item>
<item row="10" column="4">
<widget class="QCheckBox" name="optionCheckBox_7">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="12" column="4">
<widget class="QCheckBox" name="optionCheckBox_15">
<item row="14" column="2">
<widget class="QCheckBox" name="optionCheckBox_25">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -172,6 +133,32 @@
</widget>
</item>
<item row="9" column="4">
<widget class="QCheckBox" name="optionCheckBox_7">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="11" column="4">
<widget class="QCheckBox" name="optionCheckBox_15">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="8" column="4">
<widget class="QCheckBox" name="optionCheckBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -184,26 +171,75 @@
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="sdPathLabel">
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="CPU_ID_LABEL">
<property name="text">
<string>Processor ID</string>
</property>
</widget>
</item>
<item row="17" column="4">
<widget class="QCheckBox" name="optionCheckBox_39">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SD Structure path</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="CPU_ID_LABEL">
<item row="4" column="2" colspan="4">
<widget class="QLabel" name="FwInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Processor ID</string>
<string>FwInfo</string>
</property>
</widget>
</item>
<item row="17" column="5">
<widget class="QCheckBox" name="optionCheckBox_40">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="11" column="3">
<widget class="QCheckBox" name="optionCheckBox_14">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="11" column="5">
<widget class="QCheckBox" name="optionCheckBox_16">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
@@ -246,7 +282,7 @@
</property>
</widget>
</item>
<item row="9" column="2">
<item row="8" column="2">
<widget class="QCheckBox" name="optionCheckBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -259,7 +295,7 @@
</property>
</widget>
</item>
<item row="18" column="2">
<item row="17" column="2">
<widget class="QCheckBox" name="optionCheckBox_37">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -326,7 +362,7 @@ Mode 4:
</item>
</widget>
</item>
<item row="16" column="2">
<item row="15" column="2">
<widget class="QCheckBox" name="optionCheckBox_29">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -339,7 +375,7 @@ Mode 4:
</property>
</widget>
</item>
<item row="9" column="3">
<item row="8" column="3">
<widget class="QCheckBox" name="optionCheckBox_1">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -352,6 +388,19 @@ Mode 4:
</property>
</widget>
</item>
<item row="10" column="5">
<widget class="QCheckBox" name="optionCheckBox_12">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QComboBox" name="langCombo">
<property name="sizePolicy">
@@ -368,6 +417,9 @@ Mode 4:
</property>
</widget>
</item>
<item row="3" column="2" colspan="3">
<widget class="QComboBox" name="downloadVerCB"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
@@ -376,6 +428,13 @@ Mode 4:
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Firmware Type</string>
</property>
@@ -384,6 +443,9 @@ Mode 4:
</property>
</widget>
</item>
<item row="5" column="2" colspan="3">
<widget class="QLineEdit" name="CPU_ID_LE"/>
</item>
<item row="33" column="2" colspan="2">
<widget class="QComboBox" name="channelorderCB">
<property name="sizePolicy">
@@ -534,10 +596,7 @@ This is used by the templated to determine which channel goes to what number out
</item>
</widget>
</item>
<item row="3" column="2" colspan="3">
<widget class="QComboBox" name="downloadVerCB"/>
</item>
<item row="9" column="5">
<item row="8" column="5">
<widget class="QCheckBox" name="optionCheckBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -550,7 +609,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="15" column="5">
<item row="14" column="5">
<widget class="QCheckBox" name="optionCheckBox_28">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -563,10 +622,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="5" column="2" colspan="3">
<widget class="QLineEdit" name="CPU_ID_LE"/>
</item>
<item row="19" column="3">
<item row="18" column="3">
<widget class="QCheckBox" name="optionCheckBox_42">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -579,7 +635,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="10" column="2">
<item row="9" column="2">
<widget class="QCheckBox" name="optionCheckBox_5">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -592,20 +648,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="12" column="3">
<widget class="QCheckBox" name="optionCheckBox_14">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="16" column="5">
<item row="15" column="5">
<widget class="QCheckBox" name="optionCheckBox_32">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -618,20 +661,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="12" column="5">
<widget class="QCheckBox" name="optionCheckBox_16">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="13" column="2">
<item row="12" column="2">
<widget class="QCheckBox" name="optionCheckBox_17">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -644,7 +674,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="17" column="4">
<item row="16" column="4">
<widget class="QCheckBox" name="optionCheckBox_35">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -657,7 +687,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="17" column="5">
<item row="16" column="5">
<widget class="QCheckBox" name="optionCheckBox_36">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -670,7 +700,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="12" column="2">
<item row="11" column="2">
<widget class="QCheckBox" name="optionCheckBox_13">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -683,7 +713,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="15" column="3">
<item row="14" column="3">
<widget class="QCheckBox" name="optionCheckBox_26">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -696,7 +726,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="19" column="2">
<item row="18" column="2">
<widget class="QCheckBox" name="optionCheckBox_41">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -709,17 +739,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="6" column="2" colspan="3">
<widget class="QLineEdit" name="sdPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="13" column="3">
<item row="12" column="3">
<widget class="QCheckBox" name="optionCheckBox_18">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -732,7 +752,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="11" column="4">
<item row="10" column="4">
<widget class="QCheckBox" name="optionCheckBox_11">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -745,7 +765,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="14" column="2">
<item row="13" column="2">
<widget class="QCheckBox" name="optionCheckBox_21">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -758,10 +778,10 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="13" column="5">
<item row="12" column="5">
<widget class="QCheckBox" name="optionCheckBox_20">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -771,7 +791,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="17" column="2">
<item row="16" column="2">
<widget class="QCheckBox" name="optionCheckBox_33">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -784,7 +804,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="14" column="5">
<item row="13" column="5">
<widget class="QCheckBox" name="optionCheckBox_24">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -797,7 +817,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="14" column="4">
<item row="13" column="4">
<widget class="QCheckBox" name="optionCheckBox_23">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -810,7 +830,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="14" column="3">
<item row="13" column="3">
<widget class="QCheckBox" name="optionCheckBox_22">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -823,7 +843,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="10" column="3">
<item row="9" column="3">
<widget class="QCheckBox" name="optionCheckBox_6">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -836,7 +856,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="18" column="3">
<item row="17" column="3">
<widget class="QCheckBox" name="optionCheckBox_38">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -849,7 +869,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="17" column="3">
<item row="16" column="3">
<widget class="QCheckBox" name="optionCheckBox_34">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -862,7 +882,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="16" column="4">
<item row="15" column="4">
<widget class="QCheckBox" name="optionCheckBox_31">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -875,7 +895,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="16" column="3">
<item row="15" column="3">
<widget class="QCheckBox" name="optionCheckBox_30">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -888,33 +908,7 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="11" column="5">
<widget class="QCheckBox" name="optionCheckBox_12">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="15" column="2">
<widget class="QCheckBox" name="optionCheckBox_25">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="15" column="4">
<item row="14" column="4">
<widget class="QCheckBox" name="optionCheckBox_27">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
@@ -927,13 +921,6 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="6" column="5">
<widget class="QPushButton" name="sdPathButton">
<property name="text">
<string>Open Folder</string>
</property>
</widget>
</item>
<item row="34" column="2" colspan="3">
<widget class="QCheckBox" name="renameFirmware">
<property name="text">
@@ -941,20 +928,6 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="8" column="2" colspan="4">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="45" column="2" colspan="4">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="46" column="5">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
@@ -965,65 +938,6 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="23" column="2" colspan="4">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="18" column="4">
<widget class="QCheckBox" name="optionCheckBox_39">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="4">
<widget class="QLabel" name="FwInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>FwInfo</string>
</property>
</widget>
</item>
<item row="18" column="5">
<widget class="QCheckBox" name="optionCheckBox_40">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="3" column="5">
<widget class="QPushButton" name="checkFWUpdates">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Check for updates</string>
</property>
</widget>
</item>
<item row="42" column="4">
<widget class="QPushButton" name="export_PB">
<property name="text">
@@ -1038,8 +952,15 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="24" column="0">
<item row="23" column="0">
<widget class="QLabel" name="label_16">
<property name="font">
<font>
<family>Sans Serif</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Profile</string>
</property>
@@ -1048,7 +969,30 @@ This is used by the templated to determine which channel goes to what number out
</property>
</widget>
</item>
<item row="22" column="2">
<item row="3" column="5">
<widget class="QPushButton" name="checkFWUpdates">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Check for updates</string>
</property>
</widget>
</item>
<item row="25" column="2" colspan="3">
<widget class="QLineEdit" name="SplashFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="21" column="2">
<widget class="QComboBox" name="voiceCombo">
<property name="maximumSize">
<size>
@@ -1062,8 +1006,22 @@ May be different from firmware language</string>
</property>
</widget>
</item>
<item row="22" column="0">
<item row="25" column="5">
<widget class="QPushButton" name="SplashSelect">
<property name="text">
<string>Open Image</string>
</property>
</widget>
</item>
<item row="21" column="0">
<widget class="QLabel" name="voiceLabel">
<property name="font">
<font>
<family>Sans Serif</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Voice Language</string>
</property>
@@ -1078,24 +1036,7 @@ May be different from firmware language</string>
</sizepolicy>
</property>
<property name="text">
<string>Profile Splash Screen</string>
</property>
</widget>
</item>
<item row="25" column="2" colspan="3">
<widget class="QLineEdit" name="SplashFileName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="25" column="5">
<widget class="QPushButton" name="SplashSelect">
<property name="text">
<string>Open Image</string>
<string>Splash Screen</string>
</property>
</widget>
</item>
@@ -1106,14 +1047,91 @@ May be different from firmware language</string>
</property>
</widget>
</item>
<item row="23" column="3" colspan="2">
<widget class="QLineEdit" name="ProfName_LE"/>
</item>
<item row="23" column="2">
<widget class="QSpinBox" name="ProfSlot_SB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10</number>
</property>
</widget>
</item>
<item row="22" column="0" colspan="6">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="20" column="0" colspan="6">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="45" column="0" colspan="6">
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="24" column="5">
<widget class="QPushButton" name="sdPathButton">
<property name="text">
<string>Open Folder</string>
</property>
</widget>
</item>
<item row="24" column="2" colspan="3">
<widget class="QLineEdit" name="sdPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="24" column="0">
<widget class="QLabel" name="sdPathLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>SD Structure path</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>downloadVerCB</tabstop>
<tabstop>CPU_ID_LE</tabstop>
<tabstop>sdPath</tabstop>
<tabstop>sdPathButton</tabstop>
<tabstop>langCombo</tabstop>
<tabstop>optionCheckBox_2</tabstop>
<tabstop>optionCheckBox_1</tabstop>
+117 -597
View File
@@ -117,165 +117,6 @@ void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last=fal
b->setMaxVisibleItems(10);
}
QString getRepeatString(unsigned int val)
{
if (val==0) {
return QObject::tr("No repeat");
} else {
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10;
return QObject::tr("%1 sec").arg(step*val);
}
}
QString getFuncName(unsigned int val)
{
if (val < NUM_SAFETY_CHNOUT) {
return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, val).toString());
}
else if (val == FuncTrainer)
return QObject::tr("Trainer");
else if (val == FuncTrainerRUD)
return QObject::tr("Trainer RUD");
else if (val == FuncTrainerELE)
return QObject::tr("Trainer ELE");
else if (val == FuncTrainerTHR)
return QObject::tr("Trainer THR");
else if (val == FuncTrainerAIL)
return QObject::tr("Trainer AIL");
else if (val == FuncInstantTrim)
return QObject::tr("Instant Trim");
else if (val == FuncPlaySound)
return QObject::tr("Play Sound");
else if (val == FuncPlayHaptic)
return QObject::tr("Play Haptic");
else if (val == FuncReset)
return QObject::tr("Reset");
else if (val == FuncVario)
return QObject::tr("Vario");
else if (val == FuncPlayPrompt)
return QObject::tr("Play Track");
else if (val == FuncPlayBoth)
return QObject::tr("Play Both");
else if (val == FuncPlayValue)
return QObject::tr("Play Value");
else if (val == FuncLogs)
return QObject::tr("Start Logs");
else if (val == FuncVolume)
return QObject::tr("Volume");
else if (val == FuncBacklight)
return QObject::tr("Backlight");
else if (val == FuncBackgroundMusic)
return QObject::tr("Background Music");
else if (val == FuncBackgroundMusicPause)
return QObject::tr("Background Music Pause");
else if (val >= FuncAdjustGV1 && val <= FuncAdjustGVLast)
return QObject::tr("Adjust GV%1").arg(val-FuncAdjustGV1+1);
else {
return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is)
}
}
// TODO should be a toString() method in CustoSwData ...
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model)
{
QString result = "";
if (!customSw->func)
return result;
if (customSw->andsw!=0) {
result +="( ";
}
switch (getCSFunctionFamily(customSw->func)) {
case CS_FAMILY_TIMERS:
result = QString("TIM(%1 , %2)").arg(ValToTim(customSw->val1)).arg(ValToTim(customSw->val2));
break;
case CS_FAMILY_VOFS: {
RawSource source = RawSource(customSw->val1, &model);
RawSourceRange range = source.getRange();
if (customSw->val1)
result += source.toString();
else
result += "0";
result.remove(" ");
if (customSw->func == CS_FN_APOS || customSw->func == CS_FN_ANEG)
result = "|" + result + "|";
else if (customSw->func == CS_FN_DAPOS)
result = "|d(" + result + ")|";
else if (customSw->func == CS_FN_DPOS) result = "d(" + result + ")";
if (customSw->func == CS_FN_APOS || customSw->func == CS_FN_VPOS || customSw->func == CS_FN_DAPOS || customSw->func == CS_FN_DPOS)
result += " &gt; ";
else if (customSw->func == CS_FN_ANEG || customSw->func == CS_FN_VNEG)
result += " &lt; ";
result += QString::number(range.step * (customSw->val2 /*TODO+ source.getRawOffset(model)*/) + range.offset);
break;
}
case CS_FAMILY_VBOOL:
result = RawSwitch(customSw->val1).toString();
switch (customSw->func) {
case CS_FN_AND:
result += " AND ";
break;
case CS_FN_OR:
result += " OR ";
break;
case CS_FN_XOR:
result += " XOR ";
break;
default:
break;
}
result += RawSwitch(customSw->val2).toString();
break;
case CS_FAMILY_VCOMP:
if (customSw->val1)
result += RawSource(customSw->val1).toString();
else
result += "0";
switch (customSw->func) {
case CS_FN_EQUAL:
result += " = ";
break;
case CS_FN_NEQUAL:
result += " != ";
break;
case CS_FN_GREATER:
result += " &gt; ";
break;
case CS_FN_LESS:
result += " &lt; ";
break;
case CS_FN_EGREATER:
result += " &gt;= ";
break;
case CS_FN_ELESS:
result += " &lt;= ";
break;
default:
break;
}
if (customSw->val2)
result += RawSource(customSw->val2).toString();
else
result += "0";
break;
}
if (customSw->andsw!=0) {
result +=" ) AND ";
result += RawSwitch(customSw->andsw).toString();
}
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
if (customSw->delay)
result += QObject::tr(" Delay %1 sec").arg(customSw->delay/2.0);
if (customSw->duration)
result += QObject::tr(" Duration %1 sec").arg(customSw->duration/2.0);
}
return result;
}
QString getProtocolStr(const int proto)
{
static const char *strings[] = { "OFF",
@@ -290,186 +131,6 @@ QString getProtocolStr(const int proto)
return CHECK_IN_ARRAY(strings, proto);
}
void populateFuncCB(QComboBox *b, unsigned int value)
{
b->clear();
for (unsigned int i = 0; i < FuncCount; i++) {
b->addItem(getFuncName(i));
if (!GetEepromInterface()->getCapability(HasVolume)) {
if (i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
if ((i==FuncPlayHaptic) && !GetEepromInterface()->getCapability(Haptic)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncPlayBoth) && !GetEepromInterface()->getCapability(HasBeeper)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncLogs) && !GetEepromInterface()->getCapability(HasSDLogs)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
b->setCurrentIndex(value);
b->setMaxVisibleItems(10);
}
QString FuncParam(uint function, int value, QString paramT,unsigned int adjustmode)
{
QStringList qs;
if (function <= FuncInstantTrim) {
return QString("%1").arg(value);
}
else if (function==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
if (value>=0 && value<(int)qs.count())
return qs.at(value);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (function==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
if (value>=0 && value<(int)qs.count())
return qs.at(value);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (function==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
if (value>=0 && value<(int)qs.count())
return qs.at(value);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if ((function==FuncVolume)|| (function==FuncPlayValue)) {
RawSource item(value);
return item.toString();
}
else if ((function==FuncPlayPrompt) || (function==FuncPlayBoth)) {
if ( GetEepromInterface()->getCapability(VoicesAsNumbers)) {
return QString("%1").arg(value);
} else {
return paramT;
}
} else if ((function>FuncBackgroundMusicPause) && (function<FuncCount)) {
switch (adjustmode) {
case 0:
return QObject::tr("Value ")+QString("%1").arg(value);
break;
case 1:
return RawSource(value).toString();
break;
case 2:
return RawSource(value).toString();
break;
case 3:
if (value==0) {
return QObject::tr("Decr:")+QString(" -1");
} else {
return QObject::tr("Incr:")+QString(" +1");
}
break;
default:
return "";
}
}
return "";
}
void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList)
{
b->clear();
b->addItem("----");
QString currentvalue(value);
foreach ( QString entry, paramsList ) {
b->addItem(entry);
if (entry==currentvalue) {
b->setCurrentIndex(b->count()-1);
}
}
}
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
{
QStringList qs;
b->clear();
if (function==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
int reCount = GetEepromInterface()->getCapability(RotaryEncoders);
if (reCount == 1) {
qs.append( QObject::tr("Rotary Encoder"));
}
else if (reCount == 2) {
qs.append( QObject::tr("REa"));
qs.append( QObject::tr("REb"));
}
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncVolume) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS);
}
else if (function==FuncPlayValue) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
}
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
switch (adjustmode) {
case 1:
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
break;
case 2:
populateSourceCB(b, RawSource(value), model, POPULATE_GVARS);
break;
case 3:
b->clear();
b->addItem("-1", 0);
b->addItem("+1", 1);
b->setCurrentIndex(value);
break;
}
}
else {
b->hide();
}
}
void populateGVmodeCB(QComboBox *b, unsigned int value)
{
b->clear();
b->addItem(QObject::tr("Value"));
b->addItem(QObject::tr("Source"));
b->addItem(QObject::tr("GVAR"));
b->addItem(QObject::tr("Increment"));
b->setCurrentIndex(value);
}
void populatePhasesCB(QComboBox *b, int value)
{
for (int i=-GetEepromInterface()->getCapability(FlightPhases); i<=GetEepromInterface()->getCapability(FlightPhases); i++) {
@@ -694,88 +355,6 @@ void populateGvarUseCB(QComboBox *b, unsigned int phase)
}
}
void populateTimerSwitchCB(QComboBox *b, int value)
{
b->clear();
uint8_t count=0;
for (int i=-128; i<128; i++) {
QString timerMode = getTimerMode(i);
if (!timerMode.isEmpty()) {
b->addItem(getTimerMode(i), i);
if (i==value)
b->setCurrentIndex(b->count()-1);
count++;
}
}
b->setMaxVisibleItems(10);
}
QString getTimerMode(int tm) {
QString stt = "OFFABSTHsTH%THt";
QString s;
if (tm >= 0 && tm <= TMRMODE_THt) {
return stt.mid(abs(tm)*3, 3);
}
int tma = abs(tm);
if (tma >= TMRMODE_FIRST_SWITCH && tma < TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions)) {
s = RawSwitch(SWITCH_TYPE_SWITCH, tma - TMRMODE_FIRST_SWITCH + 1).toString();
if (tm < 0) s.prepend("!");
return s;
}
if (tma >= TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) && tma < TMRMODE_FIRST_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) + GetEepromInterface()->getCapability(CustomSwitches)) {
s = RawSwitch(SWITCH_TYPE_VIRTUAL, tma - TMRMODE_FIRST_SWITCH - GetEepromInterface()->getCapability(SwitchesPositions) + 1).toString();
if (tm < 0) s.prepend("!");
return s;
}
if (tma >= TMRMODE_FIRST_MOMENT_SWITCH && tma < TMRMODE_FIRST_MOMENT_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions)) {
s = RawSwitch(SWITCH_TYPE_SWITCH, tma - TMRMODE_FIRST_MOMENT_SWITCH + 1).toString()+"t";
if (tm < 0) s.prepend("!");
return s;
}
if (tma >= TMRMODE_FIRST_MOMENT_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) && tma < TMRMODE_FIRST_MOMENT_SWITCH + GetEepromInterface()->getCapability(SwitchesPositions) + GetEepromInterface()->getCapability(CustomSwitches)) {
s = RawSwitch(SWITCH_TYPE_VIRTUAL, tma - TMRMODE_FIRST_MOMENT_SWITCH - GetEepromInterface()->getCapability(SwitchesPositions) + 1).toString()+"t";
if (tm < 0) s.prepend("!");
return s;
}
if (tma >=TMRMODE_FIRST_CHPERC && tma <TMRMODE_FIRST_CHPERC+16) {
s = QString("CH%1%").arg(tma-TMRMODE_FIRST_CHPERC+1);
return s;
}
return "";
}
QString getTimerModeB(int tm) {
QString stt = "---THRRUDELEIDOID1ID2AILGEATRN";
QString s;
int tma = abs(tm);
if (tma>33) {
tma-=32;
}
if (tma < 10) {
s=stt.mid(abs(tma)*3, 3);
} else if (tma <19) {
s=QString("SW%1").arg(tma-9);
} else {
s=QString("SW")+QChar('A'+tma-19);
}
if (tm<0) {
s.prepend("!");
} else if (tm>33) {
s.append("m");
}
return s;
}
void populateBacklightCB(QComboBox *b, const uint8_t value)
{
QString strings[] = { QObject::tr("OFF"), QObject::tr("Keys"), QObject::tr("Sticks"), QObject::tr("Keys + Sticks"), QObject::tr("ON"), NULL };
@@ -788,119 +367,117 @@ void populateBacklightCB(QComboBox *b, const uint8_t value)
}
}
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr, UseContext context)
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value)
{
if (IS_ARM(GetEepromInterface()->getBoard())) {
populateSwitchCB(b, value);
}
else {
RawSwitch item;
b->clear();
item = RawSwitch(SWITCH_TYPE_NONE);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=6; i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
}
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr)
{
RawSwitch item;
b->clear();
if (attr & POPULATE_AND_SWITCHES) {
if (GetEepromInterface()->getCapability(HasNegAndSwitches)) {
for (int i=-GetEepromInterface()->getCapability(CustomAndSwitches); i<=-1; i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<=-1; i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
}
item = RawSwitch(SWITCH_TYPE_NONE);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
for (int i=1; i<=GetEepromInterface()->getCapability(CustomAndSwitches); i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
return;
}
#if 0
// TODO check ... I removed negative toggle switches in the FW, no?
if (attr & POPULATE_MSWITCHES) {
if (attr & POPULATE_ONOFF) {
item = RawSwitch(SWITCH_TYPE_ONM, 1);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
#endif
if (attr & POPULATE_ONOFF) {
item = RawSwitch(SWITCH_TYPE_OFF);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) {
for (int i=-GetEepromInterface()->getCapability(LogicalSwitches); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(RotaryEncoders); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-8; i<0; i++) {
item = RawSwitch(SWITCH_TYPE_TRIM, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (attr & POPULATE_TIMER_MODES) {
for (int i=0; i<5; i++) {
item = RawSwitch(SWITCH_TYPE_TIMER_MODE, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
item = RawSwitch(SWITCH_TYPE_NONE);
if (GetEepromInterface()->isAvailable(item, context)) {
else {
item = RawSwitch(SWITCH_TYPE_NONE);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
for (int i=1; i<=GetEepromInterface()->getCapability(CustomSwitches); i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
for (int i=0; i<GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(MultiposPots) * GetEepromInterface()->getCapability(MultiposPotsPositions); i++) {
item = RawSwitch(SWITCH_TYPE_MULTIPOS_POT, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=8; i++) {
item = RawSwitch(SWITCH_TYPE_TRIM, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(RotaryEncoders); i++) {
item = RawSwitch(SWITCH_TYPE_ROTARY_ENCODER, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(LogicalSwitches); i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (attr & POPULATE_ONOFF) {
@@ -909,52 +486,6 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (attr & POPULATE_MSWITCHES) {
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_MOMENT_SWITCH, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
for (int i=1; i<=GetEepromInterface()->getCapability(CustomSwitches); i++) {
item = RawSwitch(SWITCH_TYPE_MOMENT_VIRTUAL, i);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
if (attr & POPULATE_MSWITCHES) {
if (attr & POPULATE_ONOFF) {
item = RawSwitch(SWITCH_TYPE_ONM);
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
if (IS_ARM(GetEepromInterface()->getBoard())) {
item = RawSwitch(SWITCH_TYPE_TRN,0);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
item = RawSwitch(SWITCH_TYPE_TRN,1);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
if (GetEepromInterface()->getBoard()==BOARD_SKY9X) {
item = RawSwitch(SWITCH_TYPE_REA,0);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
item = RawSwitch(SWITCH_TYPE_REA,1);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1);
}
}
}
b->setMaxVisibleItems(10);
}
@@ -1051,7 +582,7 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
if (item == source) b->setCurrentIndex(b->count()-1);
}
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
item = RawSource(SOURCE_TYPE_CUSTOM_SWITCH, i);
b->addItem(item.toString(), item.toValue());
if (item == source) b->setCurrentIndex(b->count()-1);
@@ -1104,35 +635,6 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
b->setMaxVisibleItems(10);
}
#define CSWITCH_STR "---- a~x a>x a<x |a|>x |a|<x AND OR XOR a=b a!=b a>b a<b a>=b a<=b d>=x |d|>=xTIM "
#define CSW_NUM_FUNC 18 // TODO enum
#define CSW_LEN_FUNC 6
int csw_values[]={
CS_FN_OFF,
CS_FN_VEQUAL, // added at the end to avoid everything renumbered
CS_FN_VPOS,
CS_FN_VNEG,
CS_FN_APOS,
CS_FN_ANEG,
CS_FN_AND,
CS_FN_OR,
CS_FN_XOR,
CS_FN_EQUAL,
CS_FN_NEQUAL,
CS_FN_GREATER,
CS_FN_LESS,
CS_FN_EGREATER,
CS_FN_ELESS,
CS_FN_DPOS,
CS_FN_DAPOS,
CS_FN_TIM
};
QString getCSWFunc(int val)
{
return QString(CSWITCH_STR).mid(val*CSW_LEN_FUNC, CSW_LEN_FUNC);
}
float ValToTim(int value)
{
return ((value < -109 ? 129+value : (value < 7 ? (113+value)*5 : (53+value)*10))/10.0);
@@ -1153,14 +655,39 @@ int TimToVal(float value)
void populateCSWCB(QComboBox *b, int value)
{
int order[] = {
LS_FN_OFF,
LS_FN_VEQUAL, // added at the end to avoid everything renumbered
LS_FN_VPOS,
LS_FN_VNEG,
// LS_FN_RANGE,
LS_FN_APOS,
LS_FN_ANEG,
LS_FN_AND,
LS_FN_OR,
LS_FN_XOR,
LS_FN_STAY,
LS_FN_EQUAL,
LS_FN_NEQUAL,
LS_FN_GREATER,
LS_FN_LESS,
LS_FN_EGREATER,
LS_FN_ELESS,
LS_FN_DPOS,
LS_FN_DAPOS,
LS_FN_TIMER,
LS_FN_STICKY
};
b->clear();
for (int i = 0; i < CSW_NUM_FUNC; i++) {
b->addItem(getCSWFunc(i),csw_values[i]);
if (i>GetEepromInterface()->getCapability(CSFunc)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
}
if (value == csw_values[i]) {
for (int i=0; i<LS_FN_MAX; i++) {
int func = order[i];
b->addItem(LogicalSwitchData(func).funcToString(), func);
// if (i>GetEepromInterface()->getCapability(CSFunc)) {
// QModelIndex index = b->model()->index(i, 0);
// QVariant v(0);
// }
if (value == func) {
b->setCurrentIndex(b->count()-1);
}
}
@@ -1328,7 +855,7 @@ QString getTrimInc(ModelData * g_model)
QString getTimerStr(TimerData & timer)
{
QString str = ", " + (timer.dir ? QObject::tr("Count Up") : QObject::tr("Count Down"));
return QObject::tr("%1:%2, ").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0')) + getTimerMode(timer.mode) + str;
return QObject::tr("%1:%2, ").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0')) + timer.mode.toString() + str;
}
QString getProtocol(ModelData * g_model)
@@ -1369,13 +896,6 @@ QString getPhasesStr(unsigned int phases, ModelData & model)
}
}
float c9xexpou(float point, float coeff)
{
float x=point*1024.0/100.0;
float k=coeff*256.0/100.0;
return ((k*x*x*x/(1024*1024) + x*(256-k) + 128) / 256)/1024.0*100;
}
QString getCenterBeep(ModelData * g_model)
{
//RETA123
+5 -17
View File
@@ -4,7 +4,7 @@
#include <QtGui>
#include "eeprominterface.h"
#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(CustomSwitches)-1)
#define TMR_NUM_OPTION (TMR_VAROFS+2*9+2*GetEepromInterface()->getCapability(LogicalSwitches)-1)
//convert from mode 1 to mode generalSettings.stickMode
//NOTICE! => 1..4 -> 1..4
@@ -82,19 +82,13 @@ class CurveGroup : public QObject {
};
#define POPULATE_ONOFF 0x01
#define POPULATE_MSWITCHES 0x02
#define POPULATE_AND_SWITCHES 0x04
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext);
void populateFuncCB(QComboBox *b, unsigned int value);
void populateGVmodeCB(QComboBox *b, unsigned int value);
QString FuncParam(uint function, int value, QString paramT="",unsigned int adjustmode=0);
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamArmTCB(QComboBox *b, ModelData * g_model, char * value, QStringList & paramsList);
#define POPULATE_TIMER_MODES 0x02
void populateAndSwitchCB(QComboBox *b, const RawSwitch & value);
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0);
void populatePhasesCB(QComboBox *b, int value);
void populateGvarUseCB(QComboBox *b, unsigned int phase);
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
void populateTimerSwitchCB(QComboBox *b, int value);
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model);
QString getProtocolStr(const int proto);
QString getPhasesStr(unsigned int phases, ModelData & model);
@@ -113,13 +107,8 @@ QString getPhasesStr(unsigned int phases, ModelData & model);
void populateGVCB(QComboBox *b, int value);
void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags);
void populateCSWCB(QComboBox *b, int value);
QString getTimerMode(int tm);
QString getTimerModeB(int tm);
QString getPhaseName(int val, char * phasename=NULL);
QString getInputStr(ModelData & model, int index);
QString getCSWFunc(int val);
QString getFuncName(unsigned int val);
QString getRepeatString(unsigned int val);
QString getSignedStr(int value);
QString getGVarString(int16_t val, bool sign=false);
QString image2qstring(QImage image);
@@ -139,7 +128,6 @@ QString getFrSkyProtocol(int protocol);
QString getFrSkyMeasure(int units);
QString getFrSkySrc(int index);
float c9xexpou(float point, float coeff);
float ValToTim(int value);
int TimToVal(float value);
+7
View File
@@ -495,6 +495,13 @@ void ModelEdit::on_ca_ctype_CB_currentIndexChanged()
}
}
float c9xexpou(float point, float coeff)
{
float x=point*1024.0/100.0;
float k=coeff*256.0/100.0;
return ((k*x*x*x/(1024*1024) + x*(256-k) + 128) / 256)/1024.0*100;
}
void ModelEdit::on_ca_apply_PB_clicked()
{
int index=ui->ca_ctype_CB->currentIndex();
+163 -17
View File
@@ -36,6 +36,16 @@ void RepeatComboBox::onIndexChanged(int index)
emit modified();
}
void RepeatComboBox::update()
{
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 1 : 10;
int value = repeatParam/step;
if (step == 1) {
value++;
}
setCurrentIndex(value);
}
CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings):
ModelPanel(parent, model),
generalSettings(generalSettings),
@@ -52,7 +62,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
lock = true;
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
QStringList paramarmList;
if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) {
for (int i=0; i<num_fsw; i++) {
if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) {
@@ -90,12 +99,21 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
for (int i=0; i<num_fsw; i++) {
AssignFunc func = model.funcSw[i].func;
// The label
QLabel * label = new QLabel(this);
label->setContextMenuPolicy(Qt::CustomContextMenu);
label->setMouseTracking(true);
label->setProperty("index", i);
label->setText(tr("CF%1").arg(i+1));
gridLayout->addWidget(label, i+1, 0);
connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(fsw_customContextMenuRequested(QPoint)));
// The switch
fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setProperty("index", i);
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_ONOFF);
// The function
fswtchFunc[i] = new QComboBox(this);
@@ -135,7 +153,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
fswtchParamArmT[i] = new QComboBox(this);
fswtchParamArmT[i]->setProperty("index", i);
populateFuncParamArmTCB(fswtchParamArmT[i],&model, model.funcSw[i].paramarm, paramarmList);
populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
fswtchParamArmT[i]->setEditable(true);
paramLayout->addWidget(fswtchParamArmT[i]);
@@ -286,7 +304,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
int index = fswtchFunc[i]->currentIndex();
if (index>=FuncSafetyCh1 && index<=FuncSafetyCh16) {
if (index>=FuncSafetyCh1 && index<=FuncSafetyCh32) {
fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(-125);
@@ -337,6 +355,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) {
widgetsMask |= CUSTOM_FUNCTION_REPEAT;
fswtchRepeat[i]->update();
}
if (index==FuncPlayValue) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt();
@@ -381,14 +400,20 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) {
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm));
int vml=GetEepromInterface()->getCapability(VoicesMaxLength);
int vml = GetEepromInterface()->getCapability(VoicesMaxLength);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(),vml); j++) {
for (int j=0; j<std::min(fswtchParamArmT[i]->currentText().length(), vml); j++) {
model.funcSw[i].paramarm[j] = fswtchParamArmT[i]->currentText().toAscii().at(j);
}
}
}
else {
populateFuncParamArmTCB(fswtchParamArmT[i], model.funcSw[i].paramarm, paramarmList);
if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY;
}
}
}
}
else if (index==FuncBackgroundMusic) {
@@ -453,13 +478,13 @@ void CustomFunctionsPanel::fswPaste()
const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-fsw")) {
QByteArray fswData = mimeData->data("application/x-companion-fsw");
FuncSwData *fsw = &model.funcSw[selectedFunction];
memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData));
// TODO update switch and func
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF);
lock = true;
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction);
lock = false;
emit modified();
}
}
@@ -468,7 +493,7 @@ void CustomFunctionsPanel::fswDelete()
{
model.funcSw[selectedFunction].clear();
// TODO update switch and func
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF);
populateSwitchCB(fswtchSwtch[selectedFunction], model.funcSw[selectedFunction].swtch, POPULATE_ONOFF);
populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction);
emit modified();
@@ -476,17 +501,17 @@ void CustomFunctionsPanel::fswDelete()
void CustomFunctionsPanel::fswCopy()
{
QByteArray fswData;
fswData.append((char*)&model.funcSw[selectedFunction],sizeof(FuncSwData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-fsw", fswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
QByteArray fswData;
fswData.append((char*)&model.funcSw[selectedFunction], sizeof(FuncSwData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-fsw", fswData);
QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
}
void CustomFunctionsPanel::fswCut()
{
fswCopy();
fswDelete();
fswCopy();
fswDelete();
}
void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
@@ -508,3 +533,124 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
contextMenu.exec(globalPos);
}
void CustomFunctionsPanel::populateFuncCB(QComboBox *b, unsigned int value)
{
b->clear();
for (unsigned int i=0; i<FuncCount; i++) {
b->addItem(FuncSwData(AssignFunc(i)).funcToString());
if (!GetEepromInterface()->getCapability(HasVolume)) {
if (i==FuncVolume || i==FuncBackgroundMusic || i==FuncBackgroundMusicPause) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
if ((i==FuncPlayHaptic) && !GetEepromInterface()->getCapability(Haptic)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncPlayBoth) && !GetEepromInterface()->getCapability(HasBeeper)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
if ((i==FuncLogs) && !GetEepromInterface()->getCapability(HasSDLogs)) {
QModelIndex index = b->model()->index(i, 0);
QVariant v(0);
b->model()->setData(index, v, Qt::UserRole - 1);
}
}
b->setCurrentIndex(value);
b->setMaxVisibleItems(10);
}
void CustomFunctionsPanel::populateGVmodeCB(QComboBox *b, unsigned int value)
{
b->clear();
b->addItem(QObject::tr("Value"));
b->addItem(QObject::tr("Source"));
b->addItem(QObject::tr("GVAR"));
b->addItem(QObject::tr("Increment"));
b->setCurrentIndex(value);
}
void CustomFunctionsPanel::populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList)
{
b->clear();
b->addItem("----");
bool added = false;
QString currentvalue(value);
foreach ( QString entry, paramsList ) {
b->addItem(entry);
if (entry==currentvalue) {
b->setCurrentIndex(b->count()-1);
added = true;
}
}
if (!added && strlen(value)) {
b->addItem(value);
b->setCurrentIndex(b->count()-1);
}
}
void CustomFunctionsPanel::populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode)
{
QStringList qs;
b->clear();
if (function==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
int reCount = GetEepromInterface()->getCapability(RotaryEncoders);
if (reCount == 1) {
qs.append( QObject::tr("Rotary Encoder"));
}
else if (reCount == 2) {
qs.append( QObject::tr("REa"));
qs.append( QObject::tr("REb"));
}
b->addItems(qs);
b->setCurrentIndex(value);
}
else if (function==FuncVolume) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS);
}
else if (function==FuncPlayValue) {
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_VIRTUAL_INPUTS|POPULATE_SWITCHES|POPULATE_GVARS|POPULATE_TRIMS|POPULATE_TELEMETRYEXT);
}
else if (function>=FuncAdjustGV1 && function<=FuncAdjustGVLast) {
switch (adjustmode) {
case 1:
populateSourceCB(b, RawSource(value), model, POPULATE_SOURCES|POPULATE_TRIMS|POPULATE_SWITCHES);
break;
case 2:
populateSourceCB(b, RawSource(value), model, POPULATE_GVARS);
break;
case 3:
b->clear();
b->addItem("-1", 0);
b->addItem("+1", 1);
b->setCurrentIndex(value);
break;
}
}
else {
b->hide();
}
}
+8 -1
View File
@@ -19,6 +19,7 @@ class RepeatComboBox: public QComboBox
public:
RepeatComboBox(QWidget *parent, int & repeatParam);
void update();
signals:
void modified();
@@ -55,7 +56,13 @@ class CustomFunctionsPanel : public ModelPanel
void fswCut();
private:
void populateFuncCB(QComboBox *b, unsigned int value);
void populateGVmodeCB(QComboBox *b, unsigned int value);
void populateFuncParamCB(QComboBox *b, const ModelData & model, uint function, unsigned int value, unsigned int adjustmode=0);
void populateFuncParamArmTCB(QComboBox *b, char * value, QStringList & paramsList);
GeneralSettings & generalSettings;
QStringList paramarmList;
bool phononLock;
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchFunc[C9X_MAX_CUSTOM_FUNCTIONS];
@@ -65,7 +72,7 @@ class CustomFunctionsPanel : public ModelPanel
QComboBox * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS];
QCheckBox * fswtchEnable[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
RepeatComboBox * fswtchRepeat[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS];
#ifdef PHONON
Phonon::MediaObject *clickObject;
+161 -171
View File
@@ -7,7 +7,7 @@
#include <QDoubleSpinBox>
#include "helpers.h"
CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model):
ModelPanel(parent, model),
selectedSwitch(0)
{
@@ -18,13 +18,13 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
addLabel(gridLayout, tr("V1"), col++);
addLabel(gridLayout, tr("V2"), col++);
addLabel(gridLayout, tr("AND"), col++);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
addLabel(gridLayout, tr("Duration"), col++);
addLabel(gridLayout, tr("Delay"), col++);
}
lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
// The label
QLabel * label = new QLabel(this);
label->setProperty("index", i);
@@ -46,7 +46,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// V1
cswitchSource1[i] = new QComboBox(this);
cswitchSource1[i]->setProperty("index",i);
connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int)));
gridLayout->addWidget(cswitchSource1[i], i+1, 2);
cswitchSource1[i]->setVisible(false);
cswitchValue[i] = new QDoubleSpinBox(this);
@@ -62,7 +62,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// V2
cswitchSource2[i] = new QComboBox(this);
cswitchSource2[i]->setProperty("index", i);
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int)));
gridLayout->addWidget(cswitchSource2[i], i+1, 3);
cswitchSource2[i]->setVisible(false);
cswitchOffset[i] = new QDoubleSpinBox(this);
@@ -78,11 +78,10 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// AND
cswitchAnd[i] = new QComboBox(this);
cswitchAnd[i]->setProperty("index", i);
connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited()));
connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int)));
gridLayout->addWidget(cswitchAnd[i], i+1, 4);
cswitchAnd[i]->setVisible(false);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
// Duration
cswitchDuration[i] = new QDoubleSpinBox(this);
cswitchDuration[i]->setProperty("index", i);
@@ -91,9 +90,8 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
cswitchDuration[i]->setMinimum(0);
cswitchDuration[i]->setAccelerated(true);
cswitchDuration[i]->setDecimals(1);
connect(cswitchDuration[i],SIGNAL(editingFinished()), this, SLOT(edited()));
connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double)));
gridLayout->addWidget(cswitchDuration[i], i+1, 5);
cswitchDuration[i]->setVisible(false);
// Delay
cswitchDelay[i] = new QDoubleSpinBox(this);
@@ -103,75 +101,114 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
cswitchDelay[i]->setMinimum(0);
cswitchDelay[i]->setAccelerated(true);
cswitchDelay[i]->setDecimals(1);
connect(cswitchDelay[i], SIGNAL(editingFinished()), this, SLOT(edited()));
connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double)));
gridLayout->addWidget(cswitchDelay[i], i+1, 6);
cswitchDelay[i]->setVisible(false);
}
}
lock = false;
}
CustomSwitchesPanel::~CustomSwitchesPanel()
LogicalSwitchesPanel::~LogicalSwitchesPanel()
{
}
void CustomSwitchesPanel::edited()
void LogicalSwitchesPanel::v1Edited(int value)
{
if (!lock) {
int i = sender()->property("index").toInt();
model.customSw[i].val1 = cswitchSource1[i]->itemData(value).toInt();
if (model.customSw[i].getFunctionFamily() == LS_FAMILY_VOFS) {
RawSource source = RawSource(model.customSw[i].val1, &model);
if (source.type == SOURCE_TYPE_TELEMETRY) {
if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) {
model.customSw[i].val2 = 0;
}
else {
model.customSw[i].val2 = -128;
}
}
else {
RawSourceRange range = source.getRange();
if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
}
else {
model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/;
}
}
setSwitchWidgetVisibility(i);
}
emit modified();
}
}
void LogicalSwitchesPanel::v2Edited(int value)
{
if (!lock) {
int i = sender()->property("index").toInt();
model.customSw[i].val2 = cswitchSource2[i]->itemData(value).toInt();
emit modified();
}
}
void LogicalSwitchesPanel::andEdited(int value)
{
if (!lock) {
int index = sender()->property("index").toInt();
model.customSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
emit modified();
}
}
void LogicalSwitchesPanel::durationEdited(double duration)
{
int index = sender()->property("index").toInt();
model.customSw[index].duration = (uint8_t)round(duration*2);
emit modified();
}
void LogicalSwitchesPanel::delayEdited(double delay)
{
int index = sender()->property("index").toInt();
model.customSw[index].delay = (uint8_t)round(delay*2);
emit modified();
}
void LogicalSwitchesPanel::edited()
{
if (!lock) {
lock = true;
int i = sender()->property("index").toInt();
bool chAr;
float value, step;
int newval;
chAr = (getCSFunctionFamily(model.customSw[i].func) != getCSFunctionFamily(csw[i]->itemData(csw[i]->currentIndex()).toInt()));
model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt();
if(chAr) {
if (getCSFunctionFamily(model.customSw[i].func)==CS_FAMILY_TIMERS) {
int newFunc = csw[i]->itemData(csw[i]->currentIndex()).toInt();
bool chAr = (model.customSw[i].getFunctionFamily() != LogicalSwitchData(newFunc).getFunctionFamily());
model.customSw[i].func = newFunc;
if (chAr) {
if (model.customSw[i].getFunctionFamily() == LS_FAMILY_TIMER) {
model.customSw[i].val1 = -119;
model.customSw[i].val2 = -119;
} else {
}
else if (model.customSw[i].getFunctionFamily() == LS_FAMILY_STAY) {
model.customSw[i].val1 = 0;
model.customSw[i].val2 = -129;
model.customSw[i].val3 = 0;
}
else {
model.customSw[i].val1 = 0;
model.customSw[i].val2 = 0;
}
model.customSw[i].andsw = 0;
setSwitchWidgetVisibility(i);
}
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
model.customSw[i].duration= (uint8_t)round(cswitchDuration[i]->value()*2);
model.customSw[i].delay= (uint8_t)round(cswitchDelay[i]->value()*2);
}
RawSource source;
switch (getCSFunctionFamily(model.customSw[i].func))
switch (model.customSw[i].getFunctionFamily())
{
case (CS_FAMILY_VOFS):
if (model.customSw[i].val1 != cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt()) {
source = RawSource(model.customSw[i].val1, &model);
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
RawSource newSource = RawSource(model.customSw[i].val1, &model);
if (newSource.type == SOURCE_TYPE_TELEMETRY) {
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
model.customSw[i].val2 = 0;
}
else {
model.customSw[i].val2 = -128;
}
}
else {
RawSourceRange range = source.getRange();
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
}
else {
model.customSw[i].val2 = (cswitchOffset[i]->value() - range.offset) / range.step/* TODO - source.getRawOffset(model)*/;
}
}
setSwitchWidgetVisibility(i);
}
else {
case LS_FAMILY_VOFS:
{
source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange();
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
if (model.customSw[i].func>LS_FN_ELESS && model.customSw[i].func<LS_FN_VEQUAL) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
cswitchOffset[i]->setValue(model.customSw[i].val2*range.step);
}
@@ -181,84 +218,50 @@ void CustomSwitchesPanel::edited()
}
}
break;
case (CS_FAMILY_TIMERS): {
value = cswitchOffset[i]->value();
newval=TimToVal(value);
if (newval>model.customSw[i].val2) {
if (value >=60) {
value=round(value);
step=1;
} else if (value>=2) {
value=(round(value*2.0)/2);
step=0.5;
} else {
step=0.1;
}
} else {
if (value <=2) {
step=0.1;
} else if (value<=60) {
value=(round(value*2.0)/2);
step=0.5;
} else {
value=round(value);
step=1;
}
}
model.customSw[i].val2=TimToVal(value);
value=ValToTim(model.customSw[i].val2);
cswitchOffset[i]->setValue(value);
cswitchOffset[i]->setSingleStep(step);
value=cswitchValue[i]->value();
newval=TimToVal(value);
if (newval>model.customSw[i].val1) {
if (value >=60) {
value=round(value);
step=1;
} else if (value>=2) {
value=(round(value*2.0)/2);
step=0.5;
} else {
step=0.1;
}
} else {
if (value <=2) {
step=0.1;
} else if (value<=60) {
value=(round(value*2.0)/2);
step=0.5;
} else {
value=round(value);
step=1;
}
}
model.customSw[i].val1=TimToVal(value);
value=ValToTim(model.customSw[i].val1);
cswitchValue[i]->setValue(value);
cswitchValue[i]->setSingleStep(step);
case LS_FAMILY_TIMER:
model.customSw[i].val1 = TimToVal(cswitchValue[i]->value());
model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchValue[i], model.customSw[i].val1);
updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
break;
}
case (CS_FAMILY_VBOOL):
case (CS_FAMILY_VCOMP):
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt();
model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt();
case LS_FAMILY_STAY:
model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
break;
default:
break;
}
model.customSw[i].andsw = cswitchAnd[i]->itemData(cswitchAnd[i]->currentIndex()).toInt();
emit modified();
lock = false;
}
}
void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
void LogicalSwitchesPanel::updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero)
{
sb->setVisible(true);
sb->setDecimals(1);
sb->setMinimum(allowZero ? 0.0 : 0.1);
sb->setMaximum(175);
float value = ValToTim(timer);
if (value>60)
sb->setSingleStep(1);
else if (value>2)
sb->setSingleStep(0.5);
else
sb->setSingleStep(0.1);
sb->setValue(value);
}
void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
{
lock = true;
RawSource source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange();
switch (getCSFunctionFamily(model.customSw[i].func))
switch (model.customSw[i].getFunctionFamily())
{
case CS_FAMILY_VOFS:
case LS_FAMILY_VOFS:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(false);
@@ -266,17 +269,19 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
cswitchOffset[i]->setDecimals(range.decimals);
cswitchOffset[i]->setSingleStep(range.step);
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
if (model.customSw[i].func>LS_FN_ELESS && model.customSw[i].func<LS_FN_VEQUAL) {
cswitchOffset[i]->setMinimum(range.step*-127);
cswitchOffset[i]->setMaximum(range.step*127);
cswitchOffset[i]->setValue(range.step*model.customSw[i].val2);
} else {
}
else {
cswitchOffset[i]->setMinimum(range.min);
cswitchOffset[i]->setMaximum(range.max);
cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
}
break;
case CS_FAMILY_VBOOL:
case LS_FAMILY_VBOOL:
case LS_FAMILY_STICKY:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false);
@@ -284,7 +289,14 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2));
break;
case CS_FAMILY_VCOMP:
case LS_FAMILY_STAY:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(false);
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
break;
case LS_FAMILY_VCOMP:
cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false);
@@ -292,87 +304,65 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSourceCB(cswitchSource1[i], RawSource(model.customSw[i].val1), model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
populateSourceCB(cswitchSource2[i], RawSource(model.customSw[i].val2), model, POPULATE_SOURCES | POPULATE_TRIMS | POPULATE_VIRTUAL_INPUTS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
break;
case CS_FAMILY_TIMERS:
case LS_FAMILY_TIMER:
cswitchSource1[i]->setVisible(false);
cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(true);
cswitchOffset[i]->setVisible(true);
cswitchOffset[i]->setDecimals(1);
cswitchOffset[i]->setMinimum(0.1);
cswitchOffset[i]->setMaximum(175);
float value=ValToTim(model.customSw[i].val2);
cswitchOffset[i]->setSingleStep(0.1);
if (value>60) {
cswitchOffset[i]->setSingleStep(1);
} else if (value>2) {
cswitchOffset[i]->setSingleStep(0.5);
}
cswitchOffset[i]->setValue(value);
cswitchValue[i]->setDecimals(1);
cswitchValue[i]->setMinimum(0.1);
cswitchValue[i]->setMaximum(175);
value=ValToTim(model.customSw[i].val1);
cswitchValue[i]->setSingleStep(0.1);
if (value>60) {
cswitchValue[i]->setSingleStep(1);
} else if (value>2) {
cswitchValue[i]->setSingleStep(0.5);
}
cswitchValue[i]->setValue(value);
updateTimerParam(cswitchValue[i], model.customSw[i].val1);
updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
break;
}
cswitchAnd[i]->setVisible(true);
populateSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw), POPULATE_AND_SWITCHES);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
cswitchDuration[i]->setVisible(true);
lock = false;
}
void LogicalSwitchesPanel::update()
{
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
lock = true;
populateCSWCB(csw[i], model.customSw[i].func);
lock = false;
setSwitchWidgetVisibility(i);
lock = true;
populateAndSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw));
if (GetEepromInterface()->getCapability(LogicalSwitchesExt)) {
cswitchDuration[i]->setValue(model.customSw[i].duration/2.0);
cswitchDelay[i]->setVisible(true);
cswitchDelay[i]->setValue(model.customSw[i].delay/2.0);
}
}
void CustomSwitchesPanel::update()
{
lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
populateCSWCB(csw[i], model.customSw[i].func);
setSwitchWidgetVisibility(i);
lock = false;
}
lock = false;
}
void CustomSwitchesPanel::cswPaste()
void LogicalSwitchesPanel::cswPaste()
{
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-csw")) {
QByteArray cswData = mimeData->data("application/x-companion-csw");
CustomSwData *csw = &model.customSw[selectedSwitch];
memcpy(csw, cswData.mid(0, sizeof(CustomSwData)).constData(), sizeof(CustomSwData));
LogicalSwitchData *csw = &model.customSw[selectedSwitch];
memcpy(csw, cswData.mid(0, sizeof(LogicalSwitchData)).constData(), sizeof(LogicalSwitchData));
emit modified();
updateSelectedSwitch();
}
}
void CustomSwitchesPanel::cswDelete()
void LogicalSwitchesPanel::cswDelete()
{
model.customSw[selectedSwitch].clear();
emit modified();
updateSelectedSwitch();
}
void CustomSwitchesPanel::cswCopy()
void LogicalSwitchesPanel::cswCopy()
{
QByteArray cswData;
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(CustomSwData));
cswData.append((char*)&model.customSw[selectedSwitch],sizeof(LogicalSwitchData));
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-csw", cswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard);
}
void CustomSwitchesPanel::updateSelectedSwitch()
void LogicalSwitchesPanel::updateSelectedSwitch()
{
lock = true;
populateCSWCB(csw[selectedSwitch], model.customSw[selectedSwitch].func);
@@ -380,14 +370,14 @@ void CustomSwitchesPanel::updateSelectedSwitch()
lock = false;
}
void CustomSwitchesPanel::cswCut()
void LogicalSwitchesPanel::cswCut()
{
cswCopy();
cswDelete();
}
// TODO make something generic here!
void CustomSwitchesPanel::csw_customContextMenuRequested(QPoint pos)
void LogicalSwitchesPanel::csw_customContextMenuRequested(QPoint pos)
{
QLabel *label = (QLabel *)sender();
selectedSwitch = label->property("index").toInt();
+10 -3
View File
@@ -5,18 +5,23 @@
#include <QComboBox>
#include <QDoubleSpinBox>
class CustomSwitchesPanel : public ModelPanel
class LogicalSwitchesPanel : public ModelPanel
{
Q_OBJECT
public:
CustomSwitchesPanel(QWidget *parent, ModelData & model);
virtual ~CustomSwitchesPanel();
LogicalSwitchesPanel(QWidget *parent, ModelData & model);
virtual ~LogicalSwitchesPanel();
virtual void update();
private slots:
void edited();
void v1Edited(int value);
void v2Edited(int value);
void andEdited(int value);
void durationEdited(double duration);
void delayEdited(double delay);
void csw_customContextMenuRequested(QPoint pos);
void cswDelete();
void cswCopy();
@@ -36,6 +41,8 @@ class CustomSwitchesPanel : public ModelPanel
int selectedSwitch;
void updateSelectedSwitch();
void updateV2(int index);
void updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero=false);
};
+1 -1
View File
@@ -30,7 +30,7 @@ ModelEdit::ModelEdit(RadioData & radioData, int modelId, bool openWizard, bool i
addTab(new InputsPanel(this, model, radioData.generalSettings), tr("Inputs"));
addTab(new MixesPanel(this, model, radioData.generalSettings), tr("Mixes"));
addTab(new Channels(this, model), tr("Channels"));
addTab(new CustomSwitchesPanel(this, model), tr("Logical Switches"));
addTab(new LogicalSwitchesPanel(this, model), tr("Logical Switches"));
if (GetEepromInterface()->getCapability(CustomFunctions))
addTab(new CustomFunctionsPanel(this, model, radioData.generalSettings), tr("Switch Assignment"));
addTab(new Curves(this, model), tr("Curves"));
+9 -3
View File
@@ -11,8 +11,10 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
{
ui->setupUi(this);
lock = true;
// Mode
populateTimerSwitchCB(ui->mode, timer.mode);
populateSwitchCB(ui->mode, timer.mode, POPULATE_TIMER_MODES);
if (!GetEepromInterface()->getCapability(PermTimers)) {
ui->persistent->hide();
@@ -23,6 +25,8 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
ui->countdownBeep->addItem(tr("Beeps"));
if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard()))
ui->countdownBeep->addItem(tr("Countdown"));
lock = false;
}
TimerPanel::~TimerPanel()
@@ -63,8 +67,10 @@ void TimerPanel::on_value_editingFinished()
void TimerPanel::on_mode_currentIndexChanged(int index)
{
timer.mode = TimerMode(ui->mode->itemData(index).toInt());
emit modified();
if (!lock) {
timer.mode = RawSwitch(ui->mode->itemData(index).toInt());
emit modified();
}
}
void TimerPanel::on_persistent_toggled(bool checked)
+1 -1
View File
@@ -352,7 +352,7 @@ void TelemetryCustomScreen::updateBar(int line)
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model);
RawSourceRange range = source.getRange(true);
int max = round((range.max - range.min) / range.step);
if (255-screen.body.bars[line].barMax > max)
if (int(255-screen.body.bars[line].barMax) > max)
screen.body.bars[line].barMax = 255 - max;
minSB[line]->setEnabled(true);
minSB[line]->setDecimals(range.decimals);
+5 -5
View File
@@ -584,8 +584,8 @@ void Templates::applyTemplate(uint8_t idx)
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_CH, 13); md->weight= 100; md->swtch=RawSwitch();
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-100; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 11); md->mltpx=MLTPX_REP;
md=setDest(14); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 100; md->swtch=RawSwitch(SWITCH_TYPE_SWITCH,thrsw); md->mltpx=MLTPX_REP;
setSwitch(0xB, CS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99);
setSwitch(0xC, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0);
setSwitch(0xB, LS_FN_VNEG, RawSource(SOURCE_TYPE_STICK, 2).toValue(), -99);
setSwitch(0xC, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 13).toValue(), 0);
updateSwitchesTab();
}
@@ -841,9 +841,9 @@ void Templates::applyTemplate(uint8_t idx)
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_CUSTOM_SWITCH, 0); md->weight= 110; md->swtch=RawSwitch();
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight=-110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 2); md->mltpx=MLTPX_REP;
md=setDest(16); md->srcRaw=RawSource(SOURCE_TYPE_MAX); md->weight= 110; md->swtch=RawSwitch(SWITCH_TYPE_VIRTUAL, 3); md->mltpx=MLTPX_REP;
setSwitch(1, CS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue());
setSwitch(2, CS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105);
setSwitch(3, CS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105);
setSwitch(1, LS_FN_LESS, RawSource(SOURCE_TYPE_CH, 14).toValue(), RawSource(SOURCE_TYPE_CH, 15).toValue());
setSwitch(2, LS_FN_VPOS, RawSource(SOURCE_TYPE_CH, 14).toValue(), 105);
setSwitch(3, LS_FN_VNEG, RawSource(SOURCE_TYPE_CH, 14).toValue(), -105);
// redraw switches tab
updateSwitchesTab();
+4 -32
View File
@@ -54,7 +54,6 @@ printDialog::printDialog(QWidget *parent, GeneralSettings *gg, ModelData *gm, QS
printCurves();
printGvars();
printSwitches();
printSafetySwitches();
printFSwitches();
printFrSky();
@@ -643,7 +642,7 @@ void printDialog::printSwitches()
str.append("<tr><td><h2>"+tr("Logical Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=0 cellspacing=0 cellpadding=3>");
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
for (int i=0; i<GetEepromInterface()->getCapability(LogicalSwitches); i++) {
if (g_model->customSw[i].func) {
str.append("<tr>");
if (i<9) {
@@ -651,7 +650,7 @@ void printDialog::printSwitches()
} else {
str.append("<td width=\"60\" align=\"center\"><b>"+tr("LS")+('A'+(i-9))+"</b></td>");
}
QString tstr = getCustomSwitchStr(&g_model->customSw[i], *g_model);
QString tstr = g_model->customSw[i].toString(*g_model);
str.append(doTC(tstr,"green"));
str.append("</tr>");
sc++;
@@ -693,33 +692,6 @@ void printDialog::printGvars()
}
}
void printDialog::printSafetySwitches()
{
int sc=0;
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">";
str.append("<tr><td><h2>"+tr("Safety Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=0 cellspacing=0 cellpadding=3><tr>");
str.append("<td width=\"60\">&nbsp;</td>");
str.append(doTC(tr("Switch"), "", true));
str.append(doTL(tr("Value"), "", true));
str.append("</tr>");
for(int i=0; i<GetEepromInterface()->getCapability(Outputs); i++)
{
if (g_model->safetySw[i].swtch.type) {
str.append("<tr>");
str.append(doTC(tr("CH")+QString("%1").arg(i+1),"",true));
str.append(doTC(g_model->safetySw[i].swtch.toString(),"green"));
str.append(doTC(QString::number(g_model->safetySw[i].val),"green"));
str.append("</tr>");
sc++;
}
}
str.append("</table></td></tr></table>");
str.append("<br>");
if (sc!=0)
te->append(str);
}
void printDialog::printFSwitches()
{
int sc=0;
@@ -736,8 +708,8 @@ void printDialog::printFSwitches()
if (g_model->funcSw[i].swtch.type!=SWITCH_TYPE_NONE) {
str.append("<tr>");
str.append(doTC(g_model->funcSw[i].swtch.toString(),"green"));
str.append(doTC(getFuncName(g_model->funcSw[i].func),"green"));
str.append(doTC(FuncParam(g_model->funcSw[i].func,g_model->funcSw[i].param,g_model->funcSw[i].paramarm, g_model->funcSw[i].adjustMode),"green"));
str.append(doTC(g_model->funcSw[i].funcToString(),"green"));
str.append(doTC(g_model->funcSw[i].paramToString(),"green"));
int index=g_model->funcSw[i].func;
if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
str.append(doTC(QString("%1").arg(g_model->funcSw[i].repeatParam),"green"));
+1 -1
View File
@@ -356,7 +356,7 @@ void simulatorDialog::loadParams(RadioData &radioData, const int model_idx)
beepVal = 0;
beepShow = 0;
switches=txInterface->getCapability(CustomSwitches);
switches=txInterface->getCapability(LogicalSwitches);
if ( switches < 13) {
ui->cswitch_13->hide();
ui->labelCSW_13->hide();