Merge branch 'bsongis/Issue592_sticky_switches' into next
Conflicts: radio/src/gui/menu_model.cpp
This commit is contained in:
@@ -83,7 +83,6 @@ void compareDialog::printDiff()
|
||||
printCurves();
|
||||
printGvars();
|
||||
printSwitches();
|
||||
printSafetySwitches();
|
||||
printFSwitches();
|
||||
printFrSky();
|
||||
te->scrollToAnchor("1");
|
||||
@@ -1041,8 +1040,8 @@ void compareDialog::printSwitches()
|
||||
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);
|
||||
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%\"> </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> </td><td> </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> </td><td> </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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 CustomSwData::getFunctionFamily()
|
||||
{
|
||||
if (func == CS_FN_STAY)
|
||||
return CS_FAMILY_STAY;
|
||||
else if (func == CS_FN_TIMER)
|
||||
return CS_FAMILY_TIMER;
|
||||
else if (func == CS_FN_STICKY)
|
||||
return CS_FAMILY_STICKY;
|
||||
else if (func < CS_FN_AND || func > CS_FN_ELESS)
|
||||
return CS_FAMILY_VOFS;
|
||||
else if (func < CS_FN_EQUAL)
|
||||
return CS_FAMILY_VBOOL;
|
||||
else
|
||||
return CS_FAMILY_VCOMP;
|
||||
}
|
||||
|
||||
QString CustomSwData::funcToString()
|
||||
{
|
||||
switch (func) {
|
||||
case CS_FN_OFF:
|
||||
return QObject::tr("---");
|
||||
case CS_FN_VPOS:
|
||||
return QObject::tr("a>x");
|
||||
case CS_FN_VNEG:
|
||||
return QObject::tr("a<x");
|
||||
case CS_FN_APOS:
|
||||
return QObject::tr("|a|>x");
|
||||
case CS_FN_ANEG:
|
||||
return QObject::tr("|a|<x");
|
||||
case CS_FN_AND:
|
||||
return QObject::tr("AND");
|
||||
case CS_FN_OR:
|
||||
return QObject::tr("OR");
|
||||
case CS_FN_XOR:
|
||||
return QObject::tr("XOR");
|
||||
case CS_FN_EQUAL:
|
||||
return QObject::tr("a=b");
|
||||
case CS_FN_NEQUAL:
|
||||
return QObject::tr("a!=b");
|
||||
case CS_FN_GREATER:
|
||||
return QObject::tr("a>b");
|
||||
case CS_FN_LESS:
|
||||
return QObject::tr("a<b");
|
||||
case CS_FN_EGREATER:
|
||||
return QObject::tr("a>=b");
|
||||
case CS_FN_ELESS:
|
||||
return QObject::tr("a<=b");
|
||||
case CS_FN_DPOS:
|
||||
return QObject::tr("d>=x");
|
||||
case CS_FN_DAPOS:
|
||||
return QObject::tr("|d|>=x");
|
||||
case CS_FN_VEQUAL:
|
||||
return QObject::tr("a~x");
|
||||
case CS_FN_TIMER:
|
||||
return QObject::tr("Timer");
|
||||
case CS_FN_STICKY:
|
||||
return QObject::tr("Sticky");
|
||||
case CS_FN_STAY:
|
||||
return QObject::tr("Stay");
|
||||
default:
|
||||
return QObject::tr("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
QString CustomSwData::toString(const ModelData & model)
|
||||
{
|
||||
QString result = "";
|
||||
|
||||
if (!func)
|
||||
return result;
|
||||
|
||||
if (andsw!=0) {
|
||||
result +="( ";
|
||||
}
|
||||
switch (getFunctionFamily()) {
|
||||
case CS_FAMILY_STAY:
|
||||
result = QObject::tr("STAY(%1, [%2:%3])").arg(RawSwitch(val1).toString()).arg(ValToTim(val2)).arg(ValToTim(val2+val3));
|
||||
break;
|
||||
case CS_FAMILY_STICKY:
|
||||
result = QObject::tr("STICKY(%1, %2)").arg(RawSwitch(val1).toString()).arg(RawSwitch(val2).toString());
|
||||
break;
|
||||
case CS_FAMILY_TIMER:
|
||||
result = QObject::tr("TIMER(%1, %2)").arg(ValToTim(val1)).arg(ValToTim(val2));
|
||||
break;
|
||||
case CS_FAMILY_VOFS: {
|
||||
RawSource source = RawSource(val1, &model);
|
||||
RawSourceRange range = source.getRange();
|
||||
if (val1)
|
||||
result += source.toString();
|
||||
else
|
||||
result += "0";
|
||||
result.remove(" ");
|
||||
if (func == CS_FN_APOS || func == CS_FN_ANEG)
|
||||
result = "|" + result + "|";
|
||||
else if (func == CS_FN_DAPOS)
|
||||
result = "|d(" + result + ")|";
|
||||
else if (func == CS_FN_DPOS) result = "d(" + result + ")";
|
||||
if (func == CS_FN_APOS || func == CS_FN_VPOS || func == CS_FN_DAPOS || func == CS_FN_DPOS)
|
||||
result += " > ";
|
||||
else if (func == CS_FN_ANEG || func == CS_FN_VNEG)
|
||||
result += " < ";
|
||||
result += QString::number(range.step * (val2 /*TODO+ source.getRawOffset(model)*/) + range.offset);
|
||||
break;
|
||||
}
|
||||
case CS_FAMILY_VBOOL:
|
||||
result = RawSwitch(val1).toString();
|
||||
switch (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(val2).toString();
|
||||
break;
|
||||
|
||||
case CS_FAMILY_VCOMP:
|
||||
if (val1)
|
||||
result += RawSource(val1).toString();
|
||||
else
|
||||
result += "0";
|
||||
switch (func) {
|
||||
case CS_FN_EQUAL:
|
||||
result += " = ";
|
||||
break;
|
||||
case CS_FN_NEQUAL:
|
||||
result += " != ";
|
||||
break;
|
||||
case CS_FN_GREATER:
|
||||
result += " > ";
|
||||
break;
|
||||
case CS_FN_LESS:
|
||||
result += " < ";
|
||||
break;
|
||||
case CS_FN_EGREATER:
|
||||
result += " >= ";
|
||||
break;
|
||||
case CS_FN_ELESS:
|
||||
result += " <= ";
|
||||
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(CustomSwitchesExt)) {
|
||||
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( " ","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();
|
||||
|
||||
@@ -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 {
|
||||
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_TIMER,
|
||||
CS_FN_STICKY,
|
||||
CS_FN_STAY,
|
||||
// later ... CS_FN_RANGE,
|
||||
CS_FN_MAX
|
||||
};
|
||||
|
||||
class SafetySwData { // Custom Switches data
|
||||
public:
|
||||
SafetySwData() { clear(); }
|
||||
RawSwitch swtch;
|
||||
int val;
|
||||
enum CSFunctionFamily {
|
||||
CS_FAMILY_VOFS,
|
||||
CS_FAMILY_VBOOL,
|
||||
CS_FAMILY_VCOMP,
|
||||
CS_FAMILY_TIMER,
|
||||
CS_FAMILY_STICKY,
|
||||
CS_FAMILY_STAY,
|
||||
};
|
||||
|
||||
void clear() { memset(this, 0, sizeof(SafetySwData)); }
|
||||
class CustomSwData { // Custom Switches data
|
||||
public:
|
||||
CustomSwData(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(CustomSwData)); }
|
||||
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 {
|
||||
@@ -897,11 +878,9 @@ class ModelData {
|
||||
CurveData curves[C9X_MAX_CURVES];
|
||||
CustomSwData 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
|
||||
@@ -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,7 +1160,7 @@ 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)) {
|
||||
switch (model.customSw[i].getFunctionFamily()) {
|
||||
case CS_FAMILY_VCOMP:
|
||||
source = RawSource(model.customSw[i].val2);
|
||||
if (source.type == SOURCE_TYPE_STICK)
|
||||
|
||||
@@ -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()
|
||||
@@ -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;
|
||||
|
||||
@@ -168,7 +168,6 @@ PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data
|
||||
int8_t swtch;
|
||||
int8_t val;
|
||||
|
||||
operator SafetySwData();
|
||||
t_Er9xSafetySwData();
|
||||
}) Er9xSafetySwData;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ 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)) {
|
||||
switch (CustomSwData(model.customSw[i].func).getFunctionFamily()) {
|
||||
case CS_FAMILY_VCOMP:
|
||||
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
|
||||
// no break
|
||||
|
||||
@@ -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()
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -210,7 +209,6 @@ 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;
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ 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)) {
|
||||
switch (CustomSwData(model.customSw[i].func).getFunctionFamily()) {
|
||||
case CS_FAMILY_VCOMP:
|
||||
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
|
||||
// no break
|
||||
@@ -106,7 +106,7 @@ 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)) {
|
||||
switch (CustomSwData(model.customSw[i].func).getFunctionFamily()) {
|
||||
case CS_FAMILY_VCOMP:
|
||||
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
|
||||
// no break
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -199,7 +199,6 @@ 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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 ()
|
||||
@@ -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;
|
||||
|
||||
@@ -244,7 +244,6 @@ 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;
|
||||
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
|
||||
+113
-593
@@ -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 += " > ";
|
||||
else if (customSw->func == CS_FN_ANEG || customSw->func == CS_FN_VNEG)
|
||||
result += " < ";
|
||||
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 += " > ";
|
||||
break;
|
||||
case CS_FN_LESS:
|
||||
result += " < ";
|
||||
break;
|
||||
case CS_FN_EGREATER:
|
||||
result += " >= ";
|
||||
break;
|
||||
case CS_FN_ELESS:
|
||||
result += " <= ";
|
||||
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,105 +367,111 @@ 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++) {
|
||||
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);
|
||||
}
|
||||
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(CustomSwitches); i++) {
|
||||
@@ -895,66 +480,12 @@ void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (attr & POPULATE_ONOFF) {
|
||||
item = RawSwitch(SWITCH_TYPE_ON);
|
||||
b->addItem(item.toString(), item.toValue());
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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[] = {
|
||||
CS_FN_OFF,
|
||||
CS_FN_VEQUAL, // added at the end to avoid everything renumbered
|
||||
CS_FN_VPOS,
|
||||
CS_FN_VNEG,
|
||||
// CS_FN_RANGE,
|
||||
CS_FN_APOS,
|
||||
CS_FN_ANEG,
|
||||
CS_FN_AND,
|
||||
CS_FN_OR,
|
||||
CS_FN_XOR,
|
||||
CS_FN_STAY,
|
||||
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_TIMER,
|
||||
CS_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<CS_FN_MAX; i++) {
|
||||
int func = order[i];
|
||||
b->addItem(CustomSwData(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
|
||||
|
||||
+4
-16
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,9 +78,8 @@ 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)) {
|
||||
// Duration
|
||||
@@ -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,9 +101,8 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,59 +113,99 @@ CustomSwitchesPanel::~CustomSwitchesPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void CustomSwitchesPanel::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() == CS_FAMILY_VOFS) {
|
||||
RawSource source = RawSource(model.customSw[i].val1, &model);
|
||||
if (source.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);
|
||||
}
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomSwitchesPanel::v2Edited(int value)
|
||||
{
|
||||
if (!lock) {
|
||||
int i = sender()->property("index").toInt();
|
||||
model.customSw[i].val2 = cswitchSource2[i]->itemData(value).toInt();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomSwitchesPanel::andEdited(int value)
|
||||
{
|
||||
if (!lock) {
|
||||
int index = sender()->property("index").toInt();
|
||||
model.customSw[index].andsw = cswitchAnd[index]->itemData(value).toInt();
|
||||
emit modified();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomSwitchesPanel::durationEdited(double duration)
|
||||
{
|
||||
int index = sender()->property("index").toInt();
|
||||
model.customSw[index].duration = (uint8_t)round(duration*2);
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void CustomSwitchesPanel::delayEdited(double delay)
|
||||
{
|
||||
int index = sender()->property("index").toInt();
|
||||
model.customSw[index].delay = (uint8_t)round(delay*2);
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void CustomSwitchesPanel::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() != CustomSwData(newFunc).getFunctionFamily());
|
||||
model.customSw[i].func = newFunc;
|
||||
if (chAr) {
|
||||
if (model.customSw[i].getFunctionFamily() == CS_FAMILY_TIMER) {
|
||||
model.customSw[i].val1 = -119;
|
||||
model.customSw[i].val2 = -119;
|
||||
} else {
|
||||
}
|
||||
else if (model.customSw[i].getFunctionFamily() == CS_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 CS_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) {
|
||||
@@ -181,82 +218,48 @@ 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 CS_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 CS_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::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 CustomSwitchesPanel::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:
|
||||
cswitchSource1[i]->setVisible(true);
|
||||
@@ -270,13 +273,15 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
|
||||
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 CS_FAMILY_STICKY:
|
||||
cswitchSource1[i]->setVisible(true);
|
||||
cswitchSource2[i]->setVisible(true);
|
||||
cswitchValue[i]->setVisible(false);
|
||||
@@ -284,6 +289,13 @@ 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_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 CS_FAMILY_VCOMP:
|
||||
cswitchSource1[i]->setVisible(true);
|
||||
cswitchSource2[i]->setVisible(true);
|
||||
@@ -292,54 +304,32 @@ 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 CS_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);
|
||||
cswitchDuration[i]->setValue(model.customSw[i].duration/2.0);
|
||||
cswitchDelay[i]->setVisible(true);
|
||||
cswitchDelay[i]->setValue(model.customSw[i].delay/2.0);
|
||||
}
|
||||
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void CustomSwitchesPanel::update()
|
||||
{
|
||||
lock = true;
|
||||
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); 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(CustomSwitchesExt)) {
|
||||
cswitchDuration[i]->setValue(model.customSw[i].duration/2.0);
|
||||
cswitchDelay[i]->setValue(model.customSw[i].delay/2.0);
|
||||
}
|
||||
lock = false;
|
||||
}
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void CustomSwitchesPanel::cswPaste()
|
||||
|
||||
@@ -17,6 +17,11 @@ class CustomSwitchesPanel : public ModelPanel
|
||||
|
||||
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);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -54,7 +54,6 @@ printDialog::printDialog(QWidget *parent, GeneralSettings *gg, ModelData *gm, QS
|
||||
printCurves();
|
||||
printGvars();
|
||||
printSwitches();
|
||||
printSafetySwitches();
|
||||
printFSwitches();
|
||||
printFrSky();
|
||||
|
||||
@@ -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\"> </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"));
|
||||
|
||||
Reference in New Issue
Block a user