1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-19 14:25:11 +03:00

Merge branch 'bsongis/Issue592_sticky_switches' into next

Conflicts:
	radio/src/gui/menu_model.cpp
This commit is contained in:
Andre Bernet 2014-02-07 23:39:28 +01:00
commit 17823786e4
61 changed files with 2606 additions and 2385 deletions

View file

@ -19,3 +19,4 @@ Grootwitbaas - 9xforums.com (mac)
Adrian Amberg (splash screens) Adrian Amberg (splash screens)
Wallaguest1 - 9xforums.com (splash screens) Wallaguest1 - 9xforums.com (splash screens)
HC1969 - 9xforums.com (splash screens) HC1969 - 9xforums.com (splash screens)

View file

@ -83,7 +83,6 @@ void compareDialog::printDiff()
printCurves(); printCurves();
printGvars(); printGvars();
printSwitches(); printSwitches();
printSafetySwitches();
printFSwitches(); printFSwitches();
printFrSky(); printFrSky();
te->scrollToAnchor("1"); 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><h2>"+tr("Logical Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=1 cellspacing=0 cellpadding=1 width=\"100%\">"); str.append("<tr><td><table border=1 cellspacing=0 cellpadding=1 width=\"100%\">");
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) { for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
QString sw1 = getCustomSwitchStr(&g_model1->customSw[i], *g_model1); QString sw1 = g_model1->customSw[i].toString(*g_model1);
QString sw2 = getCustomSwitchStr(&g_model2->customSw[i], *g_model2); QString sw2 = g_model2->customSw[i].toString(*g_model2);
if (!(sw1.isEmpty() && sw2.isEmpty())) { if (!(sw1.isEmpty() && sw2.isEmpty())) {
str.append("<tr>"); str.append("<tr>");
color=getColor1(sw1,sw2); color=getColor1(sw1,sw2);
@ -1096,8 +1095,8 @@ void compareDialog::printFSwitches()
str.append("<tr>"); str.append("<tr>");
if (g_model1->funcSw[i].swtch.type) { if (g_model1->funcSw[i].swtch.type) {
str.append(doTC(g_model1->funcSw[i].swtch.toString(),color1)); str.append(doTC(g_model1->funcSw[i].swtch.toString(),color1));
str.append(doTC(getFuncName(g_model1->funcSw[i].func),color1)); str.append(doTC(g_model1->funcSw[i].funcToString(),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].paramToString(),color1));
int index=g_model1->funcSw[i].func; int index=g_model1->funcSw[i].func;
if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { 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)); 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)); str.append(doTC(tr("CF")+QString("%1").arg(i+1),"",true));
if (g_model2->funcSw[i].swtch.type) { if (g_model2->funcSw[i].swtch.type) {
str.append(doTC(g_model2->funcSw[i].swtch.toString(),color2)); str.append(doTC(g_model2->funcSw[i].swtch.toString(),color2));
str.append(doTC(getFuncName(g_model2->funcSw[i].func),color2)); str.append(doTC(g_model2->funcSw[i].funcToString(),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].paramToString(),color2));
int index=g_model2->funcSw[i].func; int index=g_model2->funcSw[i].func;
if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { 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)); str.append(doTC(QString("%1").arg(g_model2->funcSw[i].repeatParam),color2));
@ -1142,55 +1141,6 @@ void compareDialog::printFSwitches()
te->append(str); te->append(str);
} }
void compareDialog::printSafetySwitches()
{
QString color1;
QString color2;
int sc=0;
QString str = "<table border=1 cellspacing=0 cellpadding=3 style=\"page-break-before:always;\" width=\"100%\">";
str.append("<tr><td><h2>"+tr("Safety Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=1 cellspacing=0 cellpadding=1 width=\"100%\"><tr>");
str.append("<td width=\"8%\" align=\"center\"><b>"+tr("Switch")+"</b></td>");
str.append("<td width=\"37%\" align=\"center\"><b>"+tr("Value")+"</b></td>");
str.append("<td width=\"10%\">&nbsp;</td>");
str.append("<td width=\"8%\" align=\"center\"><b>"+tr("Switch")+"</b></td>");
str.append("<td width=\"37%\" align=\"center\"><b>"+tr("Value")+"</b></td>");
str.append("</tr>");
for(int i=0; i<GetEepromInterface()->getCapability(Outputs); i++)
{
if ((g_model1->safetySw[i].swtch.type!=SWITCH_TYPE_NONE)||(g_model2->safetySw[i].swtch.type!=SWITCH_TYPE_NONE)) {
if ((g_model1->safetySw[i].swtch!=g_model2->safetySw[i].swtch)||(g_model1->safetySw[i].val!=g_model2->safetySw[i].val)) {
color1="green";
color2="red";
} else {
color1="grey";
color2="grey";
}
str.append("<tr>");
if (g_model1->safetySw[i].swtch.type) {
str.append(doTC(g_model1->safetySw[i].swtch.toString(),color1));
str.append(doTC(QString::number(g_model1->safetySw[i].val),color1));
}
else {
str.append("<td>&nbsp;</td><td>&nbsp;</td>");
}
str.append(doTC(tr("CH")+QString("%1").arg(i+1),"",true));
if (g_model2->safetySw[i].swtch.type) {
str.append(doTC(g_model2->safetySw[i].swtch.toString(),color2));
str.append(doTC(QString::number(g_model2->safetySw[i].val),color2));
} else {
str.append("<td>&nbsp;</td><td>&nbsp;</td>");
}
str.append("</tr>");
sc++;
}
}
str.append("</table></td></tr></table>");
str.append("<br>");
if (sc!=0)
te->append(str);
}
void compareDialog::printFrSky() void compareDialog::printFrSky()
{ {
QString color; QString color;

View file

@ -93,6 +93,17 @@ class DataField {
const char *name; const char *name;
}; };
class ProxyField: public DataField {
public:
ProxyField():
DataField("Proxy")
{
}
virtual DataField * getField() = 0;
};
template<int N> template<int N>
class UnsignedField: public DataField { class UnsignedField: public DataField {
public: public:
@ -273,9 +284,10 @@ class SpareBitsField: public UnsignedField<N> {
template<int N> template<int N>
class CharField: public DataField { class CharField: public DataField {
public: public:
CharField(char *field): CharField(char *field, bool truncate=true):
DataField("Char"), DataField("Char"),
field(field) field(field),
truncate(truncate)
{ {
} }
@ -283,7 +295,7 @@ class CharField: public DataField {
{ {
output.resize(N*8); output.resize(N*8);
int b = 0; int b = 0;
int len = strlen(field); int len = truncate ? strlen(field) : N;
for (int i=0; i<N; i++) { for (int i=0; i<N; i++) {
int idx = (i>=len ? 0 : field[i]); int idx = (i>=len ? 0 : field[i]);
for (int j=0; j<8; j++, b++) { for (int j=0; j<8; j++, b++) {
@ -313,6 +325,7 @@ class CharField: public DataField {
protected: protected:
char * field; char * field;
bool truncate;
}; };
int8_t char2idx(char c); int8_t char2idx(char c);

View file

@ -268,62 +268,52 @@ QString RawSwitch::toString()
QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26") QObject::tr("S21"), QObject::tr("S22"), QObject::tr("S23"), QObject::tr("S24"), QObject::tr("S25"), QObject::tr("S26")
}; };
switch(type) { static const QString trimsSwitches[] = {
case SWITCH_TYPE_SWITCH: QObject::tr("RudTrim Left"), QObject::tr("RudTrim Right"),
if (IS_TARANIS(GetEepromInterface()->getBoard())) QObject::tr("EleTrim Down"), QObject::tr("EleTrim Up"),
return index > 0 ? CHECK_IN_ARRAY(switchesX9D, index-1) : QString("!") + CHECK_IN_ARRAY(switchesX9D, -index-1); QObject::tr("ThrTrim Down"), QObject::tr("ThrTrim Up"),
else QObject::tr("AilTrim Left"), QObject::tr("AilTrim Right")
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;
}
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() 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 += " &gt; ";
else if (func == CS_FN_ANEG || func == CS_FN_VNEG)
result += " &lt; ";
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 += " &gt; ";
break;
case CS_FN_LESS:
result += " &lt; ";
break;
case CS_FN_EGREATER:
result += " &gt;= ";
break;
case CS_FN_ELESS:
result += " &lt;= ";
break;
default:
break;
}
if (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( "&nbsp;","green"));
}
if ((index<=FuncInstantTrim) || (index>FuncBackgroundMusicPause)) {
str.append(doTC((g_model->funcSw[i].enabled ? "ON" : "OFF"),"green"));
} else {
str.append(doTC( "---","green"));
}
return result;
}
#endif
QString FuncSwData::funcToString()
{
if (func >= FuncSafetyCh1 && func <= FuncSafetyCh32)
return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, func).toString());
else if (func == FuncTrainer)
return QObject::tr("Trainer");
else if (func == FuncTrainerRUD)
return QObject::tr("Trainer RUD");
else if (func == FuncTrainerELE)
return QObject::tr("Trainer ELE");
else if (func == FuncTrainerTHR)
return QObject::tr("Trainer THR");
else if (func == FuncTrainerAIL)
return QObject::tr("Trainer AIL");
else if (func == FuncInstantTrim)
return QObject::tr("Instant Trim");
else if (func == FuncPlaySound)
return QObject::tr("Play Sound");
else if (func == FuncPlayHaptic)
return QObject::tr("Play Haptic");
else if (func == FuncReset)
return QObject::tr("Reset");
else if (func == FuncVario)
return QObject::tr("Vario");
else if (func == FuncPlayPrompt)
return QObject::tr("Play Track");
else if (func == FuncPlayBoth)
return QObject::tr("Play Both");
else if (func == FuncPlayValue)
return QObject::tr("Play Value");
else if (func == FuncLogs)
return QObject::tr("Start Logs");
else if (func == FuncVolume)
return QObject::tr("Volume");
else if (func == FuncBacklight)
return QObject::tr("Backlight");
else if (func == FuncBackgroundMusic)
return QObject::tr("Background Music");
else if (func == FuncBackgroundMusicPause)
return QObject::tr("Background Music Pause");
else if (func >= FuncAdjustGV1 && func <= FuncAdjustGVLast)
return QObject::tr("Adjust GV%1").arg(func-FuncAdjustGV1+1);
else {
return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is)
}
}
QString FuncSwData::paramToString()
{
QStringList qs;
if (func <= FuncInstantTrim) {
return QString("%1").arg(param);
}
else if (func==FuncPlaySound) {
qs <<"Beep 1" << "Beep 2" << "Beep 3" << "Warn1" << "Warn2" << "Cheep" << "Ratata" << "Tick" << "Siren" << "Ring" ;
qs << "SciFi" << "Robot" << "Chirp" << "Tada" << "Crickt" << "AlmClk" ;
if (param>=0 && param<(int)qs.count())
return qs.at(param);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncPlayHaptic) {
qs << "0" << "1" << "2" << "3";
if (param>=0 && param<(int)qs.count())
return qs.at(param);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if (func==FuncReset) {
qs.append( QObject::tr("Timer1"));
qs.append( QObject::tr("Timer2"));
qs.append( QObject::tr("All"));
qs.append( QObject::tr("Telemetry"));
if (param>=0 && param<(int)qs.count())
return qs.at(param);
else
return QObject::tr("<font color=red><b>Inconsistent parameter</b></font>");
}
else if ((func==FuncVolume)|| (func==FuncPlayValue)) {
RawSource item(param);
return item.toString();
}
else if ((func==FuncPlayPrompt) || (func==FuncPlayBoth)) {
if ( GetEepromInterface()->getCapability(VoicesAsNumbers)) {
return QString("%1").arg(param);
} else {
return paramarm;
}
}
else if ((func>FuncBackgroundMusicPause) && (func<FuncCount)) {
switch (adjustMode) {
case 0:
return QObject::tr("Value ")+QString("%1").arg(param);
break;
case 1:
return RawSource(param).toString();
break;
case 2:
return RawSource(param).toString();
break;
case 3:
if (param==0) {
return QObject::tr("Decr:")+QString(" -1");
}
else {
return QObject::tr("Incr:")+QString(" +1");
}
break;
default:
return "";
}
}
return "";
}
QString FuncSwData::repeatToString()
{
if (repeatParam==0) {
return QObject::tr("No repeat");
}
else {
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10;
return QObject::tr("%1 sec").arg(step*repeatParam);
}
}
GeneralSettings::GeneralSettings() GeneralSettings::GeneralSettings()
{ {
memset(this, 0, sizeof(GeneralSettings)); memset(this, 0, sizeof(GeneralSettings));
@ -497,7 +871,8 @@ void ModelData::clear()
if (IS_TARANIS(board)) { if (IS_TARANIS(board)) {
moduleData[0].protocol=PXX_XJT_X16; moduleData[0].protocol=PXX_XJT_X16;
moduleData[1].protocol=OFF; moduleData[1].protocol=OFF;
} else { }
else {
moduleData[0].protocol=PPM; moduleData[0].protocol=PPM;
moduleData[1].protocol=OFF; moduleData[1].protocol=OFF;
} }
@ -505,20 +880,17 @@ void ModelData::clear()
phaseData[i].clear(); phaseData[i].clear();
clearInputs(); clearInputs();
clearMixes(); 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++) for (int i=0; i<C9X_NUM_CHNOUT; i++)
limitData[i].clear(); limitData[i].clear();
for (int i=0; i<NUM_STICKS; i++) for (int i=0; i<NUM_STICKS; i++)
expoData[i].clear(); expoData[i].clear();
for (int i=0; i<C9X_NUM_CSW; i++) for (int i=0; i<C9X_NUM_CSW; i++)
customSw[i].clear(); 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); curves[i].clear(5);
} for (int i=0; i<2; i++)
timers[i].clear();
swashRingData.clear(); swashRingData.clear();
frsky.clear(); frsky.clear();

View file

@ -72,7 +72,6 @@ const uint8_t modn12x3[4][4]= {
#define C9X_MAX_POINTS 17 #define C9X_MAX_POINTS 17
#define C9X_MAX_GVARS 9 #define C9X_MAX_GVARS 9
#define C9X_MAX_ENCODERS 2 #define C9X_MAX_ENCODERS 2
#define NUM_SAFETY_CHNOUT 16
#define C9X_NUM_CHNOUT 32 // number of real output channels #define C9X_NUM_CHNOUT 32 // number of real output channels
#define C9X_NUM_CSW 32 // number of custom switches #define C9X_NUM_CSW 32 // number of custom switches
#define C9X_MAX_CUSTOM_FUNCTIONS 32 // number of functions assigned to switches #define C9X_MAX_CUSTOM_FUNCTIONS 32 // number of functions assigned to switches
@ -147,44 +146,6 @@ enum EnumKeys {
#endif #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 " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-."
#define CHAR_FOR_NAMES_REGEX "[ A-Za-z0-9_.-,]*" #define CHAR_FOR_NAMES_REGEX "[ A-Za-z0-9_.-,]*"
@ -357,13 +318,11 @@ enum RawSwitchType {
SWITCH_TYPE_SWITCH, SWITCH_TYPE_SWITCH,
SWITCH_TYPE_VIRTUAL, SWITCH_TYPE_VIRTUAL,
SWITCH_TYPE_MULTIPOS_POT, SWITCH_TYPE_MULTIPOS_POT,
SWITCH_TYPE_MOMENT_SWITCH, SWITCH_TYPE_TRIM,
SWITCH_TYPE_MOMENT_VIRTUAL, SWITCH_TYPE_ROTARY_ENCODER,
SWITCH_TYPE_ON, SWITCH_TYPE_ON,
SWITCH_TYPE_OFF, SWITCH_TYPE_OFF,
SWITCH_TYPE_ONM, SWITCH_TYPE_TIMER_MODE
SWITCH_TYPE_TRN,
SWITCH_TYPE_REA,
}; };
class RawSwitch { class RawSwitch {
@ -617,30 +576,63 @@ class MixData {
void clear() { memset(this, 0, sizeof(MixData)); } void clear() { memset(this, 0, sizeof(MixData)); }
}; };
class CustomSwData { // Custom Switches data enum CSFunction {
public: CS_FN_OFF,
CustomSwData() { clear(); } CS_FN_VPOS,
int val1; //input CS_FN_VNEG,
int val2; //offset CS_FN_APOS,
unsigned int func; CS_FN_ANEG,
unsigned int delay; CS_FN_AND,
unsigned int duration; CS_FN_OR,
unsigned int andsw; CS_FN_XOR,
void clear() { memset(this, 0, sizeof(CustomSwData)); } 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 enum CSFunctionFamily {
public: CS_FAMILY_VOFS,
SafetySwData() { clear(); } CS_FAMILY_VBOOL,
RawSwitch swtch; CS_FAMILY_VCOMP,
int val; 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 { enum AssignFunc {
FuncSafetyCh1 = 0, FuncSafetyCh1 = 0,
FuncSafetyCh16 = FuncSafetyCh1+15, FuncSafetyCh32 = FuncSafetyCh1+C9X_NUM_CHNOUT-1,
FuncTrainer, FuncTrainer,
FuncTrainerRUD, FuncTrainerRUD,
FuncTrainerELE, FuncTrainerELE,
@ -666,7 +658,7 @@ enum AssignFunc {
class FuncSwData { // Function Switches data class FuncSwData { // Function Switches data
public: public:
FuncSwData() { clear(); } FuncSwData(AssignFunc func=FuncSafetyCh1) { clear(); this->func = func; }
RawSwitch swtch; RawSwitch swtch;
AssignFunc func; AssignFunc func;
int param; int param;
@ -675,6 +667,10 @@ class FuncSwData { // Function Switches data
unsigned int adjustMode; unsigned int adjustMode;
int repeatParam; int repeatParam;
void clear() { memset(this, 0, sizeof(FuncSwData)); } void clear() { memset(this, 0, sizeof(FuncSwData)); }
QString funcToString();
QString paramToString();
QString repeatToString();
QStringList toStringList();
}; };
class PhaseData { class PhaseData {
@ -809,32 +805,17 @@ class MavlinkData {
void clear() { memset(this, 0, sizeof(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 { class TimerData {
public: public:
TimerData() { clear(); } TimerData() { clear(); }
TimerMode mode; // timer trigger source -> off, abs, THs, TH%, THt, sw/!sw, !m_sw/!m_sw RawSwitch mode;
bool minuteBeep; bool minuteBeep;
unsigned int countdownBeep; unsigned int countdownBeep;
bool dir; // 0=>Count Down, 1=>Count Up bool dir; // 0=>Count Down, 1=>Count Up
unsigned int val; unsigned int val;
bool persistent; bool persistent;
int pvalue; 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 { enum Protocol {
@ -897,11 +878,9 @@ class ModelData {
CurveData curves[C9X_MAX_CURVES]; CurveData curves[C9X_MAX_CURVES];
CustomSwData customSw[C9X_NUM_CSW]; CustomSwData customSw[C9X_NUM_CSW];
FuncSwData funcSw[C9X_MAX_CUSTOM_FUNCTIONS]; FuncSwData funcSw[C9X_MAX_CUSTOM_FUNCTIONS];
SafetySwData safetySw[C9X_NUM_CHNOUT];
SwashRingData swashRingData; SwashRingData swashRingData;
unsigned int thrTraceSrc; unsigned int thrTraceSrc;
int8_t traineron; // 0 disable trainer, 1 allow trainer int8_t traineron; // 0 disable trainer, 1 allow trainer
int8_t t2throttle; // Start timer2 using throttle
unsigned int modelId; unsigned int modelId;
unsigned int switchWarningStates; unsigned int switchWarningStates;
// TODO structure // TODO structure
@ -1100,10 +1079,6 @@ class EEPROMInterface
virtual int isAvailable(Protocol proto, int port=0) = 0; 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 SimulatorInterface * getSimulator() = 0;
virtual const int getEEpromSize() = 0; virtual const int getEEpromSize() = 0;
@ -1185,7 +1160,7 @@ inline void applyStickModeToModel(ModelData &model, unsigned int mode)
// virtual switches // virtual switches
for (int i=0; i<C9X_NUM_CSW; i++) { for (int i=0; i<C9X_NUM_CSW; i++) {
RawSource source; RawSource source;
switch (getCSFunctionFamily(model.customSw[i].func)) { switch (model.customSw[i].getFunctionFamily()) {
case CS_FAMILY_VCOMP: case CS_FAMILY_VCOMP:
source = RawSource(model.customSw[i].val2); source = RawSource(model.customSw[i].val2);
if (source.type == SOURCE_TYPE_STICK) if (source.type == SOURCE_TYPE_STICK)

View file

@ -17,9 +17,9 @@ RawSwitch er9xToSwitch(int8_t sw)
else if (sw == -22) else if (sw == -22)
return RawSwitch(SWITCH_TYPE_OFF); return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 22+9) 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 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() t_Er9xTrainerMix::t_Er9xTrainerMix()
@ -298,14 +298,6 @@ t_Er9xSafetySwData::t_Er9xSafetySwData()
memset(this, 0, sizeof(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() t_Er9xFrSkyChannelData::t_Er9xFrSkyChannelData()
{ {
memset(this, 0, sizeof(t_Er9xFrSkyChannelData)); memset(this, 0, sizeof(t_Er9xFrSkyChannelData));
@ -343,10 +335,11 @@ t_Er9xFrSkyData::operator FrSkyData ()
return c9x; return c9x;
} }
TimerMode getEr9xTimerMode(int mode) RawSwitch getEr9xTimerMode(int mode)
{ {
/*
if (mode <= -33) if (mode <= -33)
return TimerMode(TMRMODE_FIRST_NEG_MOMENT_SWITCH+(mode+33)); return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+33));
else if (mode <= -1) else if (mode <= -1)
return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1)); return TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 16) else if (mode < 16)
@ -354,7 +347,9 @@ TimerMode getEr9xTimerMode(int mode)
else if (mode < 16+21) else if (mode < 16+21)
return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16)); return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16));
else else
return TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-16-21)); return TimerMode(TMRMODE_FIRST_SWITCH+(mode-16-21));
*/
return RawSwitch();
} }
t_Er9xModelData::operator ModelData () t_Er9xModelData::operator ModelData ()
@ -381,7 +376,7 @@ t_Er9xModelData::operator ModelData ()
break; break;
} }
c9x.traineron= traineron; c9x.traineron= traineron;
c9x.t2throttle = t2throttle; // c9x.t2throttle = t2throttle;
c9x.moduleData[0].ppmFrameLength=ppmFrameLength; c9x.moduleData[0].ppmFrameLength=ppmFrameLength;
c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH; c9x.moduleData[0].channelsCount = 8 + 2 * ppmNCH;
c9x.thrTrim = thrTrim; c9x.thrTrim = thrTrim;
@ -471,8 +466,8 @@ t_Er9xModelData::operator ModelData ()
for (int i=0; i<ER9X_NUM_CSW; i++) for (int i=0; i<ER9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<ER9X_NUM_CHNOUT; i++) // for (int i=0; i<ER9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky; c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto; c9x.frsky.usrProto=FrSkyUsrProto;

View file

@ -168,7 +168,6 @@ PACK(typedef struct t_Er9xSafetySwData { // Custom Switches data
int8_t swtch; int8_t swtch;
int8_t val; int8_t val;
operator SafetySwData();
t_Er9xSafetySwData(); t_Er9xSafetySwData();
}) Er9xSafetySwData; }) Er9xSafetySwData;

View file

@ -75,7 +75,7 @@ inline void applyStickModeToModel(Er9xModelData & model, unsigned int mode)
for (int i=0; i<ER9X_MAX_MIXERS; i++) for (int i=0; i<ER9X_MAX_MIXERS; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode); model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ER9X_NUM_CSW; i++) { 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: case CS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode); model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break // no break

View file

@ -5,14 +5,12 @@
extern RawSwitch er9xToSwitch(int8_t sw); extern RawSwitch er9xToSwitch(int8_t sw);
TimerMode getErSky9xTimerMode(int mode) RawSwitch getErSky9xTimerMode(int mode)
{ {
if (mode<4) if (mode<4)
return TimerMode(mode); return RawSwitch(SWITCH_TYPE_TIMER_MODE, mode);
else if (mode < 20)
return TimerMode(TMRMODE_FIRST_CHPERC+(mode-4));
else else
return TimerMode(0); return RawSwitch();
} }
RawSwitch ersky9xToSwitch(int8_t sw) RawSwitch ersky9xToSwitch(int8_t sw)
@ -29,9 +27,9 @@ RawSwitch ersky9xToSwitch(int8_t sw)
else if (sw == -34) else if (sw == -34)
return RawSwitch(SWITCH_TYPE_OFF); return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 34+9) 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 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() t_Ersky9xTrainerMix::t_Ersky9xTrainerMix()
@ -406,27 +404,11 @@ t_Ersky9xSafetySwData_v10::t_Ersky9xSafetySwData_v10()
memset(this, 0, sizeof(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() t_Ersky9xSafetySwData_v11::t_Ersky9xSafetySwData_v11()
{ {
memset(this, 0, sizeof(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() t_Ersky9xFrSkyChannelData_v10::t_Ersky9xFrSkyChannelData_v10()
{ {
memset(this, 0, sizeof(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++) for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V10; i++) // for (int i=0; i<ERSKY9X_NUM_CHNOUT_V10; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky; c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto; c9x.frsky.usrProto=FrSkyUsrProto;
@ -733,8 +715,8 @@ t_Ersky9xModelData_v11::operator ModelData ()
for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++) for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++) // for (int i=0; i<ERSKY9X_NUM_CHNOUT_V11; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.frsky = frsky; c9x.frsky = frsky;
c9x.frsky.usrProto=FrSkyUsrProto; c9x.frsky.usrProto=FrSkyUsrProto;

View file

@ -19,8 +19,7 @@
#include <inttypes.h> #include <inttypes.h>
#include "eeprominterface.h" #include "eeprominterface.h"
extern TimerMode getEr9xTimerMode(int mode); extern RawSwitch getEr9xTimerMode(int mode);
extern int setEr9xTimerMode(TimerMode mode);
//eeprom data //eeprom data
#define ERSKY9X_MAX_MIXERS_V10 32 #define ERSKY9X_MAX_MIXERS_V10 32
@ -210,7 +209,6 @@ PACK(typedef struct t_Ersky9xSafetySwData_v10 { // Custom Switches data
int8_t swtch; int8_t swtch;
int8_t val; int8_t val;
operator SafetySwData();
t_Ersky9xSafetySwData_v10(); t_Ersky9xSafetySwData_v10();
}) Ersky9xSafetySwData_v10; }) Ersky9xSafetySwData_v10;
@ -230,7 +228,6 @@ PACK(typedef struct t_Ersky9xSafetySwData_v11 { // Custom Switches data
} vs ; } vs ;
} opt ; } opt ;
operator SafetySwData();
t_Ersky9xSafetySwData_v11(); t_Ersky9xSafetySwData_v11();
}) Ersky9xSafetySwData_v11; }) Ersky9xSafetySwData_v11;

View file

@ -74,7 +74,7 @@ inline void applyStickModeToModel(Ersky9xModelData_v10 & model, unsigned int mod
for (int i=0; i<ERSKY9X_MAX_MIXERS_V10; i++) for (int i=0; i<ERSKY9X_MAX_MIXERS_V10; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode); model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ERSKY9X_NUM_CSW_V10; i++) { 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: case CS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode); model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break // 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++) for (int i=0; i<ERSKY9X_MAX_MIXERS_V11; i++)
model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode); model.mixData[i].srcRaw = applyStickMode(model.mixData[i].srcRaw, mode);
for (int i=0; i<ERSKY9X_NUM_CSW_V11; i++) { 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: case CS_FAMILY_VCOMP:
model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode); model.customSw[i].v2 = applyStickMode(model.customSw[i].v2, mode);
// no break // no break

View file

@ -332,14 +332,6 @@ Gruvin9xFuncSwData::operator FuncSwData ()
return c9x; return c9x;
} }
t_Gruvin9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = gruvin9xToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Gruvin9xSwashRingData::t_Gruvin9xSwashRingData() t_Gruvin9xSwashRingData::t_Gruvin9xSwashRingData()
{ {
memset(this, 0, sizeof(t_Gruvin9xSwashRingData)); memset(this, 0, sizeof(t_Gruvin9xSwashRingData));
@ -381,7 +373,7 @@ t_Gruvin9xPhaseData_v106::operator PhaseData ()
return c9x; return c9x;
} }
extern TimerMode getEr9xTimerMode(int mode); extern RawSwitch getEr9xTimerMode(int mode);
t_Gruvin9xTimerData::operator TimerData () t_Gruvin9xTimerData::operator TimerData ()
{ {
@ -489,8 +481,8 @@ t_Gruvin9xModelData_v102::operator ModelData ()
for (int i=0; i<G9X_NUM_CSW; i++) for (int i=0; i<G9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++) // for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
return c9x; return c9x;
@ -560,8 +552,8 @@ t_Gruvin9xModelData_v103::operator ModelData ()
for (int i=0; i<G9X_NUM_CSW; i++) for (int i=0; i<G9X_NUM_CSW; i++)
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++) // for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
return c9x; return c9x;
@ -650,8 +642,8 @@ t_Gruvin9xModelData_v105::operator ModelData ()
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_FSW; i++) for (int i=0; i<G9X_NUM_FSW; i++)
c9x.funcSw[i] = funcSw[i]; c9x.funcSw[i] = funcSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++) // for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
@ -734,8 +726,8 @@ t_Gruvin9xModelData_v106::operator ModelData ()
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<G9X_NUM_FSW; i++) for (int i=0; i<G9X_NUM_FSW; i++)
c9x.funcSw[i] = funcSw[i]; c9x.funcSw[i] = funcSw[i];
for (int i=0; i<G9X_NUM_CHNOUT; i++) // for (int i=0; i<G9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;

View file

@ -199,7 +199,6 @@ PACK(typedef struct t_Gruvin9xSafetySwData { // Safety Switches data
int8_t swtch; int8_t swtch;
int8_t val; int8_t val;
operator SafetySwData();
t_Gruvin9xSafetySwData() { memset(this, 0, sizeof(t_Gruvin9xSafetySwData)); } t_Gruvin9xSafetySwData() { memset(this, 0, sizeof(t_Gruvin9xSafetySwData)); }
}) Gruvin9xSafetySwData; }) Gruvin9xSafetySwData;

View file

@ -19,13 +19,13 @@ RawSwitch open9xArmToSwitch(int8_t sw)
else if (sw == 42) else if (sw == 42)
return RawSwitch(SWITCH_TYPE_ON); return RawSwitch(SWITCH_TYPE_ON);
else if (sw == 84) else if (sw == 84)
return RawSwitch(SWITCH_TYPE_ONM); return RawSwitch(SWITCH_TYPE_ON);
else if (sw == -42) else if (sw == -42)
return RawSwitch(SWITCH_TYPE_OFF); return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 42+9) 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 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) RawSource open9xArm208ToSource(int8_t value)
@ -124,9 +124,9 @@ RawSource open9xArm210ToSource(int8_t value)
t_Open9xArmTimerData_v202::operator TimerData () t_Open9xArmTimerData_v202::operator TimerData ()
{ {
TimerData c9x; TimerData c9x;
/*
if (mode <= -42) 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) else if (mode <= -1)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1)); c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 5) else if (mode < 5)
@ -134,8 +134,8 @@ t_Open9xArmTimerData_v202::operator TimerData ()
else if (mode < 5+41) else if (mode < 5+41)
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5)); c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
else else
c9x.mode = TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-5-21)); c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
*/
c9x.val = val; c9x.val = val;
c9x.persistent = false; c9x.persistent = false;
c9x.dir = (val == 0); c9x.dir = (val == 0);
@ -577,7 +577,7 @@ t_Open9xArmFuncSwData_v208::operator FuncSwData ()
FuncSwData c9x; FuncSwData c9x;
c9x.swtch = open9xArmToSwitch(swtch); c9x.swtch = open9xArmToSwitch(swtch);
c9x.func = (AssignFunc)(func); c9x.func = (AssignFunc)(func);
if (c9x.func <= FuncSafetyCh16) { if (c9x.func <= FuncSafetyCh32) {
c9x.enabled=param & 0x01; c9x.enabled=param & 0x01;
c9x.param = (param>>1)<<1; c9x.param = (param>>1)<<1;
} }

View file

@ -74,13 +74,13 @@ RawSwitch open9xStockToSwitch(int8_t sw)
else if (sw == 22) else if (sw == 22)
return RawSwitch(SWITCH_TYPE_ON); return RawSwitch(SWITCH_TYPE_ON);
else if (sw == 44) else if (sw == 44)
return RawSwitch(SWITCH_TYPE_ONM); return RawSwitch(SWITCH_TYPE_ON);
else if (sw == -22) else if (sw == -22)
return RawSwitch(SWITCH_TYPE_OFF); return RawSwitch(SWITCH_TYPE_OFF);
else if (swa <= 22+9) 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 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 () t_Open9xExpoData_v201::operator ExpoData ()
@ -662,14 +662,6 @@ t_Open9xFuncSwData_v210::operator FuncSwData ()
return c9x; return c9x;
} }
t_Open9xSafetySwData::operator SafetySwData ()
{
SafetySwData c9x;
c9x.swtch = open9xStockToSwitch(swtch);
c9x.val = val;
return c9x;
}
t_Open9xSwashRingData_v208::operator SwashRingData () t_Open9xSwashRingData_v208::operator SwashRingData ()
{ {
SwashRingData c9x; SwashRingData c9x;
@ -709,7 +701,7 @@ t_Open9xPhaseData_v201::operator PhaseData ()
t_Open9xTimerData_v201::operator TimerData () t_Open9xTimerData_v201::operator TimerData ()
{ {
TimerData c9x; TimerData c9x;
c9x.mode = TMRMODE_OFF; // c9x.mode = TMRMODE_OFF;
c9x.val = val; c9x.val = val;
c9x.persistent = persistent; c9x.persistent = persistent;
c9x.dir = dir; c9x.dir = dir;
@ -719,9 +711,9 @@ t_Open9xTimerData_v201::operator TimerData ()
t_Open9xTimerData_v202::operator TimerData () t_Open9xTimerData_v202::operator TimerData ()
{ {
TimerData c9x; TimerData c9x;
/*
if (mode <= -22) 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) else if (mode <= -1)
c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1)); c9x.mode = TimerMode(TMRMODE_FIRST_NEG_SWITCH+(mode+1));
else if (mode < 5) else if (mode < 5)
@ -729,8 +721,8 @@ t_Open9xTimerData_v202::operator TimerData ()
else if (mode < 5+21) else if (mode < 5+21)
c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5)); c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5));
else else
c9x.mode = TimerMode(TMRMODE_FIRST_MOMENT_SWITCH+(mode-5-21)); c9x.mode = TimerMode(TMRMODE_FIRST_SWITCH+(mode-5-21));
*/
c9x.val = val; c9x.val = val;
c9x.persistent = false; c9x.persistent = false;
c9x.dir = (val == 0); c9x.dir = (val == 0);
@ -993,8 +985,8 @@ t_Open9xModelData_v201::operator ModelData ()
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<12; i++) for (int i=0; i<12; i++)
c9x.funcSw[i] = funcSw[i]; c9x.funcSw[i] = funcSw[i];
for (int i=0; i<O9X_NUM_CHNOUT; i++) // for (int i=0; i<O9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
@ -1067,8 +1059,8 @@ t_Open9xModelData_v202::operator ModelData ()
c9x.customSw[i] = customSw[i]; c9x.customSw[i] = customSw[i];
for (int i=0; i<12; i++) for (int i=0; i<12; i++)
c9x.funcSw[i] = funcSw[i]; c9x.funcSw[i] = funcSw[i];
for (int i=0; i<O9X_NUM_CHNOUT; i++) // for (int i=0; i<O9X_NUM_CHNOUT; i++)
c9x.safetySw[i] = safetySw[i]; // c9x.safetySw[i] = safetySw[i];
c9x.swashRingData = swashR; c9x.swashRingData = swashR;
c9x.frsky = frsky; c9x.frsky = frsky;
c9x.moduleData[0].ppmFrameLength = ppmFrameLength; c9x.moduleData[0].ppmFrameLength = ppmFrameLength;

View file

@ -244,7 +244,6 @@ PACK(typedef struct t_Open9xSafetySwData { // Safety Switches data
int8_t swtch; int8_t swtch;
int8_t val; int8_t val;
operator SafetySwData();
t_Open9xSafetySwData() { memset(this, 0, sizeof(t_Open9xSafetySwData)); } t_Open9xSafetySwData() { memset(this, 0, sizeof(t_Open9xSafetySwData)); }
}) Open9xSafetySwData; }) Open9xSafetySwData;

File diff suppressed because it is too large Load diff

View file

@ -64,6 +64,7 @@ class Open9xGeneralDataNew: public TransformedField {
StructField internalField; StructField internalField;
GeneralSettings & generalData; GeneralSettings & generalData;
BoardEnum board; BoardEnum board;
unsigned int version;
int inputsCount; int inputsCount;
unsigned int chkSum; unsigned int chkSum;
}; };

View file

@ -57,19 +57,19 @@ const char * Open9xInterface::getName()
{ {
switch (board) { switch (board) {
case BOARD_STOCK: case BOARD_STOCK:
return "openTx for 9X board"; return "OpenTX for 9X board";
case BOARD_M128: case BOARD_M128:
return "openTx for M128 / 9X board"; return "OpenTX for M128 / 9X board";
case BOARD_GRUVIN9X: case BOARD_GRUVIN9X:
return "openTx for Gruvin9x board / 9X"; return "OpenTX for Gruvin9x board / 9X";
case BOARD_TARANIS: case BOARD_TARANIS:
return "openTx for FrSky Taranis"; return "OpenTX for FrSky Taranis";
case BOARD_TARANIS_REV4a: case BOARD_TARANIS_REV4a:
return "openTx for FrSky Taranis Rev4a"; return "OpenTX for FrSky Taranis Rev4a";
case BOARD_SKY9X: case BOARD_SKY9X:
return "openTx for Sky9x board / 9X"; return "OpenTX for Sky9x board / 9X";
default: 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 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 } }; Option fai_options[] = { { "faichoice", QObject::tr("Possibility to enable FAI MODE at field") }, { "faimode", QObject::tr("FAI MODE always enabled") }, { NULL } };
/* 9x board */ /* 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->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1051,7 +1051,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9x board with M128 chip */ /* 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->addOptions(ext_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1083,7 +1083,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9XR board */ /* 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->addOptions(extr_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1117,7 +1117,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* 9XR board with M128 chip */ /* 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->addOptions(extr_options);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1147,7 +1147,7 @@ void RegisterOpen9xFirmwares()
firmwares.push_back(open9x); firmwares.push_back(open9x);
/* Gruvin9x board */ /* 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->setVariantBase(FRSKY_VARIANT);
open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1177,7 +1177,7 @@ void RegisterOpen9xFirmwares()
#ifndef __APPLE__ #ifndef __APPLE__
/* SKY9X board */ /* 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->setVariantBase(FRSKY_VARIANT);
open9x->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support")); open9x->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu")); open9x->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
@ -1202,7 +1202,7 @@ void RegisterOpen9xFirmwares()
#endif #endif
/* Taranis board */ /* 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("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu"));
open9x->addOption("nogvars", QObject::tr("Disable Global variables")); open9x->addOption("nogvars", QObject::tr("Disable Global variables"));
@ -1214,7 +1214,7 @@ void RegisterOpen9xFirmwares()
QSettings settings; QSettings settings;
int rev4a = settings.value("rev4asupport",0).toInt(); int rev4a = settings.value("rev4asupport",0).toInt();
if (rev4a) { 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("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu")); open9x->addOption("notemplates", QObject::tr("Disable TEMPLATES menu"));
open9x->addOption("nogvars", QObject::tr("Disable Global variables")); open9x->addOption("nogvars", QObject::tr("Disable Global variables"));

View file

@ -2,18 +2,6 @@
#include "helpers.h" #include "helpers.h"
#include "th9xeeprom.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) RawSwitch th9xToSwitch(int8_t sw)
{ {
if (sw == 0) if (sw == 0)
@ -266,7 +254,7 @@ t_Th9xModelData::operator ModelData ()
ModelData c9x; ModelData c9x;
c9x.used = true; c9x.used = true;
getEEPROMString(c9x.name, name, sizeof(name)); getEEPROMString(c9x.name, name, sizeof(name));
switch(tmrMode) { /*switch(tmrMode) {
case 1: case 1:
c9x.timers[0].mode = TMRMODE_ABS; c9x.timers[0].mode = TMRMODE_ABS;
break; break;
@ -279,7 +267,7 @@ t_Th9xModelData::operator ModelData ()
default: default:
c9x.timers[0].mode = TMRMODE_OFF; c9x.timers[0].mode = TMRMODE_OFF;
break; break;
} }*/
// c9x.timers[0].dir = tmrDir; // c9x.timers[0].dir = tmrDir;
c9x.timers[0].val = tmrVal; c9x.timers[0].val = tmrVal;
/*c9x.protocol = (Protocol)protocol; /*c9x.protocol = (Protocol)protocol;

View file

@ -117,165 +117,6 @@ void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last=fal
b->setMaxVisibleItems(10); b->setMaxVisibleItems(10);
} }
QString getRepeatString(unsigned int val)
{
if (val==0) {
return QObject::tr("No repeat");
} else {
unsigned int step = IS_ARM(GetEepromInterface()->getBoard()) ? 5 : 10;
return QObject::tr("%1 sec").arg(step*val);
}
}
QString getFuncName(unsigned int val)
{
if (val < NUM_SAFETY_CHNOUT) {
return QObject::tr("Safety %1").arg(RawSource(SOURCE_TYPE_CH, val).toString());
}
else if (val == FuncTrainer)
return QObject::tr("Trainer");
else if (val == FuncTrainerRUD)
return QObject::tr("Trainer RUD");
else if (val == FuncTrainerELE)
return QObject::tr("Trainer ELE");
else if (val == FuncTrainerTHR)
return QObject::tr("Trainer THR");
else if (val == FuncTrainerAIL)
return QObject::tr("Trainer AIL");
else if (val == FuncInstantTrim)
return QObject::tr("Instant Trim");
else if (val == FuncPlaySound)
return QObject::tr("Play Sound");
else if (val == FuncPlayHaptic)
return QObject::tr("Play Haptic");
else if (val == FuncReset)
return QObject::tr("Reset");
else if (val == FuncVario)
return QObject::tr("Vario");
else if (val == FuncPlayPrompt)
return QObject::tr("Play Track");
else if (val == FuncPlayBoth)
return QObject::tr("Play Both");
else if (val == FuncPlayValue)
return QObject::tr("Play Value");
else if (val == FuncLogs)
return QObject::tr("Start Logs");
else if (val == FuncVolume)
return QObject::tr("Volume");
else if (val == FuncBacklight)
return QObject::tr("Backlight");
else if (val == FuncBackgroundMusic)
return QObject::tr("Background Music");
else if (val == FuncBackgroundMusicPause)
return QObject::tr("Background Music Pause");
else if (val >= FuncAdjustGV1 && val <= FuncAdjustGVLast)
return QObject::tr("Adjust GV%1").arg(val-FuncAdjustGV1+1);
else {
return QString("???"); // Highlight unknown functions with output of question marks.(BTW should not happen that we do not know what a function is)
}
}
// TODO should be a toString() method in CustoSwData ...
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model)
{
QString result = "";
if (!customSw->func)
return result;
if (customSw->andsw!=0) {
result +="( ";
}
switch (getCSFunctionFamily(customSw->func)) {
case CS_FAMILY_TIMERS:
result = QString("TIM(%1 , %2)").arg(ValToTim(customSw->val1)).arg(ValToTim(customSw->val2));
break;
case CS_FAMILY_VOFS: {
RawSource source = RawSource(customSw->val1, &model);
RawSourceRange range = source.getRange();
if (customSw->val1)
result += source.toString();
else
result += "0";
result.remove(" ");
if (customSw->func == CS_FN_APOS || customSw->func == CS_FN_ANEG)
result = "|" + result + "|";
else if (customSw->func == CS_FN_DAPOS)
result = "|d(" + result + ")|";
else if (customSw->func == CS_FN_DPOS) result = "d(" + result + ")";
if (customSw->func == CS_FN_APOS || customSw->func == CS_FN_VPOS || customSw->func == CS_FN_DAPOS || customSw->func == CS_FN_DPOS)
result += " &gt; ";
else if (customSw->func == CS_FN_ANEG || customSw->func == CS_FN_VNEG)
result += " &lt; ";
result += QString::number(range.step * (customSw->val2 /*TODO+ source.getRawOffset(model)*/) + range.offset);
break;
}
case CS_FAMILY_VBOOL:
result = RawSwitch(customSw->val1).toString();
switch (customSw->func) {
case CS_FN_AND:
result += " AND ";
break;
case CS_FN_OR:
result += " OR ";
break;
case CS_FN_XOR:
result += " XOR ";
break;
default:
break;
}
result += RawSwitch(customSw->val2).toString();
break;
case CS_FAMILY_VCOMP:
if (customSw->val1)
result += RawSource(customSw->val1).toString();
else
result += "0";
switch (customSw->func) {
case CS_FN_EQUAL:
result += " = ";
break;
case CS_FN_NEQUAL:
result += " != ";
break;
case CS_FN_GREATER:
result += " &gt; ";
break;
case CS_FN_LESS:
result += " &lt; ";
break;
case CS_FN_EGREATER:
result += " &gt;= ";
break;
case CS_FN_ELESS:
result += " &lt;= ";
break;
default:
break;
}
if (customSw->val2)
result += RawSource(customSw->val2).toString();
else
result += "0";
break;
}
if (customSw->andsw!=0) {
result +=" ) AND ";
result += RawSwitch(customSw->andsw).toString();
}
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
if (customSw->delay)
result += QObject::tr(" Delay %1 sec").arg(customSw->delay/2.0);
if (customSw->duration)
result += QObject::tr(" Duration %1 sec").arg(customSw->duration/2.0);
}
return result;
}
QString getProtocolStr(const int proto) QString getProtocolStr(const int proto)
{ {
static const char *strings[] = { "OFF", static const char *strings[] = { "OFF",
@ -290,186 +131,6 @@ QString getProtocolStr(const int proto)
return CHECK_IN_ARRAY(strings, 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) void populatePhasesCB(QComboBox *b, int value)
{ {
for (int i=-GetEepromInterface()->getCapability(FlightPhases); i<=GetEepromInterface()->getCapability(FlightPhases); i++) { 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) 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 }; 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; RawSwitch item;
b->clear(); 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) { if (attr & POPULATE_ONOFF) {
item = RawSwitch(SWITCH_TYPE_OFF); item = RawSwitch(SWITCH_TYPE_OFF);
if (GetEepromInterface()->isAvailable(item, context)) { b->addItem(item.toString(), item.toValue());
b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1);
if (item == value) b->setCurrentIndex(b->count()-1);
}
} }
for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) { for (int i=-GetEepromInterface()->getCapability(CustomSwitches); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_VIRTUAL, i); item = RawSwitch(SWITCH_TYPE_VIRTUAL, i);
if (GetEepromInterface()->isAvailable(item, context)) { b->addItem(item.toString(), item.toValue());
b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1);
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++) { for (int i=-GetEepromInterface()->getCapability(SwitchesPositions); i<0; i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, 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()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);
} }
} }
else {
item = RawSwitch(SWITCH_TYPE_NONE); item = RawSwitch(SWITCH_TYPE_NONE);
if (GetEepromInterface()->isAvailable(item, context)) {
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); if (item == value) b->setCurrentIndex(b->count()-1);
} }
for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) { for (int i=1; i<=GetEepromInterface()->getCapability(SwitchesPositions); i++) {
item = RawSwitch(SWITCH_TYPE_SWITCH, i); item = RawSwitch(SWITCH_TYPE_SWITCH, i);
if (GetEepromInterface()->isAvailable(item, context)) { b->addItem(item.toString(), item.toValue());
b->addItem(item.toString(), item.toValue()); if (item == value) b->setCurrentIndex(b->count()-1);
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++) { 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 (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) { if (attr & POPULATE_ONOFF) {
item = RawSwitch(SWITCH_TYPE_ON); item = RawSwitch(SWITCH_TYPE_ON);
b->addItem(item.toString(), item.toValue()); b->addItem(item.toString(), item.toValue());
if (item == value) b->setCurrentIndex(b->count()-1); 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); b->setMaxVisibleItems(10);
} }
@ -1104,35 +635,6 @@ void populateSourceCB(QComboBox *b, const RawSource & source, const ModelData &
b->setMaxVisibleItems(10); 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) float ValToTim(int value)
{ {
return ((value < -109 ? 129+value : (value < 7 ? (113+value)*5 : (53+value)*10))/10.0); 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) 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(); b->clear();
for (int i = 0; i < CSW_NUM_FUNC; i++) { for (int i=0; i<CS_FN_MAX; i++) {
b->addItem(getCSWFunc(i),csw_values[i]); int func = order[i];
if (i>GetEepromInterface()->getCapability(CSFunc)) { b->addItem(CustomSwData(func).funcToString(), func);
QModelIndex index = b->model()->index(i, 0); // if (i>GetEepromInterface()->getCapability(CSFunc)) {
QVariant v(0); // QModelIndex index = b->model()->index(i, 0);
} // QVariant v(0);
if (value == csw_values[i]) { // }
if (value == func) {
b->setCurrentIndex(b->count()-1); b->setCurrentIndex(b->count()-1);
} }
} }
@ -1328,7 +855,7 @@ QString getTrimInc(ModelData * g_model)
QString getTimerStr(TimerData & timer) QString getTimerStr(TimerData & timer)
{ {
QString str = ", " + (timer.dir ? QObject::tr("Count Up") : QObject::tr("Count Down")); 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) 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) QString getCenterBeep(ModelData * g_model)
{ {
//RETA123 //RETA123

View file

@ -82,19 +82,13 @@ class CurveGroup : public QObject {
}; };
#define POPULATE_ONOFF 0x01 #define POPULATE_ONOFF 0x01
#define POPULATE_MSWITCHES 0x02 #define POPULATE_TIMER_MODES 0x02
#define POPULATE_AND_SWITCHES 0x04 void populateAndSwitchCB(QComboBox *b, const RawSwitch & value);
void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0, UseContext context=DefaultContext); void populateSwitchCB(QComboBox *b, const RawSwitch & value, unsigned long attr=0);
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);
void populatePhasesCB(QComboBox *b, int value); void populatePhasesCB(QComboBox *b, int value);
void populateGvarUseCB(QComboBox *b, unsigned int phase); void populateGvarUseCB(QComboBox *b, unsigned int phase);
void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto); void populateCustomScreenFieldCB(QComboBox *b, unsigned int value, bool last, int hubproto);
void populateTimerSwitchCB(QComboBox *b, int value);
QString getCustomSwitchStr(CustomSwData * customSw, const ModelData & model);
QString getProtocolStr(const int proto); QString getProtocolStr(const int proto);
QString getPhasesStr(unsigned int phases, ModelData & model); 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 populateGVCB(QComboBox *b, int value);
void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags); void populateSourceCB(QComboBox *b, const RawSource &source, const ModelData & model, unsigned int flags);
void populateCSWCB(QComboBox *b, int value); void populateCSWCB(QComboBox *b, int value);
QString getTimerMode(int tm);
QString getTimerModeB(int tm);
QString getPhaseName(int val, char * phasename=NULL); QString getPhaseName(int val, char * phasename=NULL);
QString getInputStr(ModelData & model, int index); 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 getSignedStr(int value);
QString getGVarString(int16_t val, bool sign=false); QString getGVarString(int16_t val, bool sign=false);
QString image2qstring(QImage image); QString image2qstring(QImage image);
@ -139,7 +128,6 @@ QString getFrSkyProtocol(int protocol);
QString getFrSkyMeasure(int units); QString getFrSkyMeasure(int units);
QString getFrSkySrc(int index); QString getFrSkySrc(int index);
float c9xexpou(float point, float coeff);
float ValToTim(int value); float ValToTim(int value);
int TimToVal(float value); int TimToVal(float value);

View file

@ -495,6 +495,13 @@ void ModelEdit::on_ca_ctype_CB_currentIndexChanged()
} }
} }
float c9xexpou(float point, float coeff)
{
float x=point*1024.0/100.0;
float k=coeff*256.0/100.0;
return ((k*x*x*x/(1024*1024) + x*(256-k) + 128) / 256)/1024.0*100;
}
void ModelEdit::on_ca_apply_PB_clicked() void ModelEdit::on_ca_apply_PB_clicked()
{ {
int index=ui->ca_ctype_CB->currentIndex(); int index=ui->ca_ctype_CB->currentIndex();

View file

@ -36,6 +36,16 @@ void RepeatComboBox::onIndexChanged(int index)
emit modified(); 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): CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings):
ModelPanel(parent, model), ModelPanel(parent, model),
generalSettings(generalSettings), generalSettings(generalSettings),
@ -52,7 +62,6 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
lock = true; lock = true;
int num_fsw = GetEepromInterface()->getCapability(CustomFunctions); int num_fsw = GetEepromInterface()->getCapability(CustomFunctions);
QStringList paramarmList;
if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) { if (!GetEepromInterface()->getCapability(VoicesAsNumbers)) {
for (int i=0; i<num_fsw; i++) { for (int i=0; i<num_fsw; i++) {
if (model.funcSw[i].func==FuncPlayPrompt || model.funcSw[i].func==FuncBackgroundMusic) { 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++) { for (int i=0; i<num_fsw; i++) {
AssignFunc func = model.funcSw[i].func; 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 // The switch
fswtchSwtch[i] = new QComboBox(this); fswtchSwtch[i] = new QComboBox(this);
fswtchSwtch[i]->setProperty("index", i); fswtchSwtch[i]->setProperty("index", i);
connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited())); connect(fswtchSwtch[i], SIGNAL(currentIndexChanged(int)), this, SLOT(customFunctionEdited()));
gridLayout->addWidget(fswtchSwtch[i], i+1, 1); gridLayout->addWidget(fswtchSwtch[i], i+1, 1);
populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_MSWITCHES|POPULATE_ONOFF); populateSwitchCB(fswtchSwtch[i], model.funcSw[i].swtch, POPULATE_ONOFF);
// The function // The function
fswtchFunc[i] = new QComboBox(this); fswtchFunc[i] = new QComboBox(this);
@ -135,7 +153,7 @@ CustomFunctionsPanel::CustomFunctionsPanel(QWidget * parent, ModelData & model,
fswtchParamArmT[i] = new QComboBox(this); fswtchParamArmT[i] = new QComboBox(this);
fswtchParamArmT[i]->setProperty("index", i); 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); fswtchParamArmT[i]->setEditable(true);
paramLayout->addWidget(fswtchParamArmT[i]); paramLayout->addWidget(fswtchParamArmT[i]);
@ -286,7 +304,7 @@ void CustomFunctionsPanel::refreshCustomFunction(int i, bool modified)
int index = fswtchFunc[i]->currentIndex(); int index = fswtchFunc[i]->currentIndex();
if (index>=FuncSafetyCh1 && index<=FuncSafetyCh16) { if (index>=FuncSafetyCh1 && index<=FuncSafetyCh32) {
fswtchParam[i]->setDecimals(0); fswtchParam[i]->setDecimals(0);
fswtchParam[i]->setSingleStep(1); fswtchParam[i]->setSingleStep(1);
fswtchParam[i]->setMinimum(-125); 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) { else if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) {
if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) { if (index != FuncBackgroundMusic && GetEepromInterface()->getCapability(HasFuncRepeat)) {
widgetsMask |= CUSTOM_FUNCTION_REPEAT; widgetsMask |= CUSTOM_FUNCTION_REPEAT;
fswtchRepeat[i]->update();
} }
if (index==FuncPlayValue) { if (index==FuncPlayValue) {
if (modified) model.funcSw[i].param = fswtchParamT[i]->itemData(fswtchParamT[i]->currentIndex()).toInt(); 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; widgetsMask |= CUSTOM_FUNCTION_FILE_PARAM;
if (modified) { if (modified) {
memset(model.funcSw[i].paramarm, 0, sizeof(model.funcSw[i].paramarm)); 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() != "----") { if (fswtchParamArmT[i]->currentText() != "----") {
widgetsMask |= CUSTOM_FUNCTION_PLAY; 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); 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) { else if (index==FuncBackgroundMusic) {
@ -453,13 +478,13 @@ void CustomFunctionsPanel::fswPaste()
const QMimeData *mimeData = clipboard->mimeData(); const QMimeData *mimeData = clipboard->mimeData();
if (mimeData->hasFormat("application/x-companion-fsw")) { if (mimeData->hasFormat("application/x-companion-fsw")) {
QByteArray fswData = mimeData->data("application/x-companion-fsw"); QByteArray fswData = mimeData->data("application/x-companion-fsw");
FuncSwData *fsw = &model.funcSw[selectedFunction]; FuncSwData *fsw = &model.funcSw[selectedFunction];
memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData)); memcpy(fsw, fswData.mid(0, sizeof(FuncSwData)).constData(), sizeof(FuncSwData));
// TODO update switch and func lock = true;
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); populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction); refreshCustomFunction(selectedFunction);
lock = false;
emit modified(); emit modified();
} }
} }
@ -468,7 +493,7 @@ void CustomFunctionsPanel::fswDelete()
{ {
model.funcSw[selectedFunction].clear(); model.funcSw[selectedFunction].clear();
// TODO update switch and func // 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); populateFuncCB(fswtchFunc[selectedFunction], model.funcSw[selectedFunction].func);
refreshCustomFunction(selectedFunction); refreshCustomFunction(selectedFunction);
emit modified(); emit modified();
@ -476,17 +501,17 @@ void CustomFunctionsPanel::fswDelete()
void CustomFunctionsPanel::fswCopy() void CustomFunctionsPanel::fswCopy()
{ {
QByteArray fswData; QByteArray fswData;
fswData.append((char*)&model.funcSw[selectedFunction],sizeof(FuncSwData)); fswData.append((char*)&model.funcSw[selectedFunction], sizeof(FuncSwData));
QMimeData *mimeData = new QMimeData; QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-companion-fsw", fswData); mimeData->setData("application/x-companion-fsw", fswData);
QApplication::clipboard()->setMimeData(mimeData,QClipboard::Clipboard); QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard);
} }
void CustomFunctionsPanel::fswCut() void CustomFunctionsPanel::fswCut()
{ {
fswCopy(); fswCopy();
fswDelete(); fswDelete();
} }
void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos) void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
@ -508,3 +533,124 @@ void CustomFunctionsPanel::fsw_customContextMenuRequested(QPoint pos)
contextMenu.exec(globalPos); 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();
}
}

View file

@ -19,6 +19,7 @@ class RepeatComboBox: public QComboBox
public: public:
RepeatComboBox(QWidget *parent, int & repeatParam); RepeatComboBox(QWidget *parent, int & repeatParam);
void update();
signals: signals:
void modified(); void modified();
@ -55,7 +56,13 @@ class CustomFunctionsPanel : public ModelPanel
void fswCut(); void fswCut();
private: 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; GeneralSettings & generalSettings;
QStringList paramarmList;
bool phononLock; bool phononLock;
QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchSwtch[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchFunc[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 * fswtchParamT[C9X_MAX_CUSTOM_FUNCTIONS];
QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS]; QComboBox * fswtchParamArmT[C9X_MAX_CUSTOM_FUNCTIONS];
QCheckBox * fswtchEnable[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]; QComboBox * fswtchGVmode[C9X_MAX_CUSTOM_FUNCTIONS];
#ifdef PHONON #ifdef PHONON
Phonon::MediaObject *clickObject; Phonon::MediaObject *clickObject;

View file

@ -46,7 +46,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// V1 // V1
cswitchSource1[i] = new QComboBox(this); cswitchSource1[i] = new QComboBox(this);
cswitchSource1[i]->setProperty("index",i); 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); gridLayout->addWidget(cswitchSource1[i], i+1, 2);
cswitchSource1[i]->setVisible(false); cswitchSource1[i]->setVisible(false);
cswitchValue[i] = new QDoubleSpinBox(this); cswitchValue[i] = new QDoubleSpinBox(this);
@ -62,7 +62,7 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// V2 // V2
cswitchSource2[i] = new QComboBox(this); cswitchSource2[i] = new QComboBox(this);
cswitchSource2[i]->setProperty("index", i); 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); gridLayout->addWidget(cswitchSource2[i], i+1, 3);
cswitchSource2[i]->setVisible(false); cswitchSource2[i]->setVisible(false);
cswitchOffset[i] = new QDoubleSpinBox(this); cswitchOffset[i] = new QDoubleSpinBox(this);
@ -78,9 +78,8 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
// AND // AND
cswitchAnd[i] = new QComboBox(this); cswitchAnd[i] = new QComboBox(this);
cswitchAnd[i]->setProperty("index", i); 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); gridLayout->addWidget(cswitchAnd[i], i+1, 4);
cswitchAnd[i]->setVisible(false);
if (GetEepromInterface()->getCapability(CustomSwitchesExt)) { if (GetEepromInterface()->getCapability(CustomSwitchesExt)) {
// Duration // Duration
@ -91,9 +90,8 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
cswitchDuration[i]->setMinimum(0); cswitchDuration[i]->setMinimum(0);
cswitchDuration[i]->setAccelerated(true); cswitchDuration[i]->setAccelerated(true);
cswitchDuration[i]->setDecimals(1); 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); gridLayout->addWidget(cswitchDuration[i], i+1, 5);
cswitchDuration[i]->setVisible(false);
// Delay // Delay
cswitchDelay[i] = new QDoubleSpinBox(this); cswitchDelay[i] = new QDoubleSpinBox(this);
@ -103,9 +101,8 @@ CustomSwitchesPanel::CustomSwitchesPanel(QWidget * parent, ModelData & model):
cswitchDelay[i]->setMinimum(0); cswitchDelay[i]->setMinimum(0);
cswitchDelay[i]->setAccelerated(true); cswitchDelay[i]->setAccelerated(true);
cswitchDelay[i]->setDecimals(1); 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); 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() void CustomSwitchesPanel::edited()
{ {
if (!lock) { if (!lock) {
lock = true; lock = true;
int i = sender()->property("index").toInt(); int i = sender()->property("index").toInt();
bool chAr; int newFunc = csw[i]->itemData(csw[i]->currentIndex()).toInt();
float value, step; bool chAr = (model.customSw[i].getFunctionFamily() != CustomSwData(newFunc).getFunctionFamily());
int newval; model.customSw[i].func = newFunc;
chAr = (getCSFunctionFamily(model.customSw[i].func) != getCSFunctionFamily(csw[i]->itemData(csw[i]->currentIndex()).toInt())); if (chAr) {
model.customSw[i].func = csw[i]->itemData(csw[i]->currentIndex()).toInt(); if (model.customSw[i].getFunctionFamily() == CS_FAMILY_TIMER) {
if(chAr) {
if (getCSFunctionFamily(model.customSw[i].func)==CS_FAMILY_TIMERS) {
model.customSw[i].val1 = -119; model.customSw[i].val1 = -119;
model.customSw[i].val2 = -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].val1 = 0;
model.customSw[i].val2 = 0; model.customSw[i].val2 = 0;
} }
model.customSw[i].andsw = 0; model.customSw[i].andsw = 0;
setSwitchWidgetVisibility(i); 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; RawSource source;
switch (getCSFunctionFamily(model.customSw[i].func)) switch (model.customSw[i].getFunctionFamily())
{ {
case (CS_FAMILY_VOFS): 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 {
source = RawSource(model.customSw[i].val1, &model); source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange();
if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) { if (model.customSw[i].func>CS_FN_ELESS && model.customSw[i].func<CS_FN_VEQUAL) {
@ -181,82 +218,48 @@ void CustomSwitchesPanel::edited()
} }
} }
break; break;
case (CS_FAMILY_TIMERS): { case CS_FAMILY_TIMER:
value = cswitchOffset[i]->value(); model.customSw[i].val1 = TimToVal(cswitchValue[i]->value());
newval=TimToVal(value); model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
if (newval>model.customSw[i].val2) { updateTimerParam(cswitchValue[i], model.customSw[i].val1);
if (value >=60) { updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
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);
break; break;
} case CS_FAMILY_STAY:
case (CS_FAMILY_VBOOL): model.customSw[i].val2 = TimToVal(cswitchOffset[i]->value());
case (CS_FAMILY_VCOMP): updateTimerParam(cswitchOffset[i], model.customSw[i].val2, true);
model.customSw[i].val1 = cswitchSource1[i]->itemData(cswitchSource1[i]->currentIndex()).toInt(); break;
model.customSw[i].val2 = cswitchSource2[i]->itemData(cswitchSource2[i]->currentIndex()).toInt(); default:
break; break;
} }
model.customSw[i].andsw = cswitchAnd[i]->itemData(cswitchAnd[i]->currentIndex()).toInt();
emit modified(); emit modified();
lock = false; 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) void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
{ {
lock = true;
RawSource source = RawSource(model.customSw[i].val1, &model); RawSource source = RawSource(model.customSw[i].val1, &model);
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange();
switch (getCSFunctionFamily(model.customSw[i].func)) switch (model.customSw[i].getFunctionFamily())
{ {
case CS_FAMILY_VOFS: case CS_FAMILY_VOFS:
cswitchSource1[i]->setVisible(true); cswitchSource1[i]->setVisible(true);
@ -270,13 +273,15 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
cswitchOffset[i]->setMinimum(range.step*-127); cswitchOffset[i]->setMinimum(range.step*-127);
cswitchOffset[i]->setMaximum(range.step*127); cswitchOffset[i]->setMaximum(range.step*127);
cswitchOffset[i]->setValue(range.step*model.customSw[i].val2); cswitchOffset[i]->setValue(range.step*model.customSw[i].val2);
} else { }
else {
cswitchOffset[i]->setMinimum(range.min); cswitchOffset[i]->setMinimum(range.min);
cswitchOffset[i]->setMaximum(range.max); cswitchOffset[i]->setMaximum(range.max);
cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset); cswitchOffset[i]->setValue(range.step*(model.customSw[i].val2/* TODO+source.getRawOffset(model)*/)+range.offset);
} }
break; break;
case CS_FAMILY_VBOOL: case CS_FAMILY_VBOOL:
case CS_FAMILY_STICKY:
cswitchSource1[i]->setVisible(true); cswitchSource1[i]->setVisible(true);
cswitchSource2[i]->setVisible(true); cswitchSource2[i]->setVisible(true);
cswitchValue[i]->setVisible(false); cswitchValue[i]->setVisible(false);
@ -284,6 +289,13 @@ void CustomSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1)); populateSwitchCB(cswitchSource1[i], RawSwitch(model.customSw[i].val1));
populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2)); populateSwitchCB(cswitchSource2[i], RawSwitch(model.customSw[i].val2));
break; 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: case CS_FAMILY_VCOMP:
cswitchSource1[i]->setVisible(true); cswitchSource1[i]->setVisible(true);
cswitchSource2[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(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)); 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; break;
case CS_FAMILY_TIMERS: case CS_FAMILY_TIMER:
cswitchSource1[i]->setVisible(false); cswitchSource1[i]->setVisible(false);
cswitchSource2[i]->setVisible(false); cswitchSource2[i]->setVisible(false);
cswitchValue[i]->setVisible(true); updateTimerParam(cswitchValue[i], model.customSw[i].val1);
cswitchOffset[i]->setVisible(true); updateTimerParam(cswitchOffset[i], model.customSw[i].val2);
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);
break; break;
} }
cswitchAnd[i]->setVisible(true);
populateSwitchCB(cswitchAnd[i], RawSwitch(model.customSw[i].andsw), POPULATE_AND_SWITCHES); lock = false;
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);
}
} }
void CustomSwitchesPanel::update() void CustomSwitchesPanel::update()
{ {
lock = true;
for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) { for (int i=0; i<GetEepromInterface()->getCapability(CustomSwitches); i++) {
lock = true;
populateCSWCB(csw[i], model.customSw[i].func); populateCSWCB(csw[i], model.customSw[i].func);
lock = false;
setSwitchWidgetVisibility(i); 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() void CustomSwitchesPanel::cswPaste()

View file

@ -17,6 +17,11 @@ class CustomSwitchesPanel : public ModelPanel
private slots: private slots:
void edited(); 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 csw_customContextMenuRequested(QPoint pos);
void cswDelete(); void cswDelete();
void cswCopy(); void cswCopy();
@ -36,6 +41,8 @@ class CustomSwitchesPanel : public ModelPanel
int selectedSwitch; int selectedSwitch;
void updateSelectedSwitch(); void updateSelectedSwitch();
void updateV2(int index);
void updateTimerParam(QDoubleSpinBox *sb, int timer, bool allowZero=false);
}; };

View file

@ -11,8 +11,10 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
{ {
ui->setupUi(this); ui->setupUi(this);
lock = true;
// Mode // Mode
populateTimerSwitchCB(ui->mode, timer.mode); populateSwitchCB(ui->mode, timer.mode, POPULATE_TIMER_MODES);
if (!GetEepromInterface()->getCapability(PermTimers)) { if (!GetEepromInterface()->getCapability(PermTimers)) {
ui->persistent->hide(); ui->persistent->hide();
@ -23,6 +25,8 @@ TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer):
ui->countdownBeep->addItem(tr("Beeps")); ui->countdownBeep->addItem(tr("Beeps"));
if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard())) if (IS_ARM(GetEepromInterface()->getBoard()) || IS_2560(GetEepromInterface()->getBoard()))
ui->countdownBeep->addItem(tr("Countdown")); ui->countdownBeep->addItem(tr("Countdown"));
lock = false;
} }
TimerPanel::~TimerPanel() TimerPanel::~TimerPanel()
@ -63,8 +67,10 @@ void TimerPanel::on_value_editingFinished()
void TimerPanel::on_mode_currentIndexChanged(int index) void TimerPanel::on_mode_currentIndexChanged(int index)
{ {
timer.mode = TimerMode(ui->mode->itemData(index).toInt()); if (!lock) {
emit modified(); timer.mode = RawSwitch(ui->mode->itemData(index).toInt());
emit modified();
}
} }
void TimerPanel::on_persistent_toggled(bool checked) void TimerPanel::on_persistent_toggled(bool checked)

View file

@ -352,7 +352,7 @@ void TelemetryCustomScreen::updateBar(int line)
RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model); RawSource source = RawSource(SOURCE_TYPE_TELEMETRY, index-1, &model);
RawSourceRange range = source.getRange(true); RawSourceRange range = source.getRange(true);
int max = round((range.max - range.min) / range.step); 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; screen.body.bars[line].barMax = 255 - max;
minSB[line]->setEnabled(true); minSB[line]->setEnabled(true);
minSB[line]->setDecimals(range.decimals); minSB[line]->setDecimals(range.decimals);

View file

@ -54,7 +54,6 @@ printDialog::printDialog(QWidget *parent, GeneralSettings *gg, ModelData *gm, QS
printCurves(); printCurves();
printGvars(); printGvars();
printSwitches(); printSwitches();
printSafetySwitches();
printFSwitches(); printFSwitches();
printFrSky(); printFrSky();
@ -651,7 +650,7 @@ void printDialog::printSwitches()
} else { } else {
str.append("<td width=\"60\" align=\"center\"><b>"+tr("LS")+('A'+(i-9))+"</b></td>"); 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(doTC(tstr,"green"));
str.append("</tr>"); str.append("</tr>");
sc++; sc++;
@ -693,33 +692,6 @@ void printDialog::printGvars()
} }
} }
void printDialog::printSafetySwitches()
{
int sc=0;
QString str = "<table border=1 cellspacing=0 cellpadding=3 width=\"100%\">";
str.append("<tr><td><h2>"+tr("Safety Switches")+"</h2></td></tr>");
str.append("<tr><td><table border=0 cellspacing=0 cellpadding=3><tr>");
str.append("<td width=\"60\">&nbsp;</td>");
str.append(doTC(tr("Switch"), "", true));
str.append(doTL(tr("Value"), "", true));
str.append("</tr>");
for(int i=0; i<GetEepromInterface()->getCapability(Outputs); i++)
{
if (g_model->safetySw[i].swtch.type) {
str.append("<tr>");
str.append(doTC(tr("CH")+QString("%1").arg(i+1),"",true));
str.append(doTC(g_model->safetySw[i].swtch.toString(),"green"));
str.append(doTC(QString::number(g_model->safetySw[i].val),"green"));
str.append("</tr>");
sc++;
}
}
str.append("</table></td></tr></table>");
str.append("<br>");
if (sc!=0)
te->append(str);
}
void printDialog::printFSwitches() void printDialog::printFSwitches()
{ {
int sc=0; int sc=0;
@ -736,8 +708,8 @@ void printDialog::printFSwitches()
if (g_model->funcSw[i].swtch.type!=SWITCH_TYPE_NONE) { if (g_model->funcSw[i].swtch.type!=SWITCH_TYPE_NONE) {
str.append("<tr>"); str.append("<tr>");
str.append(doTC(g_model->funcSw[i].swtch.toString(),"green")); str.append(doTC(g_model->funcSw[i].swtch.toString(),"green"));
str.append(doTC(getFuncName(g_model->funcSw[i].func),"green")); str.append(doTC(g_model->funcSw[i].funcToString(),"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].paramToString(),"green"));
int index=g_model->funcSw[i].func; int index=g_model->funcSw[i].func;
if (index==FuncPlaySound || index==FuncPlayHaptic || index==FuncPlayValue || index==FuncPlayPrompt || index==FuncPlayBoth || index==FuncBackgroundMusic) { 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")); str.append(doTC(QString("%1").arg(g_model->funcSw[i].repeatParam),"green"));

View file

@ -571,7 +571,7 @@ void AudioQueue::wakeup()
} }
// mix the background context // mix the background context
if (!isFunctionActive(FUNC_BACKGND_MUSIC_PAUSE)) { if (!isFunctionActive(FUNCTION_BACKGND_MUSIC_PAUSE)) {
result = mixAudioContext(backgroundContext, buffer, g_eeGeneral.varioVolume, g_eeGeneral.backgroundVolume, fade); result = mixAudioContext(backgroundContext, buffer, g_eeGeneral.varioVolume, g_eeGeneral.backgroundVolume, fade);
if (result > 0) { if (result > 0) {
size = max(size, result); size = max(size, result);

View file

@ -196,15 +196,18 @@ void ConvertGeneralSettings_215_to_216(EEGeneral &settings)
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
int ConvertSwitch_215_to_216(int swtch) int ConvertSwitch_215_to_216(int swtch)
{ {
if (swtch < SWSRC_ON) if (swtch <= SWSRC_LAST_SWITCH)
return swtch; return swtch;
else else
return swtch + (2*6); // 2 * 6-pos pots added as switches return swtch + (2*4) + (2*6); // 4 trims and 2 * 6-pos added as switches
} }
#else #else
inline int ConvertSwitch_215_to_216(int swtch) inline int ConvertSwitch_215_to_216(int swtch)
{ {
return swtch; if (swtch <= SWSRC_LAST_SWITCH)
return swtch;
else
return swtch + (2*4) + 1; // 4 trims and REa added
} }
#endif #endif
@ -219,7 +222,7 @@ void ConvertModel_215_to_216(ModelData &model)
// Custom Switches: better precision for x when A comes from telemetry // Custom Switches: better precision for x when A comes from telemetry
// Main View: altitude in top bar // Main View: altitude in top bar
// Mixes: GVARS in weight moved from 512 to 4096 and -512 to -4096, because GVARS may be used in limits [-1250:1250] // Mixes: GVARS in weight moved from 512 to 4096 and -512 to -4096, because GVARS may be used in limits [-1250:1250]
// Switches: two 6-pos pots added // Switches: two 6-pos pots added, REa added to Sky9x
TRACE("Model conversion from v215 to v216"); TRACE("Model conversion from v215 to v216");
@ -378,13 +381,13 @@ void ConvertModel_215_to_216(ModelData &model)
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
CustomSwData * cs = &g_model.customSw[i]; CustomSwData * cs = &g_model.customSw[i];
uint8_t cstate = cswFamily(cs->func); uint8_t cstate = cswFamily(cs->func);
if (cstate == CS_VOFS || cstate == CS_VCOMP || cstate == CS_VDIFF) { if (cstate == CS_FAMILY_OFS || cstate == CS_FAMILY_COMP || cstate == CS_FAMILY_DIFF) {
if (cs->v1 > 0) cs->v1 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; if (cs->v1 > 0) cs->v1 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS;
if (cs->v1 > MIXSRC_GVAR1+4) cs->v1 += 4; if (cs->v1 > MIXSRC_GVAR1+4) cs->v1 += 4;
} }
if (cstate == CS_VOFS || cstate == CS_VDIFF) { if (cstate == CS_FAMILY_OFS || cstate == CS_FAMILY_DIFF) {
if (cs->v1 >= MIXSRC_FIRST_TELEM) { if (cs->v1 >= MIXSRC_FIRST_TELEM) {
switch (cs->v1) { switch ((uint8_t)cs->v1) {
case MIXSRC_FIRST_TELEM + TELEM_TM1-1: case MIXSRC_FIRST_TELEM + TELEM_TM1-1:
case MIXSRC_FIRST_TELEM + TELEM_TM2-1: case MIXSRC_FIRST_TELEM + TELEM_TM2-1:
cs->v2 = (cs->v2+128) * 3; cs->v2 = (cs->v2+128) * 3;
@ -426,7 +429,7 @@ void ConvertModel_215_to_216(ModelData &model)
} }
} }
} }
if (cstate == CS_VCOMP) { if (cstate == CS_FAMILY_COMP) {
if (cs->v2 > 0) cs->v2 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; if (cs->v2 > 0) cs->v2 += MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS;
if (cs->v2 > MIXSRC_GVAR1+4) cs->v2 += 4; if (cs->v2 > MIXSRC_GVAR1+4) cs->v2 += 4;
} }
@ -435,7 +438,7 @@ void ConvertModel_215_to_216(ModelData &model)
for (uint8_t i=0; i<32; i++) { for (uint8_t i=0; i<32; i++) {
g_model.funcSw[i] = oldModel.funcSw[i]; g_model.funcSw[i] = oldModel.funcSw[i];
CustomFnData *sd = &g_model.funcSw[i]; CustomFnData *sd = &g_model.funcSw[i];
if (CFN_FUNC(sd) == FUNC_PLAY_VALUE || CFN_FUNC(sd) == FUNC_VOLUME || (IS_ADJUST_GV_FUNCTION(sd) && CFN_GVAR_MODE(sd) == FUNC_ADJUST_GVAR_SOURCE)) { if (CFN_FUNC(sd) == FUNC_PLAY_VALUE || CFN_FUNC(sd) == FUNC_VOLUME || (IS_ADJUST_GV_FUNC(CFN_FUNC(sd)) && CFN_GVAR_MODE(sd) == FUNC_ADJUST_GVAR_SOURCE)) {
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
CFN_PARAM(sd) += 1 + MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS; CFN_PARAM(sd) += 1 + MAX_INPUTS + MAX_SCRIPTS*MAX_SCRIPT_OUTPUTS;
#endif #endif

View file

@ -383,7 +383,6 @@ void eeLoadModel(uint8_t id)
resumePulses(); resumePulses();
} }
activeSwitches = 0;
activeFnSwitches = 0; activeFnSwitches = 0;
activeFunctions = 0; activeFunctions = 0;
memclear(lastFunctionTime, sizeof(lastFunctionTime)); memclear(lastFunctionTime, sizeof(lastFunctionTime));

View file

@ -948,7 +948,6 @@ void eeLoadModel(uint8_t id)
resumePulses(); resumePulses();
} }
activeSwitches = 0;
activeFnSwitches = 0; activeFnSwitches = 0;
activeFunctions = 0; activeFunctions = 0;
memclear(lastFunctionTime, sizeof(lastFunctionTime)); memclear(lastFunctionTime, sizeof(lastFunctionTime));

View file

@ -1051,7 +1051,7 @@ void menuModelSetup(uint8_t event)
} }
else { else {
putsStrIdx(0*FW, y, STR_TIMER, k>=ITEM_MODEL_TIMER2 ? 2 : 1); putsStrIdx(0*FW, y, STR_TIMER, k>=ITEM_MODEL_TIMER2 ? 2 : 1);
putsTmrMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, m_posHorz==0 ? attr : 0); putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, m_posHorz==0 ? attr : 0);
putsTime(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, m_posHorz==1 ? attr : 0, m_posHorz==2 ? attr : 0); putsTime(MODEL_SETUP_2ND_COLUMN+5*FW-2+5*FWNUM+1, y, timer->start, m_posHorz==1 ? attr : 0, m_posHorz==2 ? attr : 0);
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
if (attr && m_posHorz < 0) lcd_filled_rect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8); if (attr && m_posHorz < 0) lcd_filled_rect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-MENUS_SCROLLBAR_WIDTH, 8);
@ -1060,7 +1060,7 @@ void menuModelSetup(uint8_t event)
div_t qr = div(timer->start, 60); div_t qr = div(timer->start, 60);
switch (m_posHorz) { switch (m_posHorz) {
case 0: case 0:
CHECK_INCDEC_MODELVAR(event, timer->mode, -2*(NUM_PSWITCH+NUM_CSW), TMR_VAROFS-1+2*(NUM_PSWITCH+NUM_CSW)); CHECK_INCDEC_MODELVAR(event, timer->mode, SWSRC_FIRST, TMR_VAROFS+SWSRC_LAST-1/*--- which is OFF*/);
break; break;
case 1: case 1:
CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59); CHECK_INCDEC_MODELVAR_ZERO(event, qr.quot, 59);
@ -1786,8 +1786,8 @@ void menuModelFlightModesAll(uint8_t event)
lcd_puts((5+LEN_FP_NAME)*FW, y, STR_DEFAULT); lcd_puts((5+LEN_FP_NAME)*FW, y, STR_DEFAULT);
} }
else { else {
putsSwitches((5+LEN_FP_NAME)*FW, y, p->swtch, attr); putsSwitches((5+LEN_FP_NAME)*FW+FW/2, y, p->swtch, attr);
if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, -NUM_SWITCH, NUM_SWITCH); if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, SWSRC_FIRST, SWSRC_LAST);
} }
break; break;
@ -4128,6 +4128,9 @@ enum CustomSwitchFields {
CSW_FIELD_FUNCTION, CSW_FIELD_FUNCTION,
CSW_FIELD_V1, CSW_FIELD_V1,
CSW_FIELD_V2, CSW_FIELD_V2,
#if defined(PCBTARANIS)
CSW_FIELD_V3,
#endif
CSW_FIELD_ANDSW, CSW_FIELD_ANDSW,
#if defined(CPUARM) #if defined(CPUARM)
CSW_FIELD_DURATION, CSW_FIELD_DURATION,
@ -4139,10 +4142,10 @@ enum CustomSwitchFields {
#if LCD_W >= 212 #if LCD_W >= 212
#define CSW_1ST_COLUMN (4*FW-3) #define CSW_1ST_COLUMN (4*FW-3)
#define CSW_2ND_COLUMN (8*FW+1) #define CSW_2ND_COLUMN (8*FW+2+FW/2)
#define CSW_3RD_COLUMN (14*FW) #define CSW_3RD_COLUMN (14*FW+1+FW/2)
#define CSW_4TH_COLUMN (21*FW+1) #define CSW_4TH_COLUMN (22*FW)
#define CSW_5TH_COLUMN (26*FW+1) #define CSW_5TH_COLUMN (26*FW+3)
#define CSW_6TH_COLUMN (31*FW+1) #define CSW_6TH_COLUMN (31*FW+1)
#else #else
#define CSW_1ST_COLUMN (4*FW-3) #define CSW_1ST_COLUMN (4*FW-3)
@ -4162,7 +4165,8 @@ void menuModelCustomSwitchOne(uint8_t event)
CustomSwData * cs = cswAddress(s_currIdx); CustomSwData * cs = cswAddress(s_currIdx);
uint8_t sw = SWSRC_SW1+s_currIdx; uint8_t sw = SWSRC_SW1+s_currIdx;
putsSwitches(14*FW, 0, sw, (getSwitch(sw) ? BOLD : 0)); putsSwitches(14*FW, 0, sw, (getSwitch(sw) ? BOLD : 0));
SIMPLE_SUBMENU_NOTITLE(CSW_FIELD_COUNT);
SUBMENU_NOTITLE(CSW_FIELD_COUNT, {0, 0, 1, 0 /*, 0...*/});
int8_t sub = m_posVert; int8_t sub = m_posVert;
@ -4176,10 +4180,18 @@ void menuModelCustomSwitchOne(uint8_t event)
lcd_putsLeft(y, STR_FUNC); lcd_putsLeft(y, STR_FUNC);
lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_VCSWFUNC, cs->func, attr); lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_VCSWFUNC, cs->func, attr);
if (attr) { if (attr) {
CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, CS_MAXF); cs->func = checkIncDec(event, cs->func, 0, CS_MAXF, EE_MODEL, isFunctionAvailable);
if (cstate != cswFamily(cs->func)) { uint8_t new_cstate = cswFamily(cs->func);
cs->v1 = 0; if (cstate != new_cstate) {
cs->v2 = 0; if (new_cstate == CS_FAMILY_TIMER) {
cs->v1 = cs->v2 = -119;
}
else if (new_cstate == CS_FAMILY_STAY) {
cs->v1 = 0; cs->v2 = -129; cs->v3 = 0;
}
else {
cs->v1 = cs->v2 = 0;
}
} }
} }
break; break;
@ -4187,11 +4199,11 @@ void menuModelCustomSwitchOne(uint8_t event)
{ {
lcd_putsLeft(y, STR_V1); lcd_putsLeft(y, STR_V1);
int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM; int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM;
if (cstate == CS_VBOOL) { if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY || cstate == CS_FAMILY_STAY) {
putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr); putsSwitches(CSWONE_2ND_COLUMN, y, cs->v1, attr);
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
} }
else if (cstate == CS_VTIMER) { else if (cstate == CS_FAMILY_TIMER) {
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v1+1, LEFT|attr); lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v1+1, LEFT|attr);
v1_max = 99; v1_max = 99;
} }
@ -4206,16 +4218,32 @@ void menuModelCustomSwitchOne(uint8_t event)
case CSW_FIELD_V2: case CSW_FIELD_V2:
{ {
lcd_putsLeft(y, STR_V2); lcd_putsLeft(y, STR_V2);
int8_t v2_min=0, v2_max=MIXSRC_LAST_TELEM; int16_t v2_min=0, v2_max=MIXSRC_LAST_TELEM;
if (cstate == CS_VBOOL) { if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) {
putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr); putsSwitches(CSWONE_2ND_COLUMN, y, cs->v2, attr);
v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1;
} }
else if (cstate == CS_VTIMER) { else if (cstate == CS_FAMILY_TIMER) {
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2+1, LEFT|attr); lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->v2+1, LEFT|attr);
v2_max = 99; v2_max = 99;
} }
else if (cstate == CS_VCOMP) { else if (cstate == CS_FAMILY_STAY) {
lcd_putc(CSWONE_2ND_COLUMN-4, y, '[');
lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|(m_posHorz==0 ? attr : 0));
lcd_putc(lcdLastPos, y, ':');
if (cs->v3 == 0)
lcd_putsAtt(lcdLastPos+3, y, "--", (m_posHorz==1 ? attr : 0));
else
lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(m_posHorz==1 ? attr : 0));
lcd_putc(lcdLastPos, y, ']');
if (s_editMode <= 0) continue;
if (attr && m_posHorz==1) {
CHECK_INCDEC_MODELVAR(event, cs->v3, 0, 222 - cs->v2);
break;
}
v2_min=-129; v2_max = 122;
}
else if (cstate == CS_FAMILY_COMP) {
putsMixerSource(CSWONE_2ND_COLUMN, y, cs->v2, attr); putsMixerSource(CSWONE_2ND_COLUMN, y, cs->v2, attr);
} }
else { else {
@ -4223,7 +4251,7 @@ void menuModelCustomSwitchOne(uint8_t event)
if (cs->v1 >= MIXSRC_FIRST_TELEM) { if (cs->v1 >= MIXSRC_FIRST_TELEM) {
putsTelemetryChannel(CSWONE_2ND_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), attr|LEFT); putsTelemetryChannel(CSWONE_2ND_COLUMN, y, cs->v1 - MIXSRC_FIRST_TELEM, convertCswTelemValue(cs), attr|LEFT);
v2_max = maxTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1); v2_max = maxTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1);
if (cstate == CS_VOFS) { if (cstate == CS_FAMILY_OFS) {
v2_min = -128; v2_min = -128;
v2_max -= 128; v2_max -= 128;
} }
@ -4252,7 +4280,7 @@ void menuModelCustomSwitchOne(uint8_t event)
case CSW_FIELD_ANDSW: case CSW_FIELD_ANDSW:
lcd_putsLeft(y, STR_AND_SWITCH); lcd_putsLeft(y, STR_AND_SWITCH);
putsSwitches(CSWONE_2ND_COLUMN, y, cs->andsw, attr); putsSwitches(CSWONE_2ND_COLUMN, y, cs->andsw, attr);
if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -NUM_SWITCH, NUM_SWITCH); if (attr) CHECK_INCDEC_MODELVAR(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW);
break; break;
case CSW_FIELD_DURATION: case CSW_FIELD_DURATION:
lcd_putsLeft(y, STR_DURATION); lcd_putsLeft(y, STR_DURATION);
@ -4312,15 +4340,26 @@ void menuModelCustomSwitches(uint8_t event)
// CSW params // CSW params
uint8_t cstate = cswFamily(cs->func); uint8_t cstate = cswFamily(cs->func);
if (cstate == CS_VBOOL) { if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) {
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0); putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0);
putsSwitches(CSW_3RD_COLUMN, y, cs->v2, 0); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, 0);
} }
else if (cstate == CS_VCOMP) { else if (cstate == CS_FAMILY_COMP) {
putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, 0); putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, 0);
putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, 0); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, 0);
} }
else if (cstate == CS_VTIMER) { else if (cstate == CS_FAMILY_STAY) {
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, 0);
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1);
lcd_putc(lcdLastPos, y, ':');
if (cs->v3 == 0)
lcd_puts(lcdLastPos+3, y, "--");
else
lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1);
lcd_putc(lcdLastPos-1, y, ']');
}
else if (cstate == CS_FAMILY_TIMER) {
lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT); lcd_outdezAtt(CSW_2ND_COLUMN, y, cs->v1+1, LEFT);
lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2+1, LEFT); lcd_outdezAtt(CSW_3RD_COLUMN, y, cs->v2+1, LEFT);
} }
@ -4397,15 +4436,15 @@ void menuModelCustomSwitches(uint8_t event)
#endif #endif
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
if (sub>=0 && horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { if (sub>=0 && horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) {
killEvents(event); killEvents(event);
CustomSwData * cs = cswAddress(sub); CustomSwData * cs = cswAddress(sub);
if (cs->func) MENU_ADD_ITEM(STR_COPY); if (cs->func) MENU_ADD_ITEM(STR_COPY);
if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH) if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH)
MENU_ADD_ITEM(STR_PASTE); MENU_ADD_ITEM(STR_PASTE);
if (cs->func || cs->v1 || cs->v2 || cs->delay || cs->duration || cs->andsw) MENU_ADD_ITEM(STR_DELETE); if (cs->func || cs->v1 || cs->v2 || cs->delay || cs->duration || cs->andsw) MENU_ADD_ITEM(STR_DELETE);
menuHandler = onCustomSwitchesMenu; menuHandler = onCustomSwitchesMenu;
} }
#endif #endif
for (uint8_t i=0; i<LCD_LINES-1; i++) { for (uint8_t i=0; i<LCD_LINES-1; i++) {
@ -4427,25 +4466,50 @@ void menuModelCustomSwitches(uint8_t event)
uint8_t cstate = cswFamily(cs->func); uint8_t cstate = cswFamily(cs->func);
#if defined(CPUARM) #if defined(CPUARM)
int16_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; int16_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM;
int16_t v3_min=0, v3_max=100;
#else #else
int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM; int8_t v1_min=0, v1_max=MIXSRC_LAST_TELEM, v2_min=0, v2_max=MIXSRC_LAST_TELEM;
#endif #endif
if (cstate == CS_VBOOL) { if (cstate == CS_FAMILY_BOOL || cstate == CS_FAMILY_STICKY) {
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1);
putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2); putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2);
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1; v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1; v2_min = SWSRC_OFF+1; v2_max = SWSRC_ON-1;
INCDEC_SET_FLAG(INCDEC_SWITCH); INCDEC_SET_FLAG(INCDEC_SWITCH);
INCDEC_ENABLE_CHECK(NULL); INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches);
} }
else if (cstate == CS_VCOMP) { #if defined(CPUARM)
else if (cstate == CS_FAMILY_STAY) {
putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1);
lcd_putc(CSW_3RD_COLUMN-4, y, '[');
lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2);
lcd_putc(lcdLastPos, y, ':');
if (cs->v3 == 0)
lcd_putsAtt(lcdLastPos+3, y, "--", (horz==CSW_FIELD_V3 ? attr : 0));
else
lcd_outdezAtt(lcdLastPos+3, y, cswTimerValue(cs->v2+cs->v3), LEFT|PREC1|(horz==CSW_FIELD_V3 ? attr : 0));
lcd_putc(lcdLastPos, y, ']');
v1_min = SWSRC_OFF+1; v1_max = SWSRC_ON-1;
v2_min=-129; v2_max = 122;
v3_max = 222 - cs->v2;
if (horz == 1) {
INCDEC_SET_FLAG(INCDEC_SWITCH);
INCDEC_ENABLE_CHECK(isSwitchAvailable);
}
else {
INCDEC_SET_FLAG(0);
INCDEC_ENABLE_CHECK(NULL);
}
}
#endif
else if (cstate == CS_FAMILY_COMP) {
putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1); putsMixerSource(CSW_2ND_COLUMN, y, cs->v1, attr1);
putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, attr2); putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, attr2);
INCDEC_SET_FLAG(INCDEC_SOURCE); INCDEC_SET_FLAG(INCDEC_SOURCE);
INCDEC_ENABLE_CHECK(isSourceAvailable); INCDEC_ENABLE_CHECK(isSourceAvailable);
} }
else if (cstate == CS_VTIMER) { else if (cstate == CS_FAMILY_TIMER) {
lcd_outdezAtt(CSW_2ND_COLUMN, y, cswTimerValue(cs->v1), LEFT|PREC1|attr1); lcd_outdezAtt(CSW_2ND_COLUMN, y, cswTimerValue(cs->v1), LEFT|PREC1|attr1);
lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2); lcd_outdezAtt(CSW_3RD_COLUMN, y, cswTimerValue(cs->v2), LEFT|PREC1|attr2);
v1_min = v2_min = -128; v1_min = v2_min = -128;
@ -4474,7 +4538,7 @@ void menuModelCustomSwitches(uint8_t event)
eeDirty(EE_MODEL); eeDirty(EE_MODEL);
} }
#else #else
if (cstate == CS_VOFS) { if (cstate == CS_FAMILY_OFS) {
v2_min = -128; v2_min = -128;
v2_max -= 128; v2_max -= 128;
} }
@ -4504,31 +4568,69 @@ void menuModelCustomSwitches(uint8_t event)
#endif #endif
} }
// CSW and switch // CSW AND switch
putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==3 ? attr : 0); #if defined(CPUARM)
putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==CSW_FIELD_ANDSW ? attr : 0);
#else
uint8_t andsw = cs->andsw;
if (andsw > SWSRC_LAST_SWITCH) {
andsw += SWSRC_SW1-SWSRC_LAST_SWITCH-1;
}
putsSwitches(CSW_4TH_COLUMN, y, andsw, horz==CSW_FIELD_ANDSW ? attr : 0);
#endif
#if defined(CPUARM) #if defined(CPUARM)
// CSW duration // CSW duration
if (cs->duration > 0) if (cs->duration > 0)
lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==4 ? attr : 0)|PREC1|LEFT); lcd_outdezAtt(CSW_5TH_COLUMN, y, 5*cs->duration, (horz==CSW_FIELD_DURATION ? attr : 0)|PREC1|LEFT);
else else
lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==4 ? attr : 0); lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DURATION ? attr : 0);
// CSW delay // CSW delay
if (cs->delay > 0) if (cstate == CS_FAMILY_STAY) {
lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==5 ? attr : 0)|PREC1|LEFT); lcd_puts(CSW_6TH_COLUMN, y, "N/A");
else if (attr && horz == CSW_FIELD_DELAY) {
lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==5 ? attr : 0); REPEAT_LAST_CURSOR_MOVE();
}
}
else if (cs->delay > 0) {
lcd_outdezAtt(CSW_6TH_COLUMN, y, 5*cs->delay, (horz==CSW_FIELD_DELAY ? attr : 0)|PREC1|LEFT);
}
else {
lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==CSW_FIELD_DELAY ? attr : 0);
}
if (attr && horz == CSW_FIELD_V3 && cstate != CS_FAMILY_STAY) {
REPEAT_LAST_CURSOR_MOVE();
}
#endif #endif
if ((s_editMode>0 || p1valdiff) && attr) { if ((s_editMode>0 || p1valdiff) && attr) {
switch (horz) { switch (horz) {
case CSW_FIELD_FUNCTION: case CSW_FIELD_FUNCTION:
{ {
#if defined(CPUARM)
cs->func = checkIncDec(event, cs->func, 0, CS_MAXF, EE_MODEL, isFunctionAvailable);
#else
CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, CS_MAXF); CHECK_INCDEC_MODELVAR_ZERO(event, cs->func, CS_MAXF);
#endif
uint8_t new_cstate = cswFamily(cs->func); uint8_t new_cstate = cswFamily(cs->func);
if (cstate != new_cstate) if (cstate != new_cstate) {
cs->v1 = cs->v2 = (new_cstate==CS_VTIMER ? -119/*1.0*/ : 0); #if defined(CPUARM)
if (new_cstate == CS_FAMILY_TIMER) {
cs->v1 = cs->v2 = -119;
}
else if (new_cstate == CS_FAMILY_STAY) {
cs->v1 = 0; cs->v2 = -129; cs->v3 = 0;
}
else {
cs->v1 = cs->v2 = 0;
}
#else
cs->v1 = cs->v2 = (new_cstate==CS_FAMILY_TIMER ? -119/*1.0*/ : 0);
#endif
}
break; break;
} }
case CSW_FIELD_V1: case CSW_FIELD_V1:
@ -4537,10 +4639,9 @@ void menuModelCustomSwitches(uint8_t event)
case CSW_FIELD_V2: case CSW_FIELD_V2:
cs->v2 = CHECK_INCDEC_PARAM(event, cs->v2, v2_min, v2_max); cs->v2 = CHECK_INCDEC_PARAM(event, cs->v2, v2_min, v2_max);
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
if (cstate==CS_VOFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { if (cstate==CS_FAMILY_OFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event); killEvents(event);
getvalue_t x = getValue(cs->v1); getvalue_t x = getValue(cs->v1);
TRACE("AUTO x=%d", x);
if (cs->v1 < MIXSRC_GVAR1) if (cs->v1 < MIXSRC_GVAR1)
cs->v2 = calcRESXto100(x); cs->v2 = calcRESXto100(x);
else if (cs->v1 - MIXSRC_FIRST_TELEM + 1 == TELEM_ALT) else if (cs->v1 - MIXSRC_FIRST_TELEM + 1 == TELEM_ALT)
@ -4549,9 +4650,16 @@ void menuModelCustomSwitches(uint8_t event)
} }
#endif #endif
break; break;
#if defined(CPUARM)
case CSW_FIELD_V3:
cs->v3 = CHECK_INCDEC_PARAM(event, cs->v3, v3_min, v3_max);
break;
#endif
case CSW_FIELD_ANDSW: case CSW_FIELD_ANDSW:
#if defined(CPUARM) #if defined(CPUARM)
CHECK_INCDEC_MODELSWITCH(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW); INCDEC_SET_FLAG(INCDEC_SWITCH);
INCDEC_ENABLE_CHECK(isSwitchAvailableInCustomSwitches);
cs->andsw = CHECK_INCDEC_PARAM(event, cs->andsw, -MAX_CSW_ANDSW, MAX_CSW_ANDSW);
#else #else
CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_CSW_ANDSW); CHECK_INCDEC_MODELVAR_ZERO(event, cs->andsw, MAX_CSW_ANDSW);
#endif #endif
@ -4596,14 +4704,14 @@ void onCustomFunctionsFileSelectionMenu(const char *result)
if (result == STR_UPDATE_LIST) { if (result == STR_UPDATE_LIST) {
char directory[] = SOUNDS_PATH; char directory[] = SOUNDS_PATH;
strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
if (!listSdFiles(directory, SOUNDS_EXT, sizeof(g_model.funcSw[sub].param), NULL)) { if (!listSdFiles(directory, SOUNDS_EXT, sizeof(g_model.funcSw[sub].play.name), NULL)) {
POPUP_WARNING(STR_NO_SOUNDS_ON_SD); POPUP_WARNING(STR_NO_SOUNDS_ON_SD);
s_menu_flags = 0; s_menu_flags = 0;
} }
} }
else { else {
// The user choosed a wav file in the list // The user choosed a wav file in the list
memcpy(g_model.funcSw[sub].param.name, result, sizeof(g_model.funcSw[sub].param.name)); memcpy(g_model.funcSw[sub].play.name, result, sizeof(g_model.funcSw[sub].play.name));
eeDirty(EE_MODEL); eeDirty(EE_MODEL);
} }
} }
@ -4643,7 +4751,7 @@ void onCustomFunctionsMenu(const char *result)
void menuModelCustomFunctions(uint8_t event) void menuModelCustomFunctions(uint8_t event)
{ {
MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|3/*repeated*/}); MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/});
uint8_t y; uint8_t y;
uint8_t k = 0; uint8_t k = 0;
@ -4676,249 +4784,218 @@ void menuModelCustomFunctions(uint8_t event)
#endif #endif
CustomFnData *sd = &g_model.funcSw[k]; CustomFnData *sd = &g_model.funcSw[k];
for (uint8_t j=0; j<4; j++) { uint8_t func = CFN_FUNC(sd);
for (uint8_t j=0; j<5; j++) {
uint8_t attr = ((sub==k && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); uint8_t attr = ((sub==k && m_posHorz==j) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
uint8_t active = (attr && (s_editMode>0 || p1valdiff)); uint8_t active = (attr && (s_editMode>0 || p1valdiff));
switch (j) { switch (j) {
case 0: case 0:
putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, sd->swtch, attr | ((activeFnSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(sd), attr | ((activeFnSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0));
if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_MODELSWITCH(event, sd->swtch, SWSRC_FIRST, SWSRC_LAST); if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_MODELSWITCH(event, CFN_SWITCH(sd), SWSRC_FIRST, SWSRC_LAST);
break; break;
case 1: case 1:
if (sd->swtch) { if (CFN_SWITCH(sd)) {
uint8_t func_displayed; lcd_putsiAtt(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr);
if (CFN_FUNC(sd) < FUNC_TRAINER) {
func_displayed = 0;
}
else if (CFN_FUNC(sd) <= FUNC_TRAINER + NUM_STICKS) {
func_displayed = 1;
}
#if defined(DEBUG)
else if (CFN_FUNC(sd) == FUNC_TEST) {
#if defined(GVARS)
func_displayed = FUNC_TEST - FUNC_TRAINER - NUM_STICKS - MAX_GVARS + 2;
#else
func_displayed = FUNC_TEST - FUNC_TRAINER - NUM_STICKS + 1;
#endif
}
#endif
#if defined(GVARS)
else if (CFN_FUNC(sd) >= FUNC_ADJUST_GV1) {
func_displayed = FUNC_ADJUST_GV1 - FUNC_TRAINER - NUM_STICKS + 1;
}
#endif
else {
func_displayed = 2 + CFN_FUNC(sd) - FUNC_TRAINER - NUM_STICKS - 1;
}
lcd_putsiAtt(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func_displayed, attr);
if (CFN_FUNC(sd) < FUNC_TRAINER) {
putsChn(lcdNextPos, y, CFN_CH_NUMBER(sd)+1, attr);
}
else if (CFN_FUNC(sd) <= FUNC_TRAINER + NUM_STICKS) {
if (CFN_FUNC(sd) != FUNC_TRAINER)
putsMixerSource(lcdNextPos, y, MIXSRC_Rud+CFN_FUNC(sd)-FUNC_TRAINER-1, attr);
}
#if defined(GVARS)
else if (CFN_FUNC(sd) >= FUNC_ADJUST_GV1) {
putsStrIdx(lcdNextPos, y, STR_GV, CFN_FUNC(sd)-FUNC_ADJUST_GV1+1, attr);
}
#endif
if (active) { if (active) {
#if defined(CPUARM)
CHECK_INCDEC_MODELVAR_ZERO(event, CFN_FUNC(sd), FUNC_MAX-1); CHECK_INCDEC_MODELVAR_ZERO(event, CFN_FUNC(sd), FUNC_MAX-1);
#else
if (CFN_FUNC(sd) < FUNC_TRAINER) {
CHECK_INCDEC_MODELVAR_ZERO(event, sd->internal.func_safety.func, 16);
}
else {
CHECK_INCDEC_MODELVAR_ZERO(event, CFN_FUNC(sd), FUNC_MAX-1);
if (CFN_FUNC(sd) < FUNC_TRAINER)
sd->internal.func_safety.func = 15;
}
#endif
if (checkIncDec_Ret) CFN_RESET(sd); if (checkIncDec_Ret) CFN_RESET(sd);
} }
} }
else if (attr) { else {
REPEAT_LAST_CURSOR_MOVE(); j = 4; // skip other fields
if (sub==k && m_posHorz > 0) {
REPEAT_LAST_CURSOR_MOVE();
}
} }
break; break;
case 2: case 2:
if (sd->swtch) { {
INCDEC_DECLARE_VARS(); int8_t maxParam = NUM_CHNOUT-1;
int16_t val_displayed = CFN_PARAM(sd); if (func == FUNC_SAFETY_CHANNEL) {
int8_t val_min = 0; putsChn(lcdNextPos, y, CFN_CH_NUMBER(sd)+1, attr);
uint8_t val_max = 255;
if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) {
#if defined(AUDIO)
val_max = AU_FRSKY_LAST-AU_FRSKY_FIRST-1;
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_FUNCSOUNDS, val_displayed, attr);
#else
break;
#endif
}
#if defined(HAPTIC)
else if (CFN_FUNC(sd) == FUNC_HAPTIC) {
val_max = 3;
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
}
#endif
#if defined(CPUARM) && defined(SDCARD)
else if (CFN_FUNC(sd) == FUNC_PLAY_TRACK || CFN_FUNC(sd) == FUNC_BACKGND_MUSIC) {
#if LCD_W >= 212
xcoord_t x = MODEL_CUSTOM_FUNC_3RD_COLUMN;
#else
xcoord_t x = (CFN_FUNC(sd) == FUNC_PLAY_TRACK ? MODEL_CUSTOM_FUNC_2ND_COLUMN + FW + FW*strlen(TR_PLAY_TRACK) : MODEL_CUSTOM_FUNC_3RD_COLUMN);
#endif
if (ZEXIST(sd->param.name))
lcd_putsnAtt(x, y, sd->param.name, sizeof(sd->param.name), attr);
else
lcd_putsiAtt(x, y, STR_VCSWFUNC, 0, attr);
if (active && event==EVT_KEY_BREAK(KEY_ENTER)) {
s_editMode = 0;
char directory[] = SOUNDS_PATH;
strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
if (listSdFiles(directory, SOUNDS_EXT, sizeof(sd->param.name), sd->param.name)) {
menuHandler = onCustomFunctionsFileSelectionMenu;
}
else {
POPUP_WARNING(STR_NO_SOUNDS_ON_SD);
s_menu_flags = 0;
}
}
break;
}
else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) {
val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
#endif
#if defined(CPUARM)
else if (CFN_FUNC(sd) == FUNC_VOLUME) {
val_max = MIXSRC_LAST_CH;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
#elif defined(VOICE)
else if (CFN_FUNC(sd) == FUNC_PLAY_TRACK) {
#if defined(GVARS)
if (attr && event==EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
s_editMode = !s_editMode;
active = true;
val_displayed = (val_displayed > 250 ? 0 : 251);
}
if (val_displayed > 250) {
putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed-250, attr);
}
else {
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT);
}
#else
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT);
#endif
}
else if (CFN_FUNC(sd) == FUNC_PLAY_BOTH) {
lcd_putcAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, '|', attr);
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, val_displayed+PROMPT_CUSTOM_BASE, attr);
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+2+3*FWNUM, y, (val_displayed+PROMPT_CUSTOM_BASE+1)%10, attr|LEFT);
}
else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) {
val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
#endif
#if defined(SDCARD)
else if (CFN_FUNC(sd) == FUNC_LOGS) {
if (val_displayed) {
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT);
lcd_putc(lcdLastPos, y, 's');
}
else {
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr);
}
}
#endif
else if (CFN_FUNC(sd) == FUNC_RESET) {
val_max = FUNC_RESET_PARAM_LAST;
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, CFN_PARAM(sd), attr);
}
else if (CFN_FUNC(sd) < FUNC_TRAINER) {
val_displayed = (int8_t)CFN_PARAM(sd);
val_min = -125; val_max = 125;
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
}
#if defined(GVARS)
else if (CFN_FUNC(sd) >= FUNC_ADJUST_GV1
#if defined(DEBUG)
&& CFN_FUNC(sd) <= FUNC_ADJUST_GVLAST
#endif
) {
switch (CFN_GVAR_MODE(sd)) {
case FUNC_ADJUST_GVAR_CONSTANT:
val_displayed = (int8_t)CFN_PARAM(sd);
val_min = -125; val_max = 125;
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
break;
case FUNC_ADJUST_GVAR_SOURCE:
val_max = MIXSRC_LAST_CH;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_ENABLE_CHECK(isSourceAvailable);
break;
case FUNC_ADJUST_GVAR_GVAR:
val_max = MAX_GVARS-1;
putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr);
break;
default: // FUNC_ADJUST_GVAR_INC
val_max = 1;
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\002-1+1"), val_displayed, attr);
break;
}
if (attr && event==EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
s_editMode = !s_editMode;
active = true;
CFN_GVAR_MODE(sd) += 1;
val_displayed = 0;
}
}
#endif
else {
if (attr) m_posHorz = (CURSOR_MOVED_LEFT(event) ? 1 : 3);
break;
}
if (active) {
CFN_PARAM(sd) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max);
}
} }
else if (func == FUNC_TRAINER) {
maxParam = 4;
#if defined(CPUARM)
putsMixerSource(lcdNextPos, y, CFN_CH_NUMBER(sd)==0 ? 0 : MIXSRC_Rud+CFN_CH_NUMBER(sd)-1, attr);
#else
putsMixerSource(lcdNextPos, y, MIXSRC_Rud+CFN_CH_NUMBER(sd)-1, attr);
#endif
}
#if defined(GVARS)
else if (func == FUNC_ADJUST_GVAR) {
maxParam = MAX_GVARS-1;
putsStrIdx(lcdNextPos, y, STR_GV, CFN_GVAR_NUMBER(sd)+1, attr);
if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_GVAR_NUMBER(sd), maxParam);
break;
}
#endif
else if (attr) { else if (attr) {
REPEAT_LAST_CURSOR_MOVE(); REPEAT_LAST_CURSOR_MOVE();
} }
if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_NUMBER(sd), maxParam);
break; break;
}
case 3: case 3:
if (sd->swtch && (CFN_FUNC(sd) <= FUNC_INSTANT_TRIM || CFN_FUNC(sd) == FUNC_RESET {
#if defined(GVARS) INCDEC_DECLARE_VARS();
// TODO #define int16_t val_displayed = CFN_PARAM(sd);
|| CFN_FUNC(sd) >= FUNC_ADJUST_GV1 int8_t val_min = 0;
uint8_t val_max = 255;
if (func == FUNC_SAFETY_CHANNEL) {
val_displayed = (int8_t)CFN_PARAM(sd);
val_min = -125; val_max = 125;
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
}
#if defined(AUDIO)
else if (func == FUNC_PLAY_SOUND) {
val_max = AU_FRSKY_LAST-AU_FRSKY_FIRST-1;
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_FUNCSOUNDS, val_displayed, attr);
break;
}
#endif
#if defined(HAPTIC)
else if (func == FUNC_HAPTIC) {
val_max = 3;
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
}
#endif
#if defined(CPUARM) && defined(SDCARD)
else if (func == FUNC_PLAY_TRACK || func == FUNC_BACKGND_MUSIC) {
#if LCD_W >= 212
xcoord_t x = MODEL_CUSTOM_FUNC_3RD_COLUMN;
#else
xcoord_t x = (func == FUNC_PLAY_TRACK ? MODEL_CUSTOM_FUNC_2ND_COLUMN + FW + FW*strlen(TR_PLAY_TRACK) : MODEL_CUSTOM_FUNC_3RD_COLUMN);
#endif
if (ZEXIST(sd->play.name))
lcd_putsnAtt(x, y, sd->play.name, sizeof(sd->play.name), attr);
else
lcd_putsiAtt(x, y, STR_VCSWFUNC, 0, attr);
if (active && event==EVT_KEY_BREAK(KEY_ENTER)) {
s_editMode = 0;
char directory[] = SOUNDS_PATH;
strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
if (listSdFiles(directory, SOUNDS_EXT, sizeof(sd->play.name), sd->play.name)) {
menuHandler = onCustomFunctionsFileSelectionMenu;
}
else {
POPUP_WARNING(STR_NO_SOUNDS_ON_SD);
s_menu_flags = 0;
}
}
break;
}
else if (func == FUNC_PLAY_VALUE) {
val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
#endif #endif
#if defined(CPUARM) #if defined(CPUARM)
// TODO #define else if (func == FUNC_VOLUME) {
|| CFN_FUNC(sd) == FUNC_VOLUME val_max = MIXSRC_LAST_CH;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
#elif defined(VOICE)
else if (func == FUNC_PLAY_TRACK) {
#if defined(GVARS)
if (attr && event==EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
s_editMode = !s_editMode;
active = true;
val_displayed = (val_displayed > 250 ? 0 : 251);
}
if (val_displayed > 250) {
putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed-250, attr);
}
else {
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT);
}
#else
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+PROMPT_CUSTOM_BASE, attr|LEFT);
#endif #endif
)) { }
else if (func == FUNC_PLAY_BOTH) {
lcd_putcAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, '|', attr);
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, val_displayed+PROMPT_CUSTOM_BASE, attr);
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+2+3*FWNUM, y, (val_displayed+PROMPT_CUSTOM_BASE+1)%10, attr|LEFT);
}
else if (func == FUNC_PLAY_VALUE) {
val_max = MIXSRC_FIRST_TELEM + TELEM_DISPLAY_MAX - 1;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_ENABLE_CHECK(isSourceAvailable);
}
#endif
#if defined(SDCARD)
else if (func == FUNC_LOGS) {
if (val_displayed) {
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT);
lcd_putc(lcdLastPos, y, 's');
}
else {
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr);
}
}
#endif
else if (func == FUNC_RESET) {
val_max = FUNC_RESET_PARAM_LAST;
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, CFN_PARAM(sd), attr);
}
#if defined(GVARS)
else if (func == FUNC_ADJUST_GVAR) {
switch (CFN_GVAR_MODE(sd)) {
case FUNC_ADJUST_GVAR_CONSTANT:
val_displayed = (int8_t)CFN_PARAM(sd);
val_min = -125; val_max = 125;
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
break;
case FUNC_ADJUST_GVAR_SOURCE:
val_max = MIXSRC_LAST_CH;
putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr);
INCDEC_ENABLE_CHECK(isSourceAvailable);
break;
case FUNC_ADJUST_GVAR_GVAR:
val_max = MAX_GVARS-1;
putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr);
break;
default: // FUNC_ADJUST_GVAR_INC
val_max = 1;
lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\002-1+1"), val_displayed, attr);
break;
}
if (attr && event==EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
s_editMode = !s_editMode;
active = true;
CFN_GVAR_MODE(sd) += 1;
#if defined(CPUARM)
CFN_GVAR_MODE(sd) &= 0x03;
#endif
val_displayed = 0;
}
}
#endif
else if (attr) {
REPEAT_LAST_CURSOR_MOVE();
}
if (active) {
CFN_PARAM(sd) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max);
}
break;
}
case 4:
if (HAS_ENABLE_PARAM(func)) {
menu_lcd_onoff(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, CFN_ACTIVE(sd), attr); menu_lcd_onoff(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, CFN_ACTIVE(sd), attr);
if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_ACTIVE(sd), 1); if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_ACTIVE(sd), 1);
} }
else if (sd->swtch && HAS_REPEAT_PARAM(sd)) { else if (HAS_REPEAT_PARAM(sd)) {
if (CFN_PLAY_REPEAT(sd) == 0) { if (CFN_PLAY_REPEAT(sd) == 0) {
#if LCD_W >= 212 #if LCD_W >= 212
lcd_putsAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr); lcd_putsAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr);

View file

@ -228,18 +228,6 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui
#endif #endif
} }
} }
if (event == EVT_KEY_LONG(KEY_ENTER) && i_max > SWSRC_ON) {
s_editMode = !s_editMode;
if (newval > SWSRC_ON)
newval -= (NUM_SWITCH+1);
else if (newval > 0)
newval += (NUM_SWITCH+1);
else if (newval < SWSRC_OFF)
newval += (NUM_SWITCH+1);
else if (newval < 0)
newval -= (NUM_SWITCH+1);
}
} }
#endif #endif
@ -976,7 +964,7 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t
{ {
lcd_putsColumnLeft(x, y, STR_SWITCH); lcd_putsColumnLeft(x, y, STR_SWITCH);
putsSwitches(x, y, value, attr); putsSwitches(x, y, value, attr);
if (attr) CHECK_INCDEC_MODELSWITCH(event, value, -NUM_SWITCH, NUM_SWITCH); if (attr) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST, SWSRC_LAST);
return value; return value;
} }
@ -1046,6 +1034,16 @@ int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t m
} }
#endif #endif
void repeatLastCursorMove(uint8_t event)
{
if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) {
putEvent(event);
}
else {
m_posHorz = 0;
}
}
#if LCD_W >= 212 #if LCD_W >= 212
#define MENU_X 30 #define MENU_X 30
#define MENU_Y 16 #define MENU_Y 16
@ -1250,7 +1248,7 @@ bool isInputSourceAvailable(int16_t source)
return false; return false;
} }
bool isSwitchAvailable(int16_t swtch) bool isSwitchAvailableInCustomSwitches(int16_t swtch)
{ {
if (swtch < 0) { if (swtch < 0) {
if (swtch <= -SWSRC_ON) if (swtch <= -SWSRC_ON)
@ -1276,6 +1274,15 @@ bool isSwitchAvailable(int16_t swtch)
} }
#endif #endif
return true;
}
bool isSwitchAvailable(int16_t swtch)
{
if (!isSwitchAvailableInCustomSwitches(swtch)) {
return false;
}
if (swtch >= SWSRC_FIRST_CSW && swtch <= SWSRC_LAST_CSW) { if (swtch >= SWSRC_FIRST_CSW && swtch <= SWSRC_LAST_CSW) {
CustomSwData * cs = cswAddress(swtch-SWSRC_FIRST_CSW); CustomSwData * cs = cswAddress(swtch-SWSRC_FIRST_CSW);
return (cs->func != CS_OFF); return (cs->func != CS_OFF);
@ -1283,4 +1290,11 @@ bool isSwitchAvailable(int16_t swtch)
return true; return true;
} }
// Not available yet, will be needed if we implement the Range function later...
bool isFunctionAvailable(int16_t function)
{
return function != CS_RANGE;
}
#endif #endif

View file

@ -190,7 +190,9 @@ int8_t checkIncDecGen(uint8_t event, int8_t i_val, int8_t i_min, int8_t i_max);
var = checkIncDecModelZero(event,var,max) var = checkIncDecModelZero(event,var,max)
#if defined(CPUARM) #if defined(CPUARM)
bool isFunctionAvailable(int16_t function);
bool isSwitchAvailable(int16_t swtch); bool isSwitchAvailable(int16_t swtch);
bool isSwitchAvailableInCustomSwitches(int16_t swtch);
#define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER)) #define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER))
#define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \ #define CHECK_INCDEC_MODELSWITCH(event, var, min, max) \
var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH|NO_INCDEC_MARKS, isSwitchAvailable) var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SWITCH|NO_INCDEC_MARKS, isSwitchAvailable)
@ -400,7 +402,8 @@ void pushMenuTextView(const char *filename);
#define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) putEvent(event); else m_posHorz = 0; } #define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) putEvent(event); else m_posHorz = 0; }
#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE() #define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE()
#else #else
#define REPEAT_LAST_CURSOR_MOVE() m_posHorz = 0; void repeatLastCursorMove(uint8_t event);
#define REPEAT_LAST_CURSOR_MOVE() repeatLastCursorMove(event)
#define MOVE_CURSOR_FROM_HERE() REPEAT_LAST_CURSOR_MOVE() #define MOVE_CURSOR_FROM_HERE() REPEAT_LAST_CURSOR_MOVE()
#endif #endif

View file

@ -295,7 +295,7 @@ void displayTopBar()
x -= 12; x -= 12;
} }
if (isFunctionActive(FUNC_LOGS)) { if (isFunctionActive(FUNCTION_LOGS)) {
LCD_NOTIF_ICON(x, ICON_LOGS); LCD_NOTIF_ICON(x, ICON_LOGS);
x -= 12; x -= 12;
} }
@ -343,7 +343,7 @@ void displayTimers()
if (g_model.timers[0].mode) { if (g_model.timers[0].mode) {
TimerState & timerState = timersStates[0]; TimerState & timerState = timersStates[0];
putsTime(TIMERS_X, TIMER1_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT); putsTime(TIMERS_X, TIMER1_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTmrMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, STRCONDENSED|SMLSIZE); putsTimerMode(TIMERS_X, TIMER1_Y-6, g_model.timers[0].mode, SMLSIZE);
if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE); if (g_model.timers[0].persistent) lcd_putcAtt(TIMERS_R, TIMER1_Y+1, 'P', SMLSIZE);
if (timerState.val < 0) { if (timerState.val < 0) {
if (BLINK_ON_PHASE) { if (BLINK_ON_PHASE) {
@ -356,7 +356,7 @@ void displayTimers()
if (g_model.timers[1].mode) { if (g_model.timers[1].mode) {
TimerState & timerState = timersStates[1]; TimerState & timerState = timersStates[1];
putsTime(TIMERS_X, TIMER2_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT); putsTime(TIMERS_X, TIMER2_Y, timerState.val, MIDSIZE|LEFT, MIDSIZE|LEFT);
putsTmrMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, STRCONDENSED|SMLSIZE); putsTimerMode(TIMERS_X, TIMER2_Y-6, g_model.timers[1].mode, SMLSIZE);
if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE); if (g_model.timers[1].persistent) lcd_putcAtt(TIMERS_R, TIMER2_Y+1, 'P', SMLSIZE);
if (timerState.val < 0) { if (timerState.val < 0) {
if (BLINK_ON_PHASE) { if (BLINK_ON_PHASE) {
@ -373,7 +373,7 @@ void displayTimers()
TimerState & timerState = timersStates[0]; TimerState & timerState = timersStates[0];
uint8_t att = DBLSIZE | (timerState.val<0 ? BLINK|INVERS : 0); uint8_t att = DBLSIZE | (timerState.val<0 ? BLINK|INVERS : 0);
putsTime(12*FW+2+10*FWNUM-4, FH*2, timerState.val, att, att); putsTime(12*FW+2+10*FWNUM-4, FH*2, timerState.val, att, att);
putsTmrMode(timerState.val >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode, STRCONDENSED); putsTimerMode(timerState.val >= 0 ? 9*FW-FW/2+3 : 9*FW-FW/2-4, FH*3, g_model.timers[0].mode);
} }
} }
#endif #endif
@ -818,7 +818,7 @@ void menuMainView(uint8_t event)
} }
else { // timer2 else { // timer2
putsTime(33+FW+2+10*FWNUM-4, FH*5, timersStates[1].val, DBLSIZE, DBLSIZE); putsTime(33+FW+2+10*FWNUM-4, FH*5, timersStates[1].val, DBLSIZE, DBLSIZE);
putsTmrMode(timersStates[1].val >= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode, STRCONDENSED); putsTimerMode(timersStates[1].val >= 0 ? 20-FW/2+5 : 20-FW/2-2, FH*6, g_model.timers[1].mode);
// lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s // lcd_outdezNAtt(33+11*FW, FH*6, s_timerVal_10ms[1], LEADING0, 2); // 1/100s
} }
#endif // PCBTARANIS #endif // PCBTARANIS

View file

@ -1040,41 +1040,6 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
lcd_vlineStip(x-2, y, 8, 0x5E/*'!'*/); lcd_vlineStip(x-2, y, 8, 0x5E/*'!'*/);
idx = -idx; idx = -idx;
} }
#if ROTARY_ENCODERS > 0
else if (idx >= SWSRC_FIRST_ROTENC_SWITCH) {
idx -= SWSRC_FIRST_ROTENC_SWITCH;
char suffix = (idx & 1) ? CHR_LONG : CHR_SHORT;
lcd_putsiAtt(x, y, STR_VRENCODERS, idx/2, att);
return lcd_putcAtt(lcdLastPos, y, suffix, att);
}
#endif
#if !defined(PCBSTD)
else if (idx >= SWSRC_TRAINER_SHORT) {
idx -= SWSRC_TRAINER_SHORT;
char suffix = (idx & 1) ? CHR_LONG : CHR_SHORT;
#if ROTARY_ENCODERS > 0
if (idx >= 2) {
idx -= 2;
lcd_putsiAtt(x, y, STR_VRENCODERS, idx/2, att);
}
else
#endif
{
lcd_putsiAtt(x, y, STR_VSWITCHES, SWSRC_TRAINER-1, att);
}
return lcd_putcAtt(lcdLastPos, y, suffix, att);
}
#endif
if (idx > SWSRC_ON) {
idx -= SWSRC_ON;
if (idx != SWSRC_ON && (~att & STRCONDENSED)) {
lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att);
return lcd_putcAtt(lcdLastPos, y, CHR_TOGGLE, att);
}
}
lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att); lcd_putsiAtt(x, y, STR_VSWITCHES, idx-1, att);
} }
@ -1141,22 +1106,15 @@ void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
} }
#endif #endif
void putsTmrMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att) void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att)
{ {
if (mode < 0) { if (mode >= 0) {
mode = TMR_VAROFS - mode - 1; if (mode < TMR_VAROFS)
lcd_putcAtt(x-1*FW, y, '!', att); return lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att);
else
mode -= (TMR_VAROFS-1);
} }
else if (mode < TMR_VAROFS) { putsSwitches(x, y, mode, att);
lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att);
return;
}
if (mode >= TMR_VAROFS+NUM_PSWITCH+NUM_CSW) {
mode++;
}
putsSwitches(x, y, mode-(TMR_VAROFS-1), att);
} }
#if defined(PCBTARANIS) #if defined(PCBTARANIS)

View file

@ -83,7 +83,6 @@
/* no 0x80 here because of "GV"1 which is aligned LEFT */ /* no 0x80 here because of "GV"1 which is aligned LEFT */
/* no 0x10 here because of "MODEL"01 which uses LEADING0 */ /* no 0x10 here because of "MODEL"01 which uses LEADING0 */
#define BSS 0x20 #define BSS 0x20
#define STRCONDENSED 0x80 /* means that THRm will be displayed as THR */
#define ZCHAR 0x80 #define ZCHAR 0x80
/* lcd outdez flags */ /* lcd outdez flags */
@ -174,7 +173,7 @@ void putsFlightPhase(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att); void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att);
#endif #endif
void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0); void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
void putsTmrMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att); void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att=0);
void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att);
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att); void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att);

View file

@ -175,7 +175,7 @@ void writeLogs()
{ {
static const pm_char * error_displayed = NULL; static const pm_char * error_displayed = NULL;
if (isFunctionActive(FUNC_LOGS) && logDelay > 0) { if (isFunctionActive(FUNCTION_LOGS) && logDelay > 0) {
tmr10ms_t tmr10ms = get_tmr10ms(); tmr10ms_t tmr10ms = get_tmr10ms();
if (lastLogTime == 0 || (tmr10ms_t)(tmr10ms - lastLogTime) >= (tmr10ms_t)logDelay*10) { if (lastLogTime == 0 || (tmr10ms_t)(tmr10ms - lastLogTime) >= (tmr10ms_t)logDelay*10) {
lastLogTime = tmr10ms; lastLogTime = tmr10ms;

View file

@ -120,7 +120,7 @@ void varioWakeup()
static tmr10ms_t s_varioTmr; static tmr10ms_t s_varioTmr;
tmr10ms_t tmr10ms = get_tmr10ms(); tmr10ms_t tmr10ms = get_tmr10ms();
if (isFunctionActive(FUNC_VARIO)) { if (isFunctionActive(FUNCTION_VARIO)) {
#if defined(AUDIO) #if defined(AUDIO)
cli(); cli();
int16_t verticalSpeed = frskyData.hub.varioSpeed; int16_t verticalSpeed = frskyData.hub.varioSpeed;

View file

@ -668,14 +668,42 @@ PACK( union u_int8int16_t {
#endif #endif
enum CswFunctions {
CS_OFF,
CS_VEQUAL, // v==offset
CS_VPOS, // v>offset
CS_VNEG, // v<offset
#if defined(CPUARM)
CS_RANGE,
#endif
CS_APOS, // |v|>offset
CS_ANEG, // |v|<offset
CS_AND,
CS_OR,
CS_XOR,
#if defined(CPUARM)
CS_STAY,
#endif
CS_EQUAL,
CS_GREATER,
CS_LESS,
CS_DIFFEGREATER,
CS_ADIFFEGREATER,
CS_TIMER,
CS_STICKY,
CS_COUNT,
CS_MAXF = CS_COUNT-1
};
#if defined(CPUARM) #if defined(CPUARM)
#define MAX_CSW_DURATION 120 /*60s*/ #define MAX_CSW_DURATION 120 /*60s*/
#define MAX_CSW_DELAY 120 /*60s*/ #define MAX_CSW_DELAY 120 /*60s*/
#define MAX_CSW_ANDSW NUM_SWITCH #define MAX_CSW_ANDSW SWSRC_LAST
typedef int16_t csw_telemetry_value_t; typedef int16_t csw_telemetry_value_t;
PACK(typedef struct t_CustomSwData { // Custom Switches data PACK(typedef struct t_CustomSwData { // Custom Switches data
int16_t v1; int8_t v1;
int16_t v2; int16_t v2;
int16_t v3;
uint8_t func; uint8_t func;
uint8_t delay; uint8_t delay;
uint8_t duration; uint8_t duration;
@ -693,57 +721,54 @@ PACK(typedef struct t_CustomSwData { // Custom Switches data
#endif #endif
enum Functions { enum Functions {
#if defined(CPUARM) // first the functions which need a checkbox
FUNC_SAFETY_CH1, FUNC_SAFETY_CHANNEL,
FUNC_SAFETY_CH16=FUNC_SAFETY_CH1+15,
#else
FUNC_SAFETY_GROUP1,
FUNC_SAFETY_GROUP2,
FUNC_SAFETY_GROUP3,
FUNC_SAFETY_GROUP4,
#endif
FUNC_TRAINER, FUNC_TRAINER,
FUNC_TRAINER_RUD,
FUNC_TRAINER_ELE,
FUNC_TRAINER_THR,
FUNC_TRAINER_AIL,
FUNC_INSTANT_TRIM, FUNC_INSTANT_TRIM,
FUNC_PLAY_SOUND,
#if !defined(PCBTARANIS)
FUNC_HAPTIC,
#endif
FUNC_RESET, FUNC_RESET,
FUNC_VARIO, FUNC_ADJUST_GVAR,
#if defined(CPUARM)
FUNC_VOLUME,
#endif
// then the other functions
FUNC_FIRST_WITHOUT_ENABLE,
FUNC_PLAY_SOUND = FUNC_FIRST_WITHOUT_ENABLE,
FUNC_PLAY_TRACK, FUNC_PLAY_TRACK,
#if !defined(CPUARM) #if !defined(CPUARM)
FUNC_PLAY_BOTH, FUNC_PLAY_BOTH,
#endif #endif
FUNC_PLAY_VALUE, FUNC_PLAY_VALUE,
#if !defined(PCBSTD)
FUNC_LOGS,
#endif
#if defined(CPUARM)
FUNC_VOLUME,
#endif
FUNC_BACKLIGHT,
#if defined(CPUARM) #if defined(CPUARM)
FUNC_BACKGND_MUSIC, FUNC_BACKGND_MUSIC,
FUNC_BACKGND_MUSIC_PAUSE, FUNC_BACKGND_MUSIC_PAUSE,
#endif #endif
#if defined(GVARS) FUNC_VARIO,
FUNC_ADJUST_GV1, FUNC_HAPTIC,
FUNC_ADJUST_GVLAST = (FUNC_ADJUST_GV1 + (MAX_GVARS-1)), #if !defined(PCBSTD)
FUNC_LOGS,
#endif #endif
FUNC_BACKLIGHT,
#if defined(DEBUG) #if defined(DEBUG)
FUNC_TEST, // should remain the last before MAX as not added in companion9x FUNC_TEST, // should remain the last before MAX as not added in companion9x
#endif #endif
FUNC_MAX FUNC_MAX
}; };
#if defined(GVARS) #define HAS_ENABLE_PARAM(func) (func < FUNC_FIRST_WITHOUT_ENABLE)
#define IS_ADJUST_GV_FUNCTION(sd) (CFN_FUNC(sd) >= FUNC_ADJUST_GV1 && CFN_FUNC(sd) <= FUNC_ADJUST_GVLAST)
#if defined(CPUARM)
#define IS_PLAY_BOTH_FUNC(func) (0)
#define IS_VOLUME_FUNC(func) (func == FUNC_VOLUME)
#else #else
#define IS_ADJUST_GV_FUNCTION(sd) (0) #define IS_PLAY_BOTH_FUNC(func) (func == FUNC_PLAY_BOTH)
#define IS_VOLUME_FUNC(func) (0)
#endif
#if defined(GVARS)
#define IS_ADJUST_GV_FUNC(func) (func == FUNC_ADJUST_GVAR)
#else
#define IS_ADJUST_GV_FUNC(func) (0)
#endif #endif
#if defined(VOICE) #if defined(VOICE)
@ -786,56 +811,68 @@ PACK(typedef struct t_CustomFnData { // Function Switches data
int8_t swtch; int8_t swtch;
uint8_t func; uint8_t func;
PACK(union { PACK(union {
char name[LEN_CFN_NAME]; struct {
char name[LEN_CFN_NAME];
} play;
struct { struct {
int16_t val; int16_t val;
int16_t ext1; uint8_t mode;
int16_t ext2; uint8_t param;
} composite; int16_t spare2;
}) param; } all;
uint8_t mode:2;
uint8_t active:6; struct {
int32_t val1;
int16_t val2;
} clear;
});
uint8_t active;
}) CustomFnData; }) CustomFnData;
#define CFN_EMPTY(p) (!(p)->swtch) #define CFN_EMPTY(p) (!(p)->swtch)
#define CFN_SWITCH(p) ((p)->swtch)
#define CFN_FUNC(p) ((p)->func) #define CFN_FUNC(p) ((p)->func)
#define CFN_ACTIVE(p) ((p)->active) #define CFN_ACTIVE(p) ((p)->active)
#define CFN_CH_NUMBER(p) (CFN_FUNC(p)) #define CFN_CH_NUMBER(p) ((p)->all.param)
#define CFN_PLAY_REPEAT(p) ((p)->active) #define CFN_PLAY_REPEAT(p) ((p)->active)
#define CFN_PLAY_REPEAT_MUL 1 #define CFN_PLAY_REPEAT_MUL 1
#define CFN_PLAY_REPEAT_NOSTART 0x3F #define CFN_PLAY_REPEAT_NOSTART 0x3F
#define CFN_GVAR_MODE(p) ((p)->mode) #define CFN_GVAR_NUMBER(p) ((p)->all.param)
#define CFN_PARAM(p) ((p)->param.composite.val) #define CFN_GVAR_MODE(p) ((p)->all.mode)
#define CFN_RESET(p) (p->active = 0, memset(&(p)->param, 0, sizeof((p)->param))) #define CFN_PARAM(p) ((p)->all.val)
#define CFN_RESET(p) ((p)->active=0, (p)->clear.val1=0, (p)->clear.val2=0)
#else #else
PACK(typedef struct t_CustomFnData { PACK(typedef struct t_CustomFnData {
int8_t swtch; // input PACK(union {
union {
struct { struct {
uint8_t param:3; int8_t swtch:6;
uint8_t func:5; uint16_t func:4;
} func_param; uint8_t mode:2;
uint8_t param:3;
uint8_t active:1;
} gvar;
struct { struct {
uint8_t active:1; int8_t swtch:6;
uint8_t param:2; uint16_t func:4;
uint8_t func:5; uint8_t param:4;
} func_param_enable; uint8_t spare:1;
uint8_t active:1;
} all;
});
struct { uint8_t value;
uint8_t active:1;
uint8_t func:7;
} func_safety;
} internal;
uint8_t param;
}) CustomFnData; }) CustomFnData;
#define CFN_FUNC(p) ((p)->internal.func_param.func) #define CFN_SWITCH(p) ((p)->all.swtch)
#define CFN_ACTIVE(p) ((p)->internal.func_param_enable.active) #define CFN_FUNC(p) ((p)->all.func)
#define CFN_CH_NUMBER(p) ((p)->internal.func_safety.func) #define CFN_ACTIVE(p) ((p)->all.active)
#define CFN_PLAY_REPEAT(p) ((p)->internal.func_param.param) #define CFN_CH_NUMBER(p) ((p)->all.param)
#define CFN_PLAY_REPEAT(p) ((p)->all.param)
#define CFN_PLAY_REPEAT_MUL 10 #define CFN_PLAY_REPEAT_MUL 10
#define CFN_GVAR_MODE(p) ((p)->internal.func_param_enable.param) #define CFN_GVAR_NUMBER(p) ((p)->gvar.param)
#define CFN_PARAM(p) ((p)->param) #define CFN_GVAR_MODE(p) ((p)->gvar.mode)
#define CFN_RESET(p) ((p)->internal.func_param_enable.active = 0, CFN_PARAM(p) = 0) #define CFN_PARAM(p) ((p)->value)
#define CFN_RESET(p) ((p)->all.active = 0, CFN_PARAM(p) = 0)
#endif #endif
enum TelemetryUnit { enum TelemetryUnit {
@ -1166,6 +1203,7 @@ enum SwitchSources {
SWSRC_SG2, SWSRC_SG2,
SWSRC_SH0, SWSRC_SH0,
SWSRC_SH2, SWSRC_SH2,
SWSRC_TRAINER = SWSRC_SH2,
#else #else
SWSRC_ID0 = SWSRC_FIRST_SWITCH, SWSRC_ID0 = SWSRC_FIRST_SWITCH,
SWSRC_ID1, SWSRC_ID1,
@ -1181,11 +1219,37 @@ enum SwitchSources {
SWSRC_AIL, SWSRC_AIL,
SWSRC_GEA, SWSRC_GEA,
SWSRC_TRN, SWSRC_TRN,
SWSRC_TRAINER = SWSRC_TRN,
#endif
SWSRC_LAST_SWITCH = SWSRC_TRAINER,
#if defined(PCBTARANIS)
SWSRC_P11,
SWSRC_P16 = SWSRC_P11+5,
SWSRC_P21,
SWSRC_P26 = SWSRC_P21+5,
#endif
SWSRC_FIRST_TRIM,
SWSRC_TrimRudLeft = SWSRC_FIRST_TRIM,
SWSRC_TrimRudRight,
SWSRC_TrimEleDown,
SWSRC_TrimEleUp,
SWSRC_TrimThrDown,
SWSRC_TrimThrUp,
SWSRC_TrimAilLeft,
SWSRC_TrimAilRight,
SWSRC_LAST_TRIM = SWSRC_TrimAilRight,
#if defined(PCBSKY9X)
SWSRC_REa,
#elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560)
SWSRC_REa,
SWSRC_REb,
#endif #endif
SWSRC_FIRST_CSW, SWSRC_FIRST_CSW,
SWSRC_LAST_SWITCH = SWSRC_FIRST_CSW-1,
SWSRC_SW1 = SWSRC_FIRST_CSW, SWSRC_SW1 = SWSRC_FIRST_CSW,
SWSRC_SW2, SWSRC_SW2,
SWSRC_SW3, SWSRC_SW3,
@ -1200,34 +1264,11 @@ enum SwitchSources {
SWSRC_SWC, SWSRC_SWC,
SWSRC_LAST_CSW = SWSRC_SW1+NUM_CSW-1, SWSRC_LAST_CSW = SWSRC_SW1+NUM_CSW-1,
#if defined(PCBTARANIS)
SWSRC_P11,
SWSRC_P16 = SWSRC_P11+5,
SWSRC_P21,
SWSRC_P26 = SWSRC_P21+5,
#endif
SWSRC_ON, SWSRC_ON,
SWSRC_FIRST_MOMENT_SWITCH,
SWSRC_LAST_MOMENT_SWITCH = SWSRC_FIRST_MOMENT_SWITCH+SWSRC_LAST_CSW,
#if !defined(PCBSTD)
SWSRC_TRAINER_SHORT,
SWSRC_TRAINER_LONG,
#endif
#if ROTARY_ENCODERS > 0
SWSRC_FIRST_ROTENC_SWITCH,
SWSRC_LAST_ROTENC_SWITCH = SWSRC_FIRST_ROTENC_SWITCH+(2*ROTARY_ENCODERS)-1,
#endif
SWSRC_COUNT,
SWSRC_FIRST = -SWSRC_LAST_MOMENT_SWITCH,
SWSRC_LAST = SWSRC_COUNT-1,
SWSRC_OFF = -SWSRC_ON, SWSRC_OFF = -SWSRC_ON,
SWSRC_TRAINER = SWSRC_SW1-1,
SWSRC_FIRST = SWSRC_OFF,
SWSRC_LAST = SWSRC_ON
}; };
enum MixSources { enum MixSources {

View file

@ -448,10 +448,23 @@ CustomSwData *cswAddress(uint8_t idx)
uint8_t cswFamily(uint8_t func) uint8_t cswFamily(uint8_t func)
{ {
return (func<CS_AND ? CS_VOFS : (func<CS_EQUAL ? CS_VBOOL : (func<CS_DIFFEGREATER ? CS_VCOMP : (func<CS_TIMER ? CS_VDIFF : CS_VTIMER)))); if (func <= CS_ANEG)
return CS_FAMILY_OFS;
else if (func <= CS_XOR)
return CS_FAMILY_BOOL;
#if defined(CPUARM)
else if (func == CS_STAY)
return CS_FAMILY_STAY;
#endif
else if (func <= CS_LESS)
return CS_FAMILY_COMP;
else if (func <= CS_ADIFFEGREATER)
return CS_FAMILY_DIFF;
else
return CS_FAMILY_TIMER+func-CS_TIMER;
} }
int16_t cswTimerValue(int8_t val) int16_t cswTimerValue(delayval_t val)
{ {
return (val < -109 ? 129+val : (val < 7 ? (113+val)*5 : (53+val)*10)); return (val < -109 ? 129+val : (val < 7 ? (113+val)*5 : (53+val)*10));
} }
@ -536,9 +549,6 @@ void applyDefaultTemplate()
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
mix->srcRaw = i+1; mix->srcRaw = i+1;
if (!isSourceAvailable(mix->srcRaw)) {
mix->srcRaw = MIXSRC_Rud - 1 + stick_index;
}
#else #else
mix->srcRaw = MIXSRC_Rud - 1 + channel_order(i+1); mix->srcRaw = MIXSRC_Rud - 1 + channel_order(i+1);
#endif #endif
@ -573,9 +583,9 @@ void modelDefault(uint8_t id)
g_model.frsky.channels[0].ratio = 132; g_model.frsky.channels[0].ratio = 132;
#endif #endif
#ifdef MAVLINK #if defined(MAVLINK)
g_model.mavlink.rc_rssi_scale = 15; g_model.mavlink.rc_rssi_scale = 15;
g_model.mavlink.pc_rssi_en = 1; g_model.mavlink.pc_rssi_en = 1;
#endif #endif
} }
@ -1343,7 +1353,6 @@ void getSwitchesPosition()
CHECK_2POS(SW_SH); CHECK_2POS(SW_SH);
switchesPos = newPos; switchesPos = newPos;
#if defined(PCBTARANIS)
for (int i=0; i<NUM_XPOTS; i++) { for (int i=0; i<NUM_XPOTS; i++) {
if (g_eeGeneral.potsType & (1 << i)) { if (g_eeGeneral.potsType & (1 << i)) {
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[POT1+i]; StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[POT1+i];
@ -1361,7 +1370,6 @@ void getSwitchesPosition()
} }
} }
} }
#endif
} }
#define SWITCH_POSITION(sw) (switchesPos & (1<<(sw))) #define SWITCH_POSITION(sw) (switchesPos & (1<<(sw)))
#define POT_POSITION(sw) ((potsPos[(sw)/POTS_POS_COUNT] & 0x0f) == ((sw) % POTS_POS_COUNT)) #define POT_POSITION(sw) ((potsPos[(sw)/POTS_POS_COUNT] & 0x0f) == ((sw) % POTS_POS_COUNT))
@ -1388,9 +1396,22 @@ bool getSwitch(int8_t swtch)
result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH); result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH);
} }
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
else if (cs_idx >= SWSRC_P11 && cs_idx <= SWSRC_P26) { else if (cs_idx <= SWSRC_P26) {
result = POT_POSITION(cs_idx-SWSRC_P11); result = POT_POSITION(cs_idx-SWSRC_P11);
} }
#endif
else if (cs_idx <= SWSRC_LAST_TRIM) {
result = trimDown(cs_idx-SWSRC_FIRST_TRIM);
}
#if ROTARY_ENCODERS > 0
else if (cs_idx == SWSRC_REa) {
result = REA_DOWN();
}
#endif
#if ROTARY_ENCODERS > 1
else if (cs_idx == SWSRC_REb) {
result = REB_DOWN();
}
#endif #endif
else { else {
cs_idx -= SWSRC_FIRST_CSW; cs_idx -= SWSRC_FIRST_CSW;
@ -1403,12 +1424,19 @@ bool getSwitch(int8_t swtch)
s_last_switch_used |= mask; s_last_switch_used |= mask;
CustomSwData * cs = cswAddress(cs_idx); CustomSwData * cs = cswAddress(cs_idx);
#if defined(CPUARM)
int8_t s = cs->andsw;
#else
uint8_t s = cs->andsw; uint8_t s = cs->andsw;
if (s > SWSRC_LAST_SWITCH) {
s += SWSRC_SW1-SWSRC_LAST_SWITCH-1;
}
#endif
if (cs->func == CS_OFF || (s && !getSwitch(s))) { if (cs->func == CS_OFF || (s && !getSwitch(s))) {
csLastValue[cs_idx] = CS_LAST_VALUE_INIT; csLastValue[cs_idx] = CS_LAST_VALUE_INIT;
result = false; result = false;
} }
else if ((s=cswFamily(cs->func)) == CS_VBOOL) { else if ((s=cswFamily(cs->func)) == CS_FAMILY_BOOL) {
bool res1 = getSwitch(cs->v1); bool res1 = getSwitch(cs->v1);
bool res2 = getSwitch(cs->v2); bool res2 = getSwitch(cs->v2);
switch (cs->func) { switch (cs->func) {
@ -1424,13 +1452,21 @@ bool getSwitch(int8_t swtch)
break; break;
} }
} }
else if (s == CS_VTIMER) { else if (s == CS_FAMILY_TIMER) {
result = csLastValue[cs_idx] <= 0; result = (csLastValue[cs_idx] <= 0);
} }
else if (s == CS_FAMILY_STICKY) {
result = (csLastValue[cs_idx] & (1<<0));
}
#if defined(CPUARM)
else if (s == CS_FAMILY_STAY) {
result = (csLastValue[cs_idx] & (1<<0));
}
#endif
else { else {
getvalue_t x = getValue(cs->v1); getvalue_t x = getValue(cs->v1);
getvalue_t y; getvalue_t y;
if (s == CS_VCOMP) { if (s == CS_FAMILY_COMP) {
y = getValue(cs->v2); y = getValue(cs->v2);
switch (cs->func) { switch (cs->func) {
@ -1455,7 +1491,7 @@ bool getSwitch(int8_t swtch)
y = convertCswTelemValue(cs); y = convertCswTelemValue(cs);
#if defined(FRSKY_HUB) && defined(GAUGES) #if defined(FRSKY_HUB) && defined(GAUGES)
if (s == CS_VOFS) { if (s == CS_FAMILY_OFS) {
uint8_t idx = cs->v1-MIXSRC_FIRST_TELEM+1-TELEM_ALT; uint8_t idx = cs->v1-MIXSRC_FIRST_TELEM+1-TELEM_ALT;
if (idx < THLD_MAX) { if (idx < THLD_MAX) {
// Fill the threshold array // Fill the threshold array
@ -1530,15 +1566,20 @@ bool getSwitch(int8_t swtch)
cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*50); cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*50);
} }
} }
if (cs->duration) { if (cs->duration) {
if (result && !cswStates[cs_idx]) if (result && !cswStates[cs_idx]) {
cswDurations[cs_idx] = get_tmr10ms() + (cs->duration*50); cswDurations[cs_idx] = get_tmr10ms() + (cs->duration*50);
}
cswStates[cs_idx] = result; cswStates[cs_idx] = result;
result = false;
if (cswDurations[cs_idx] > get_tmr10ms()) { if (cswDurations[cs_idx] > get_tmr10ms()) {
result = true; result = true;
if (cs->delay) cswDelays[cs_idx] = get_tmr10ms() + (cs->delay*50); }
else if (s == CS_FAMILY_STICKY) {
csLastValue[cs_idx] &= ~(1<<0);
} }
} }
#endif #endif
@ -2002,7 +2043,7 @@ getvalue_t convertCswTelemValue(CustomSwData * cs)
#if defined(CPUARM) #if defined(CPUARM)
val = convert16bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, cs->v2); val = convert16bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, cs->v2);
#else #else
if (cswFamily(cs->func)==CS_VOFS) if (cswFamily(cs->func)==CS_FAMILY_OFS)
val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2); val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2);
else else
val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2) - convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128); val = convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128+cs->v2) - convert8bitsTelemValue(cs->v1 - MIXSRC_FIRST_TELEM + 1, 128);
@ -2075,7 +2116,7 @@ void checkBacklight()
backlightOn(); backlightOn();
} }
bool backlightOn = (g_eeGeneral.backlightMode == e_backlight_mode_on || lightOffCounter || isFunctionActive(FUNC_BACKLIGHT)); bool backlightOn = (g_eeGeneral.backlightMode == e_backlight_mode_on || lightOffCounter || isFunctionActive(FUNCTION_BACKLIGHT));
if (flashCounter) backlightOn = !backlightOn; if (flashCounter) backlightOn = !backlightOn;
if (backlightOn) if (backlightOn)
BACKLIGHT_ON(); BACKLIGHT_ON();
@ -2893,7 +2934,7 @@ void evalInputs(uint8_t mode)
} }
if (ch < NUM_STICKS) { //only do this for sticks if (ch < NUM_STICKS) { //only do this for sticks
if (mode <= e_perout_mode_inactive_phase && (isFunctionActive(FUNC_TRAINER) || isFunctionActive(FUNC_TRAINER_RUD+ch))) { if (mode <= e_perout_mode_inactive_phase && isFunctionActive(FUNCTION_TRAINER+ch)) {
// trainer mode // trainer mode
TrainerMix* td = &g_eeGeneral.trainer.mix[ch]; TrainerMix* td = &g_eeGeneral.trainer.mix[ch];
if (td->mode) { if (td->mode) {
@ -2951,7 +2992,6 @@ void testFunc()
#endif #endif
MASK_FUNC_TYPE activeFunctions = 0; MASK_FUNC_TYPE activeFunctions = 0;
MASK_CFN_TYPE activeSwitches = 0;
MASK_CFN_TYPE activeFnSwitches = 0; MASK_CFN_TYPE activeFnSwitches = 0;
tmr10ms_t lastFunctionTime[NUM_CFN] = { 0 }; tmr10ms_t lastFunctionTime[NUM_CFN] = { 0 };
@ -3096,10 +3136,10 @@ uint8_t fnSwitchDuration[NUM_CFN] = { 0 };
inline void playCustomFunctionFile(CustomFnData *sd, uint8_t id) inline void playCustomFunctionFile(CustomFnData *sd, uint8_t id)
{ {
char filename[sizeof(SOUNDS_PATH)+sizeof(sd->param.name)+sizeof(SOUNDS_EXT)] = SOUNDS_PATH "/"; char filename[sizeof(SOUNDS_PATH)+sizeof(sd->play.name)+sizeof(SOUNDS_EXT)] = SOUNDS_PATH "/";
strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); strncpy(filename+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2);
strncpy(filename+sizeof(SOUNDS_PATH), sd->param.name, sizeof(sd->param.name)); strncpy(filename+sizeof(SOUNDS_PATH), sd->play.name, sizeof(sd->play.name));
filename[sizeof(SOUNDS_PATH)+sizeof(sd->param.name)] = '\0'; filename[sizeof(SOUNDS_PATH)+sizeof(sd->play.name)] = '\0';
strcat(filename+sizeof(SOUNDS_PATH), SOUNDS_EXT); strcat(filename+sizeof(SOUNDS_PATH), SOUNDS_EXT);
PLAY_FILE(filename, sd->func==FUNC_BACKGND_MUSIC ? PLAY_BACKGROUND : 0, id); PLAY_FILE(filename, sd->func==FUNC_BACKGND_MUSIC ? PLAY_BACKGROUND : 0, id);
} }
@ -3112,300 +3152,240 @@ bool evalFunctionsFirstTime = true;
void evalFunctions() void evalFunctions()
{ {
MASK_FUNC_TYPE newActiveFunctions = 0; MASK_FUNC_TYPE newActiveFunctions = 0;
MASK_CFN_TYPE newActiveSwitches = 0;
MASK_CFN_TYPE newActiveFnSwitches = 0; MASK_CFN_TYPE newActiveFnSwitches = 0;
#if defined(ROTARY_ENCODERS) && defined(GVARS) #if defined(ROTARY_ENCODERS) && defined(GVARS)
static rotenc_t rePreviousValues[ROTARY_ENCODERS]; static rotenc_t rePreviousValues[ROTARY_ENCODERS];
#endif #endif
for (uint8_t i=0; i<NUM_CHNOUT; i++) for (uint8_t i=0; i<NUM_CHNOUT; i++) {
safetyCh[i] = -128; // not defined safetyCh[i] = -128; // not defined
}
#if defined(GVARS) #if defined(GVARS)
for (uint8_t i=0; i<4; i++) for (uint8_t i=0; i<NUM_STICKS; i++) {
trimGvar[i] = -1; trimGvar[i] = -1;
#endif }
#if !defined(PCBSTD)
uint8_t mSwitchDurationIncremented = 0;
#endif #endif
for (uint8_t i=0; i<NUM_CFN; i++) { for (uint8_t i=0; i<NUM_CFN; i++) {
CustomFnData *sd = &g_model.funcSw[i]; CustomFnData *sd = &g_model.funcSw[i];
int8_t swtch = sd->swtch; int8_t swtch = CFN_SWITCH(sd);
if (swtch) { if (swtch) {
MASK_FUNC_TYPE function_mask = (CFN_FUNC(sd) >= FUNC_TRAINER ? ((MASK_FUNC_TYPE)1 << (CFN_FUNC(sd)-FUNC_TRAINER)) : 0);
MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i); MASK_CFN_TYPE switch_mask = ((MASK_CFN_TYPE)1 << i);
uint8_t momentary = 0;
#if !defined(PCBSTD)
#define MOMENTARY_START_TEST() ( (momentary && !(activeSwitches & switch_mask) && active) || \
(short_long==1 && !active && mSwitchDuration[mswitch]>0 && mSwitchDuration[mswitch]<CFN_PRESSLONG_DURATION) || \
(short_long==2 && active && mSwitchDuration[mswitch]==CFN_PRESSLONG_DURATION) )
uint8_t short_long = 0;
uint8_t mswitch = 0;
if (swtch == SWSRC_TRAINER_LONG) {
short_long = 2;
swtch = SWSRC_TRAINER;
mswitch = 0;
}
else if (swtch == SWSRC_TRAINER_SHORT) {
short_long = 1;
swtch = SWSRC_TRAINER;
mswitch = 0;
}
else
#else
#define short_long 0
#define MOMENTARY_START_TEST() (!(activeSwitches & switch_mask) && active)
#endif
if (swtch > NUM_SWITCH+1) {
momentary = 1;
swtch -= NUM_SWITCH+1;
}
if (swtch < -NUM_SWITCH-1) {
momentary = 1;
swtch += NUM_SWITCH+1;
}
bool active = getSwitch(swtch); bool active = getSwitch(swtch);
if (active) newActiveSwitches |= switch_mask;
if (momentary || short_long) {
#if !defined(PCBSTD) if (HAS_ENABLE_PARAM(CFN_FUNC(sd))) {
bool swState = active; active &= CFN_ACTIVE(sd);
#endif
if (MOMENTARY_START_TEST()) {
if (short_long) {
active = false;
momentary = true;
}
else {
active = !(activeFnSwitches & switch_mask);
#if !defined(CPUARM)
if (CFN_FUNC(sd) == FUNC_PLAY_BOTH && !active) {
momentary = true;
}
else
#endif
{
momentary = false;
}
}
}
else if (swtch == SWSRC_ON) {
active = false;
momentary = false;
}
else {
active = (activeFnSwitches & switch_mask);
momentary = false;
}
#if !defined(PCBSTD)
if (short_long && !(mSwitchDurationIncremented & (1<<mswitch))) {
mSwitchDurationIncremented |= (1<<mswitch);
if (swState) {
if (mSwitchDuration[mswitch] < 255)
mSwitchDuration[mswitch]++;
}
else {
mSwitchDuration[mswitch] = 0;
}
}
#endif
} }
#if !defined(CPUARM)
else if (CFN_FUNC(sd) == FUNC_PLAY_BOTH) {
momentary = true;
}
#endif
if (active || momentary) { if (active || IS_PLAY_BOTH_FUNC(CFN_FUNC(sd))) {
if (CFN_ACTIVE(sd)) { switch(CFN_FUNC(sd)) {
if (CFN_FUNC(sd) < FUNC_TRAINER) {
case FUNC_SAFETY_CHANNEL:
safetyCh[CFN_CH_NUMBER(sd)] = CFN_PARAM(sd); safetyCh[CFN_CH_NUMBER(sd)] = CFN_PARAM(sd);
break;
case FUNC_TRAINER:
{
uint8_t mask = 0x0f;
if (CFN_CH_NUMBER(sd) > 0) {
mask = (1<<(CFN_CH_NUMBER(sd)-1));
}
newActiveFunctions |= mask;
break;
} }
if (!(activeFunctions & function_mask)) { case FUNC_INSTANT_TRIM:
if (CFN_FUNC(sd) == FUNC_INSTANT_TRIM) { if (!isFunctionActive(FUNCTION_INSTANT_TRIM)) {
newActiveFunctions |= (1 << FUNCTION_INSTANT_TRIM);
if (g_menuStack[0] == menuMainView if (g_menuStack[0] == menuMainView
#if defined(FRSKY) #if defined(FRSKY)
|| g_menuStack[0] == menuTelemetryFrsky || g_menuStack[0] == menuTelemetryFrsky
#endif #endif
) )
instantTrim(); instantTrim();
} }
} break;
}
else if (CFN_FUNC(sd) <= FUNC_INSTANT_TRIM || CFN_FUNC(sd) == FUNC_RESET) {
active = false;
}
if (CFN_FUNC(sd) == FUNC_RESET) { case FUNC_RESET:
switch (CFN_PARAM(sd)) { switch (CFN_PARAM(sd)) {
case FUNC_RESET_TIMER1: case FUNC_RESET_TIMER1:
case FUNC_RESET_TIMER2: case FUNC_RESET_TIMER2:
resetTimer(CFN_PARAM(sd)); resetTimer(CFN_PARAM(sd));
break; break;
case FUNC_RESET_ALL: case FUNC_RESET_ALL:
resetAll(); resetAll();
break; break;
#if defined(FRSKY) #if defined(FRSKY)
case FUNC_RESET_TELEMETRY: case FUNC_RESET_TELEMETRY:
resetTelemetry(); resetTelemetry();
break; break;
#endif #endif
#if ROTARY_ENCODERS > 0 #if ROTARY_ENCODERS > 0
case FUNC_RESET_ROTENC1: case FUNC_RESET_ROTENC1:
#if ROTARY_ENCODERS > 1 #if ROTARY_ENCODERS > 1
case FUNC_RESET_ROTENC2: case FUNC_RESET_ROTENC2:
#endif #endif
g_rotenc[CFN_PARAM(sd)-FUNC_RESET_ROTENC1] = 0; g_rotenc[CFN_PARAM(sd)-FUNC_RESET_ROTENC1] = 0;
break; break;
#endif #endif
}
}
#if defined(SDCARD)
else if (CFN_FUNC(sd) == FUNC_LOGS) {
logDelay = CFN_PARAM(sd);
}
#endif
#if defined(HAPTIC)
else if (CFN_FUNC(sd) == FUNC_HAPTIC) {
haptic.event(AU_FRSKY_LAST+CFN_PARAM(sd));
}
#endif
#if defined(CPUARM) && defined(SDCARD)
else if (CFN_FUNC(sd) == FUNC_PLAY_SOUND || CFN_FUNC(sd) == FUNC_PLAY_TRACK || CFN_FUNC(sd) == FUNC_PLAY_VALUE) {
tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t repeatParam = CFN_PLAY_REPEAT(sd);
if (evalFunctionsFirstTime && repeatParam == CFN_PLAY_REPEAT_NOSTART)
lastFunctionTime[i] = tmr10ms;
if (!lastFunctionTime[i] || (repeatParam && repeatParam!=CFN_PLAY_REPEAT_NOSTART && (signed)(tmr10ms-lastFunctionTime[i])>=100*repeatParam)) {
if (!IS_PLAYING(i+1)) {
lastFunctionTime[i] = tmr10ms;
if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) {
AUDIO_PLAY(AU_FRSKY_FIRST+CFN_PARAM(sd));
}
else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) {
PLAY_VALUE(CFN_PARAM(sd), i+1);
}
else {
playCustomFunctionFile(sd, i+1);
}
} }
} break;
}
else if (CFN_FUNC(sd) == FUNC_BACKGND_MUSIC) {
if (!IS_PLAYING(i+1)) {
playCustomFunctionFile(sd, i+1);
}
}
else if (CFN_FUNC(sd) == FUNC_VOLUME) {
if (CFN_ACTIVE(sd)) {
getvalue_t raw = getValue(CFN_PARAM(sd));
//only set volume if input changed more than hysteresis
if (abs(requiredSpeakerVolumeRawLast - raw) > VOLUME_HYSTERESIS) {
requiredSpeakerVolumeRawLast = raw;
}
requiredSpeakerVolume = ((1024 + requiredSpeakerVolumeRawLast) * VOLUME_LEVEL_MAX) / 2048;
}
else {
active = false;
}
}
#elif defined(VOICE)
else if (CFN_FUNC(sd) == FUNC_PLAY_SOUND || CFN_FUNC(sd) == FUNC_PLAY_TRACK || CFN_FUNC(sd) == FUNC_PLAY_BOTH || CFN_FUNC(sd) == FUNC_PLAY_VALUE) {
tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t repeatParam = CFN_PLAY_REPEAT(sd);
if (!lastFunctionTime[i] || (CFN_FUNC(sd)==FUNC_PLAY_BOTH && active!=(bool)(activeFnSwitches&switch_mask)) || (repeatParam && (signed)(tmr10ms-lastFunctionTime[i])>=1000*repeatParam)) {
lastFunctionTime[i] = tmr10ms;
uint8_t param = CFN_PARAM(sd);
if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) {
AUDIO_PLAY(AU_FRSKY_FIRST+param);
}
else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) {
PLAY_VALUE(param, i+1);
}
else {
#if defined(GVARS)
if (CFN_FUNC(sd) == FUNC_PLAY_TRACK && param > 250)
param = GVAR_VALUE(param-251, getGVarFlightPhase(s_perout_flight_phase, param-251));
#endif
PUSH_CUSTOM_PROMPT(active ? param : param+1, i+1);
}
}
}
#else
else if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) {
tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t repeatParam = CFN_PLAY_REPEAT(sd);
if (!lastFunctionTime[i] || (repeatParam && (signed)(tmr10ms-lastFunctionTime[i])>=1000*repeatParam)) {
lastFunctionTime[i] = tmr10ms;
AUDIO_PLAY(AU_FRSKY_FIRST+CFN_PARAM(sd));
}
}
#endif
#if defined(DEBUG)
else if (CFN_FUNC(sd) == FUNC_TEST) {
testFunc();
}
#endif
#if defined(GVARS) #if defined(GVARS)
else if (CFN_FUNC(sd) >= FUNC_ADJUST_GV1) { case FUNC_ADJUST_GVAR:
if (CFN_ACTIVE(sd)) {
if (CFN_GVAR_MODE(sd) == 0) { if (CFN_GVAR_MODE(sd) == 0) {
SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, CFN_PARAM(sd), s_perout_flight_phase); SET_GVAR(CFN_GVAR_NUMBER(sd), CFN_PARAM(sd), s_perout_flight_phase);
} }
else if (CFN_GVAR_MODE(sd) == 2) { else if (CFN_GVAR_MODE(sd) == 2) {
SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, GVAR_VALUE(CFN_PARAM(sd), s_perout_flight_phase), s_perout_flight_phase); SET_GVAR(CFN_GVAR_NUMBER(sd), GVAR_VALUE(CFN_PARAM(sd), s_perout_flight_phase), s_perout_flight_phase);
} }
else if (CFN_GVAR_MODE(sd) == 3) { else if (CFN_GVAR_MODE(sd) == 3) {
if (!(activeFnSwitches & switch_mask)) { if (!(activeFnSwitches & switch_mask)) {
SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, GVAR_VALUE(CFN_FUNC(sd)-FUNC_ADJUST_GV1, getGVarFlightPhase(s_perout_flight_phase, CFN_FUNC(sd)-FUNC_ADJUST_GV1)) + (CFN_PARAM(sd) ? +1 : -1), s_perout_flight_phase); SET_GVAR(CFN_GVAR_NUMBER(sd), GVAR_VALUE(CFN_GVAR_NUMBER(sd), getGVarFlightPhase(s_perout_flight_phase, CFN_GVAR_NUMBER(sd))) + (CFN_PARAM(sd) ? +1 : -1), s_perout_flight_phase);
} }
} }
else if (CFN_PARAM(sd) >= MIXSRC_TrimRud && CFN_PARAM(sd) <= MIXSRC_TrimAil) { else if (CFN_PARAM(sd) >= MIXSRC_TrimRud && CFN_PARAM(sd) <= MIXSRC_TrimAil) {
trimGvar[CFN_PARAM(sd)-MIXSRC_TrimRud] = CFN_FUNC(sd)-FUNC_ADJUST_GV1; trimGvar[CFN_PARAM(sd)-MIXSRC_TrimRud] = CFN_GVAR_NUMBER(sd);
} }
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)
else if (CFN_PARAM(sd) >= MIXSRC_REa && CFN_PARAM(sd) < MIXSRC_TrimRud) { else if (CFN_PARAM(sd) >= MIXSRC_REa && CFN_PARAM(sd) < MIXSRC_TrimRud) {
int8_t scroll = rePreviousValues[CFN_PARAM(sd)-MIXSRC_REa] - (g_rotenc[CFN_PARAM(sd)-MIXSRC_REa] / ROTARY_ENCODER_GRANULARITY); int8_t scroll = rePreviousValues[CFN_PARAM(sd)-MIXSRC_REa] - (g_rotenc[CFN_PARAM(sd)-MIXSRC_REa] / ROTARY_ENCODER_GRANULARITY);
if (scroll) { if (scroll) {
SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, GVAR_VALUE(CFN_FUNC(sd)-FUNC_ADJUST_GV1, getGVarFlightPhase(s_perout_flight_phase, CFN_FUNC(sd)-FUNC_ADJUST_GV1)) + scroll, s_perout_flight_phase); SET_GVAR(CFN_GVAR_NUMBER(sd), GVAR_VALUE(CFN_GVAR_NUMBER(sd), getGVarFlightPhase(s_perout_flight_phase, CFN_GVAR_NUMBER(sd))) + scroll, s_perout_flight_phase);
} }
} }
#endif #endif
else { else {
SET_GVAR(CFN_FUNC(sd)-FUNC_ADJUST_GV1, limit((getvalue_t)-1250, getValue(CFN_PARAM(sd)), (getvalue_t)1250) / 10, s_perout_flight_phase); SET_GVAR(CFN_GVAR_NUMBER(sd), limit((getvalue_t)-1250, getValue(CFN_PARAM(sd)), (getvalue_t)1250) / 10, s_perout_flight_phase);
} }
} break;
else {
active = false;
}
}
#endif #endif
if (active) { #if defined(CPUARM) && defined(SDCARD)
newActiveFnSwitches |= switch_mask; case FUNC_VOLUME:
newActiveFunctions |= function_mask; {
getvalue_t raw = getValue(CFN_PARAM(sd));
//only set volume if input changed more than hysteresis
if (abs(requiredSpeakerVolumeRawLast - raw) > VOLUME_HYSTERESIS) {
requiredSpeakerVolumeRawLast = raw;
}
requiredSpeakerVolume = ((1024 + requiredSpeakerVolumeRawLast) * VOLUME_LEVEL_MAX) / 2048;
break;
}
#endif
#if defined(CPUARM) && defined(SDCARD)
case FUNC_PLAY_SOUND:
case FUNC_PLAY_TRACK:
case FUNC_PLAY_VALUE:
{
tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t repeatParam = CFN_PLAY_REPEAT(sd);
if (evalFunctionsFirstTime && repeatParam == CFN_PLAY_REPEAT_NOSTART)
lastFunctionTime[i] = tmr10ms;
if (!lastFunctionTime[i] || (repeatParam && repeatParam!=CFN_PLAY_REPEAT_NOSTART && (signed)(tmr10ms-lastFunctionTime[i])>=100*repeatParam)) {
if (!IS_PLAYING(i+1)) {
lastFunctionTime[i] = tmr10ms;
if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) {
AUDIO_PLAY(AU_FRSKY_FIRST+CFN_PARAM(sd));
}
else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) {
PLAY_VALUE(CFN_PARAM(sd), i+1);
}
else {
playCustomFunctionFile(sd, i+1);
}
}
}
break;
}
case FUNC_BACKGND_MUSIC:
newActiveFunctions |= (1 << FUNCTION_BACKGND_MUSIC);
if (!IS_PLAYING(i+1)) {
playCustomFunctionFile(sd, i+1);
}
break;
case FUNC_BACKGND_MUSIC_PAUSE:
newActiveFunctions |= (1 << FUNCTION_BACKGND_MUSIC_PAUSE);
break;
#elif defined(VOICE)
case FUNC_PLAY_SOUND:
case FUNC_PLAY_TRACK:
case FUNC_PLAY_BOTH:
case FUNC_PLAY_VALUE:
{
tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t repeatParam = CFN_PLAY_REPEAT(sd);
if (!lastFunctionTime[i] || (CFN_FUNC(sd)==FUNC_PLAY_BOTH && active!=(bool)(activeFnSwitches&switch_mask)) || (repeatParam && (signed)(tmr10ms-lastFunctionTime[i])>=1000*repeatParam)) {
lastFunctionTime[i] = tmr10ms;
uint8_t param = CFN_PARAM(sd);
if (CFN_FUNC(sd) == FUNC_PLAY_SOUND) {
AUDIO_PLAY(AU_FRSKY_FIRST+param);
}
else if (CFN_FUNC(sd) == FUNC_PLAY_VALUE) {
PLAY_VALUE(param, i+1);
}
else {
#if defined(GVARS)
if (CFN_FUNC(sd) == FUNC_PLAY_TRACK && param > 250)
param = GVAR_VALUE(param-251, getGVarFlightPhase(s_perout_flight_phase, param-251));
#endif
PUSH_CUSTOM_PROMPT(active ? param : param+1, i+1);
}
}
break;
}
#else
case FUNC_PLAY_SOUND:
{
tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t repeatParam = CFN_PLAY_REPEAT(sd);
if (!lastFunctionTime[i] || (repeatParam && (signed)(tmr10ms-lastFunctionTime[i])>=1000*repeatParam)) {
lastFunctionTime[i] = tmr10ms;
AUDIO_PLAY(AU_FRSKY_FIRST+CFN_PARAM(sd));
}
break;
}
#endif
#if defined(FRSKY) && defined(VARIO)
case FUNC_VARIO:
newActiveFunctions |= (1 << FUNCTION_VARIO);
break;
#endif
#if defined(HAPTIC)
case FUNC_HAPTIC:
haptic.event(AU_FRSKY_LAST+CFN_PARAM(sd));
break;
#endif
#if defined(SDCARD)
case FUNC_LOGS:
newActiveFunctions |= (1 << FUNCTION_LOGS);
logDelay = CFN_PARAM(sd);
break;
#endif
case FUNC_BACKLIGHT:
newActiveFunctions |= (1 << FUNCTION_BACKLIGHT);
break;
#if defined(DEBUG)
case FUNC_TEST:
testFunc();
break;
#endif
} }
newActiveFnSwitches |= switch_mask;
} }
else { else {
lastFunctionTime[i] = 0; lastFunctionTime[i] = 0;
@ -3413,7 +3393,7 @@ void evalFunctions()
fnSwitchDuration[i] = 0; fnSwitchDuration[i] = 0;
#endif #endif
#if defined(CPUARM) && defined(SDCARD) #if defined(CPUARM) && defined(SDCARD)
if (CFN_FUNC(sd) == FUNC_BACKGND_MUSIC && isFunctionActive(FUNC_BACKGND_MUSIC)) { if (CFN_FUNC(sd) == FUNC_BACKGND_MUSIC && isFunctionActive(FUNCTION_BACKGND_MUSIC)) {
STOP_PLAY(i+1); STOP_PLAY(i+1);
} }
#endif #endif
@ -3421,13 +3401,13 @@ void evalFunctions()
} }
} }
activeSwitches = newActiveSwitches;
activeFnSwitches = newActiveFnSwitches; activeFnSwitches = newActiveFnSwitches;
activeFunctions = newActiveFunctions; activeFunctions = newActiveFunctions;
#if defined(ROTARY_ENCODERS) && defined(GVARS) #if defined(ROTARY_ENCODERS) && defined(GVARS)
for (uint8_t i=0; i<ROTARY_ENCODERS; i++) for (uint8_t i=0; i<ROTARY_ENCODERS; i++) {
rePreviousValues[i] = (g_rotenc[i] / ROTARY_ENCODER_GRANULARITY); rePreviousValues[i] = (g_rotenc[i] / ROTARY_ENCODER_GRANULARITY);
}
#endif #endif
#if defined(CPUARM) #if defined(CPUARM)
@ -3513,8 +3493,6 @@ void perOut(uint8_t mode, uint8_t tick10ms)
do { do {
// TRACE("[pass %d]", pass);
bitfield_channels_t passDirtyChannels = 0; bitfield_channels_t passDirtyChannels = 0;
for (uint8_t i=0; i<MAX_MIXERS; i++) { for (uint8_t i=0; i<MAX_MIXERS; i++) {
@ -3985,34 +3963,25 @@ void doMixerCalculations()
timerState->sum = 0; timerState->sum = 0;
} }
uint8_t atm = (tm >= 0 ? tm : TMR_VAROFS-tm-1);
// value for time described in timer->mode // value for time described in timer->mode
// OFFABSTHsTH%THt // OFFABSTHsTH%THt
if (atm == TMRMODE_THR_REL) { if (tm == TMRMODE_THR_REL) {
timerState->cnt++; timerState->cnt++;
timerState->sum+=val; timerState->sum+=val;
} }
if (atm>=(TMR_VAROFS+NUM_SWITCH)){ // toggeled switch
if(!(timerState->toggled | timerState->sum | timerState->cnt | timerState->lastPos)) { timerState->lastPos = tm < 0; timerState->sum = 1; } // if initializing then init the lastPos
uint8_t swPos = getSwitch(tm>0 ? tm-(TMR_VAROFS+NUM_SWITCH-1) : tm+NUM_SWITCH);
if (swPos && !timerState->lastPos) timerState->toggled = !timerState->toggled; // if switch is flipped first time -> change counter state
timerState->lastPos = swPos;
}
if ((timerState->val_10ms += tick10ms) >= 100) { if ((timerState->val_10ms += tick10ms) >= 100) {
timerState->val_10ms -= 100 ; timerState->val_10ms -= 100 ;
int16_t newTimerVal = timerState->val; int16_t newTimerVal = timerState->val;
if (tv) newTimerVal = tv - newTimerVal; if (tv) newTimerVal = tv - newTimerVal;
if (atm==TMRMODE_ABS) { if (tm == TMRMODE_ABS) {
newTimerVal++; newTimerVal++;
} }
else if (atm==TMRMODE_THR) { else if (tm == TMRMODE_THR) {
if (val) newTimerVal++; if (val) newTimerVal++;
} }
else if (atm==TMRMODE_THR_REL) { else if (tm == TMRMODE_THR_REL) {
// @@@ open.20.fsguruh: why so complicated? we have already a s_sum field; use it for the half seconds (not showable) as well // @@@ open.20.fsguruh: why so complicated? we have already a s_sum field; use it for the half seconds (not showable) as well
// check for s_cnt[i]==0 is not needed because we are shure it is at least 1 // check for s_cnt[i]==0 is not needed because we are shure it is at least 1
#if defined(ACCURAT_THROTTLE_TIMER) #if defined(ACCURAT_THROTTLE_TIMER)
@ -4028,19 +3997,17 @@ void doMixerCalculations()
#endif #endif
timerState->cnt=0; timerState->cnt=0;
} }
else if (atm==TMRMODE_THR_TRG) { else if (tm == TMRMODE_THR_TRG) {
if (val || newTimerVal > 0) if (val || newTimerVal > 0)
newTimerVal++; newTimerVal++;
} }
else { else {
if (atm<(TMR_VAROFS+NUM_SWITCH)) if (tm > 0) tm -= (TMR_VAROFS-1);
timerState->toggled = tm>0 ? getSwitch(tm-(TMR_VAROFS-1)) : !getSwitch(-tm); // normal switch if (getSwitch(tm))
if (timerState->toggled)
newTimerVal++; newTimerVal++;
} }
switch(timerState->state) switch (timerState->state) {
{
case TMR_RUNNING: case TMR_RUNNING:
if (tv && newTimerVal>=(int16_t)tv) { if (tv && newTimerVal>=(int16_t)tv) {
AUDIO_TIMER_00(g_model.timers[i].countdownBeep); AUDIO_TIMER_00(g_model.timers[i].countdownBeep);
@ -4098,6 +4065,55 @@ void doMixerCalculations()
*lastValue -= 1; *lastValue -= 1;
} }
} }
else if (cs->func == CS_STICKY) {
PACK(typedef struct {
bool state;
bool last;
}) cs_sticky_struct;
cs_sticky_struct & lastValue = (cs_sticky_struct &)csLastValue[i];
bool before = lastValue.last & 0x01;
if (lastValue.state) {
bool now = getSwitch(cs->v2);
if (now != before) {
lastValue.last ^= true;
if (!before) {
lastValue.state = false;
}
}
}
else {
bool now = getSwitch(cs->v1);
if (before != now) {
lastValue.last ^= true;
if (!before) {
lastValue.state = true;
}
}
}
}
#if defined(CPUARM)
else if (cs->func == CS_STAY) {
PACK(typedef struct {
uint8_t state:1;
uint16_t duration:15;
}) cs_stay_struct;
cs_stay_struct & lastValue = (cs_stay_struct &)csLastValue[i];
lastValue.state = false;
bool state = getSwitch(cs->v1);
if (state) {
if (cs->v3 == 0 && lastValue.duration == cswTimerValue(cs->v2))
lastValue.state = true;
if (lastValue.duration < 1000)
lastValue.duration++;
}
else {
if (lastValue.duration > cswTimerValue(cs->v2) && lastValue.duration <= cswTimerValue(cs->v2+cs->v3))
lastValue.state = true;
lastValue.duration = 0;
}
}
#endif
} }
if (s_cnt_1s >= 10) { // 1sec if (s_cnt_1s >= 10) { // 1sec
@ -4267,7 +4283,7 @@ void opentxClose()
hapticOff(); hapticOff();
#endif #endif
#if defined(CPUARM) #if defined(CPUARM) && defined(FRSKY)
if((g_model.frsky.mAhPersistent) && (g_model.frsky.storedMah != frskyData.hub.currentConsumption)) { if((g_model.frsky.mAhPersistent) && (g_model.frsky.storedMah != frskyData.hub.currentConsumption)) {
g_model.frsky.storedMah = frskyData.hub.currentConsumption; g_model.frsky.storedMah = frskyData.hub.currentConsumption;
eeDirty(EE_MODEL); eeDirty(EE_MODEL);

View file

@ -397,7 +397,6 @@ enum EnumKeys {
#define NUM_PSWITCH (SWSRC_LAST_SWITCH-SWSRC_FIRST_SWITCH+1) #define NUM_PSWITCH (SWSRC_LAST_SWITCH-SWSRC_FIRST_SWITCH+1)
#define NUM_POTSSW (NUM_XPOTS*6) #define NUM_POTSSW (NUM_XPOTS*6)
#define NUM_SWITCH (NUM_PSWITCH+NUM_CSW+NUM_POTSSW)
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define KEY_RIGHT KEY_PLUS #define KEY_RIGHT KEY_PLUS
@ -623,33 +622,6 @@ enum BaseCurves {
#define SWASH_TYPE_90 4 #define SWASH_TYPE_90 4
#define SWASH_TYPE_NUM 4 #define SWASH_TYPE_NUM 4
enum CswFunctions {
CS_OFF,
CS_VEQUAL, // v==offset
CS_VPOS, // v>offset
CS_VNEG, // v<offset
CS_APOS, // |v|>offset
CS_ANEG, // |v|<offset
CS_AND,
CS_OR,
CS_XOR,
CS_EQUAL,
CS_GREATER,
CS_LESS,
CS_DIFFEGREATER,
CS_ADIFFEGREATER,
CS_TIMER,
CS_MAXF = CS_TIMER
};
#define CS_VOFS 0
#define CS_VBOOL 1
#define CS_VCOMP 2
#define CS_VDIFF 3
#define CS_VTIMER 4
uint8_t cswFamily(uint8_t func);
int16_t cswTimerValue(int8_t val);
#define NUM_CYC 3 #define NUM_CYC 3
#define NUM_CAL_PPM 4 #define NUM_CAL_PPM 4
#define NUM_PPM 8 #define NUM_PPM 8
@ -802,6 +774,7 @@ enum PowerState {
}; };
bool switchState(EnumKeys enuk); bool switchState(EnumKeys enuk);
uint8_t trimDown(uint8_t idx);
void readKeysAndTrims(); void readKeysAndTrims();
uint16_t evalChkSum(); uint16_t evalChkSum();
@ -946,10 +919,8 @@ extern uint16_t s_timeCumThr;
extern uint16_t s_timeCum16ThrP; extern uint16_t s_timeCum16ThrP;
struct TimerState { struct TimerState {
uint8_t lastPos;
uint16_t cnt; uint16_t cnt;
uint16_t sum; uint16_t sum;
uint8_t toggled;
uint8_t state; uint8_t state;
int16_t val; int16_t val;
uint8_t val_10ms; uint8_t val_10ms;
@ -1318,20 +1289,49 @@ extern int24_t act [MAX_MIXERS];
#define isMixActive(x) false #define isMixActive(x) false
#endif #endif
enum CswFunctionFamilies {
CS_FAMILY_OFS,
CS_FAMILY_BOOL,
CS_FAMILY_COMP,
CS_FAMILY_DIFF,
CS_FAMILY_TIMER,
CS_FAMILY_STICKY,
CS_FAMILY_RANGE,
CS_FAMILY_STAY
};
uint8_t cswFamily(uint8_t func);
int16_t cswTimerValue(delayval_t val);
#if defined(CPUARM) #if defined(CPUARM)
#define MASK_CFN_TYPE uint32_t // current max = 32 function switches #define MASK_CFN_TYPE uint32_t // current max = 32 function switches
#define MASK_FUNC_TYPE uint32_t // current max = 32 functions #define MASK_FUNC_TYPE uint32_t // current max = 32 functions
#elif defined(CPUM64) #elif defined(CPUM64)
#define MASK_CFN_TYPE uint16_t // current max = 16 function switches #define MASK_CFN_TYPE uint16_t // current max = 16 function switches
#define MASK_FUNC_TYPE uint16_t // current max = 16 functions #define MASK_FUNC_TYPE uint8_t // current max = 8 functions
#else #else
#define MASK_CFN_TYPE uint32_t // current max = 32 function switches #define MASK_CFN_TYPE uint32_t // current max = 32 function switches
#define MASK_FUNC_TYPE uint16_t // current max = 16 functions #define MASK_FUNC_TYPE uint8_t // current max = 8 functions
#endif #endif
extern MASK_CFN_TYPE activeSwitches; enum FunctionsActive {
extern MASK_CFN_TYPE activeFnSwitches; FUNCTION_TRAINER,
FUNCTION_INSTANT_TRIM = FUNCTION_TRAINER+4,
FUNCTION_VARIO,
FUNCTION_BACKLIGHT,
#if defined(SDCARD)
FUNCTION_LOGS,
#endif
#if defined(CPUARM)
FUNCTION_BACKGND_MUSIC,
FUNCTION_BACKGND_MUSIC_PAUSE,
#endif
};
extern MASK_FUNC_TYPE activeFunctions; extern MASK_FUNC_TYPE activeFunctions;
extern MASK_CFN_TYPE activeFnSwitches;
extern tmr10ms_t lastFunctionTime[NUM_CFN]; extern tmr10ms_t lastFunctionTime[NUM_CFN];
#if defined(CPUARM) #if defined(CPUARM)
@ -1340,7 +1340,7 @@ extern bool evalFunctionsFirstTime;
inline bool isFunctionActive(uint8_t func) inline bool isFunctionActive(uint8_t func)
{ {
return activeFunctions & ((MASK_FUNC_TYPE)1 << (func-FUNC_TRAINER)); return activeFunctions & ((uint8_t)1 << func);
} }
#if defined(ROTARY_ENCODERS) #if defined(ROTARY_ENCODERS)

View file

@ -79,8 +79,8 @@ FXDEFMAP(Open9xSim) Open9xSimMap[]={
FXIMPLEMENT(Open9xSim,FXMainWindow,Open9xSimMap,ARRAYNUMBER(Open9xSimMap)) FXIMPLEMENT(Open9xSim,FXMainWindow,Open9xSimMap,ARRAYNUMBER(Open9xSimMap))
Open9xSim::Open9xSim(FXApp* a) Open9xSim::Open9xSim(FXApp* a):
:FXMainWindow(a,"OpenTXSimu",NULL,NULL,DECOR_ALL,20,90,0,0) FXMainWindow(a, "OpenTX Simu", NULL, NULL, DECOR_ALL, 20, 90, 0, 0)
{ {
firstTime=true; firstTime=true;
for(int i=0; i<(LCD_W*LCD_H/8); i++) displayBuf[i]=0;//rand(); for(int i=0; i<(LCD_W*LCD_H/8); i++) displayBuf[i]=0;//rand();

View file

@ -182,12 +182,6 @@ void pwrOff()
#endif #endif
} }
#if ROTARY_ENCODERS <= 2
#define ROTENC_DOWN() ((~PIND & 0x20) || (~PIND & 0x10))
#else
#define ROTENC_DOWN() (0)
#endif
FORCEINLINE uint8_t keyDown() FORCEINLINE uint8_t keyDown()
{ {
return ((~PINL) & 0x3F) || ROTENC_DOWN(); return ((~PINL) & 0x3F) || ROTENC_DOWN();
@ -261,59 +255,50 @@ bool switchState(EnumKeys enuk)
return result; return result;
} }
static const pm_uchar crossTrim[] PROGMEM = {
1<<INP_J_TRM_LH_DWN,
1<<INP_J_TRM_LH_UP,
1<<INP_J_TRM_LV_DWN,
1<<INP_J_TRM_LV_UP,
1<<INP_J_TRM_RV_DWN,
1<<INP_J_TRM_RV_UP,
1<<INP_J_TRM_RH_DWN,
1<<INP_J_TRM_RH_UP
};
uint8_t trimDown(uint8_t idx)
{
uint8_t in = ~PIND;
return (in & pgm_read_byte(crossTrim+idx));
}
FORCEINLINE void readKeysAndTrims() FORCEINLINE void readKeysAndTrims()
{ {
/* Original keys were connected to PORTB as follows:
Bit Key
7 other use
6 LEFT
5 RIGHT
4 UP
3 DOWN
2 EXIT
1 MENU
0 other use
*/
uint8_t enuk = KEY_MENU; uint8_t enuk = KEY_MENU;
#if ROTARY_ENCODERS <= 2 // User buttons ...
keys[BTN_REa].input(~PIND & 0x20, BTN_REa);
#endif
keys[BTN_REb].input(~PIND & 0x10, BTN_REb);
uint8_t tin = ~PINL; uint8_t tin = ~PINL;
uint8_t in; uint8_t in;
in = (tin & 0x0f) << 3; in = (tin & 0x0f) << 3;
in |= (tin & 0x30) >> 3; in |= (tin & 0x30) >> 3;
for (int i=1; i<7; i++) {
for (int i=1; i<7; i++) // INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
{ keys[enuk].input(in & (1<<i), (EnumKeys)enuk);
//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
keys[enuk].input(in & (1<<i),(EnumKeys)enuk);
++enuk; ++enuk;
} }
// Trim switches ... // Trims ...
static const pm_uchar crossTrim[] PROGMEM ={
1<<INP_J_TRM_LH_DWN,
1<<INP_J_TRM_LH_UP,
1<<INP_J_TRM_LV_DWN,
1<<INP_J_TRM_LV_UP,
1<<INP_J_TRM_RV_DWN,
1<<INP_J_TRM_RV_UP,
1<<INP_J_TRM_RH_DWN,
1<<INP_J_TRM_RH_UP
};
in = ~PINJ; in = ~PINJ;
for (int i=0; i<8; i++) { for (int i=0; i<8; i++) {
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7 // INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
keys[enuk].input(in & pgm_read_byte(crossTrim+i),(EnumKeys)enuk); keys[enuk].input(in & pgm_read_byte(crossTrim+i), (EnumKeys)enuk);
++enuk; ++enuk;
} }
#if defined(ROTARY_ENCODERS)
keys[BTN_REa].input(REA_DOWN(), BTN_REa);
keys[BTN_REb].input(REB_DOWN(), BTN_REb);
#endif
} }
#if ROTARY_ENCODERS <= 2 #if ROTARY_ENCODERS <= 2

View file

@ -100,63 +100,63 @@ void sdPoll10ms();
#define IS_BACKLIGHT_ON() (PORTC & (1<<OUT_C_LIGHT)) #define IS_BACKLIGHT_ON() (PORTC & (1<<OUT_C_LIGHT))
# define INP_L_SPARE6 7 #define INP_L_SPARE6 7
# define INP_L_SPARE5 6 #define INP_L_SPARE5 6
# define INP_L_KEY_EXT 5 #define INP_L_KEY_EXT 5
# define INP_L_KEY_MEN 4 #define INP_L_KEY_MEN 4
# define INP_L_KEY_LFT 3 #define INP_L_KEY_LFT 3
# define INP_L_KEY_RGT 2 #define INP_L_KEY_RGT 2
# define INP_L_KEY_UP 1 #define INP_L_KEY_UP 1
# define INP_L_KEY_DWN 0 #define INP_L_KEY_DWN 0
# define INP_J_TRM_RH_UP 7 #define INP_J_TRM_RH_UP 7
# define INP_J_TRM_RH_DWN 6 #define INP_J_TRM_RH_DWN 6
# define INP_J_TRM_RV_UP 5 #define INP_J_TRM_RV_UP 5
# define INP_J_TRM_RV_DWN 4 #define INP_J_TRM_RV_DWN 4
# define INP_J_TRM_LV_UP 3 #define INP_J_TRM_LV_UP 3
# define INP_J_TRM_LV_DWN 2 #define INP_J_TRM_LV_DWN 2
# define INP_J_TRM_LH_UP 1 #define INP_J_TRM_LH_UP 1
# define INP_J_TRM_LH_DWN 0 #define INP_J_TRM_LH_DWN 0
# define INP_E_PPM_IN 7 #define INP_E_PPM_IN 7
# define INP_E_ROT_ENC_1_B 6 #define INP_E_ROT_ENC_1_B 6
# define INP_E_ROT_ENC_1_A 5 #define INP_E_ROT_ENC_1_A 5
# define INP_E_USB_D_PLS 4 #define INP_E_USB_D_PLS 4
# define OUT_E_BUZZER 3 #define OUT_E_BUZZER 3
# define INP_E_USB_D_NEG 2 #define INP_E_USB_D_NEG 2
# define INP_E_TELEM_RX 1 #define INP_E_TELEM_RX 1
# define OUT_E_TELEM_TX 0 #define OUT_E_TELEM_TX 0
# define OUT_D_HAPTIC 7 #define OUT_D_HAPTIC 7
# define INP_D_SPARE4 6 #define INP_D_SPARE4 6
# define INP_D_ROT_ENC_2_PUSH 5 #define INP_D_ROT_ENC_2_PUSH 5
# define INP_D_ROT_ENC_1_PUSH 4 #define INP_D_ROT_ENC_1_PUSH 4
# define OUT_D_ROT_ENC_2_B 3 #define OUT_D_ROT_ENC_2_B 3
# define INP_D_ROT_ENC_2_A 2 #define INP_D_ROT_ENC_2_A 2
# define INP_D_I2C_SCL 1 #define INP_D_I2C_SCL 1
# define INP_D_I2C_SDA 0 #define INP_D_I2C_SDA 0
# define INP_G_Gear 5 #define INP_G_Gear 5
# define INP_G_ThrCt 2 #define INP_G_ThrCt 2
# define OUT_G_SIM_CTL 4 //1 : phone-jack=ppm_in #define OUT_G_SIM_CTL 4 //1 : phone-jack=ppm_in
# define INP_G_ID1 3 #define INP_G_ID1 3
# define INP_G_RF_POW 1 #define INP_G_RF_POW 1
# define INP_G_RuddDR 0 #define INP_G_RuddDR 0
# define INP_C_AileDR 7 #define INP_C_AileDR 7
# define INP_C_ElevDR 6 #define INP_C_ElevDR 6
# define OUT_C_LIGHT 0 #define OUT_C_LIGHT 0
# define OUT_B_Speaker 7 #define OUT_B_Speaker 7
# define OUT_B_PPM 6 // will be switched by TCNT1==OCR1B in hardware #define OUT_B_PPM 6 // will be switched by TCNT1==OCR1B in hardware
# define INP_B_Trainer 5 #define INP_B_Trainer 5
# define INP_B_ID2 4 #define INP_B_ID2 4
#if defined(VOICE) #if defined(VOICE)
# define OUT_H_14DRESET 3 #define OUT_H_14DRESET 3
# define OUT_H_14DCLK 4 #define OUT_H_14DCLK 4
# define OUT_H_14DDATA 5 #define OUT_H_14DDATA 5
# define INP_H_14DBUSY 6 #define INP_H_14DBUSY 6
#endif #endif
// Keys driver // Keys driver
@ -187,4 +187,14 @@ void pwrOff();
// Haptic driver // Haptic driver
#define hapticOff() // TODO hapticOn() cleaner ... #define hapticOff() // TODO hapticOn() cleaner ...
// Rotary encoder driver
#if ROTARY_ENCODERS <= 2
#define REA_DOWN() (~PIND & 0x20)
#define REB_DOWN() (~PIND & 0x10)
#else
#define REA_DOWN() (0)
#define REB_DOWN() (0)
#endif
#define ROTENC_DOWN() (REA_DOWN() || REB_DOWN())
#endif #endif

View file

@ -253,9 +253,9 @@ void rotencInit();
void rotencEnd(); void rotencEnd();
#if ROTARY_ENCODERS > 0 #if ROTARY_ENCODERS > 0
#define rotencDown() (!(PIOB->PIO_PDSR & 0x40)) #define REA_DOWN() (!(PIOB->PIO_PDSR & 0x40))
#else #else
#define rotencDown() 0 #define REA_DOWN() (0)
#endif #endif
// Debug driver // Debug driver

View file

@ -113,9 +113,14 @@ uint32_t readTrims()
return result; return result;
} }
uint8_t trimDown(uint8_t idx)
{
return readTrims() & (1 << idx);
}
uint8_t keyDown() uint8_t keyDown()
{ {
return (~readKeys() & 0x7E) || rotencDown(); return (~readKeys() & 0x7E) || REA_DOWN();
} }
void readKeysAndTrims() void readKeysAndTrims()
@ -123,7 +128,7 @@ void readKeysAndTrims()
register uint32_t i; register uint32_t i;
#if ROTARY_ENCODERS > 0 #if ROTARY_ENCODERS > 0
keys[BTN_REa].input(rotencDown(), BTN_REa); keys[BTN_REa].input(REA_DOWN(), BTN_REa);
#endif #endif
uint8_t enuk = KEY_MENU; uint8_t enuk = KEY_MENU;

View file

@ -234,37 +234,38 @@ bool switchState(EnumKeys enuk)
return result; return result;
} }
#ifndef SIMU // Trim switches ...
FORCEINLINE static const pm_uchar crossTrim[] PROGMEM ={
#endif 1<<INP_D_TRM_LH_DWN, // bit 7
void readKeysAndTrims() 1<<INP_D_TRM_LH_UP,
1<<INP_D_TRM_LV_DWN,
1<<INP_D_TRM_LV_UP,
1<<INP_D_TRM_RV_DWN,
1<<INP_D_TRM_RV_UP,
1<<INP_D_TRM_RH_DWN,
1<<INP_D_TRM_RH_UP // bit 0
};
uint8_t trimDown(uint8_t idx)
{
uint8_t in = ~PIND;
return (in & pgm_read_byte(crossTrim+idx));
}
FORCEINLINE void readKeysAndTrims()
{ {
uint8_t enuk = KEY_MENU; uint8_t enuk = KEY_MENU;
// User buttons ... // User buttons ...
uint8_t in = ~PINB; uint8_t in = ~PINB;
for (int i=1; i<7; i++) {
for(int i=1; i<7; i++) // INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
{ keys[enuk].input(in & (1<<i), (EnumKeys)enuk);
//INP_B_KEY_MEN 1 .. INP_B_KEY_LFT 6
keys[enuk].input(in & (1<<i),(EnumKeys)enuk);
++enuk; ++enuk;
} }
// Trim switches ... // Trims ...
static const pm_uchar crossTrim[] PROGMEM ={
1<<INP_D_TRM_LH_DWN, // bit 7
1<<INP_D_TRM_LH_UP,
1<<INP_D_TRM_LV_DWN,
1<<INP_D_TRM_LV_UP,
1<<INP_D_TRM_RV_DWN,
1<<INP_D_TRM_RV_UP,
1<<INP_D_TRM_RH_DWN,
1<<INP_D_TRM_RH_UP // bit 0
};
in = ~PIND; in = ~PIND;
for (int i=0; i<8; i++) { for (int i=0; i<8; i++) {
// INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7 // INP_D_TRM_RH_UP 0 .. INP_D_TRM_LH_UP 7
keys[enuk].input(in & pgm_read_byte(crossTrim+i), (EnumKeys)enuk); keys[enuk].input(in & pgm_read_byte(crossTrim+i), (EnumKeys)enuk);

View file

@ -92,6 +92,11 @@ uint32_t readTrims()
return result; return result;
} }
uint8_t trimDown(uint8_t idx)
{
return readTrims() & (1 << idx);
}
uint8_t keyDown() uint8_t keyDown()
{ {
return ~readKeys() & 0x7E ; return ~readKeys() & 0x7E ;

View file

@ -335,9 +335,9 @@
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "*1 " #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS
#else #else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "*1 " #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW
#endif #endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)

View file

@ -335,9 +335,9 @@
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "ONE" #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS
#else #else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "ONE" #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW
#endif #endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)

View file

@ -150,8 +150,25 @@
#define LEN_VMIXTRIMS "\003" #define LEN_VMIXTRIMS "\003"
#define TR_VMIXTRIMS "OFF""ON\0""Rud""Ele""Thr""Ail" #define TR_VMIXTRIMS "OFF""ON\0""Rud""Ele""Thr""Ail"
#if defined(PCBTARANIS)
#define TR_CSWTIMER "Timer"
#define TR_CSWSTICKY "Stcky"
#define TR_CSWRANGE "Range"
#define TR_CSWSTAY "Stay\0"
#else
#define TR_CSWTIMER "Tim\0 "
#define TR_CSWSTICKY "Glue\0"
#if defined(CPUARM)
#define TR_CSWRANGE "Rnge\0"
#define TR_CSWSTAY "Stay\0"
#else
#define TR_CSWRANGE
#define TR_CSWSTAY
#endif
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""a<x\0 ""|a|>x""|a|<x""AND\0 ""OR\0 ""XOR\0 ""a=b\0 ""a>b\0 ""a<b\0 ""d}x\0 ""|d|}x""TIM\0" #define TR_VCSWFUNC "---\0 ""a{x\0 ""a>x\0 ""a<x\0 " TR_CSWRANGE "|a|>x""|a|<x""AND\0 ""OR\0 ""XOR\0 " TR_CSWSTAY "a=b\0 ""a>b\0 ""a<b\0 ""d}x\0 ""|d|}x" TR_CSWTIMER TR_CSWSTICKY
#define LEN_VFSWFUNC "\012" #define LEN_VFSWFUNC "\012"
@ -167,9 +184,7 @@
#define TR_SOUND "Beep\0 " #define TR_SOUND "Beep\0 "
#endif #endif
#if defined(PCBTARANIS) #if defined(HAPTIC)
#define TR_HAPTIC
#elif defined(HAPTIC)
#define TR_HAPTIC "Haptic\0 " #define TR_HAPTIC "Haptic\0 "
#else #else
#define TR_HAPTIC "[Haptic]\0 " #define TR_HAPTIC "[Haptic]\0 "
@ -189,7 +204,6 @@
#define TR_PLAY_VALUE "[Play Val]" #define TR_PLAY_VALUE "[Play Val]"
#endif #endif
#define TR_CFN_VOLUME "Volume\0 "
#define TR_CFN_BG_MUSIC "BgMusic\0 ""BgMusic ||" #define TR_CFN_BG_MUSIC "BgMusic\0 ""BgMusic ||"
#if defined(SDCARD) #if defined(SDCARD)
@ -198,10 +212,10 @@
#define TR_SDCLOGS "[SD Logs]\0" #define TR_SDCLOGS "[SD Logs]\0"
#endif #endif
#ifdef GVARS #if defined(GVARS)
#define TR_CFN_ADJUST_GVAR "Adjust \0 " #define TR_ADJUST_GVAR "Adjust \0 "
#else #else
#define TR_CFN_ADJUST_GVAR #define TR_ADJUST_GVAR "[AdjustGV]"
#endif #endif
#ifdef DEBUG #ifdef DEBUG
@ -211,11 +225,11 @@
#endif #endif
#if defined(CPUARM) #if defined(CPUARM)
#define TR_VFSWFUNC "Safety\0 ""Trainer\0 ""Inst. Trim" TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_VALUE TR_SDCLOGS TR_CFN_VOLUME "Backlight\0" TR_CFN_BG_MUSIC TR_CFN_ADJUST_GVAR TR_CFN_TEST #define TR_VFSWFUNC "Safety\0 ""Trainer\0 ""Inst. Trim""Reset\0 " TR_ADJUST_GVAR "Volume\0 " TR_SOUND TR_PLAY_TRACK TR_PLAY_VALUE TR_CFN_BG_MUSIC TR_VVARIO TR_HAPTIC TR_SDCLOGS "Backlight\0" TR_CFN_TEST
#elif defined(PCBGRUVIN9X) #elif defined(PCBGRUVIN9X)
#define TR_VFSWFUNC "Safety\0 ""Trainer\0 ""Inst. Trim" TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_BOTH TR_PLAY_VALUE TR_SDCLOGS "Backlight\0" TR_CFN_ADJUST_GVAR TR_CFN_TEST #define TR_VFSWFUNC "Safety\0 ""Trainer\0 ""Inst. Trim""Reset\0 " TR_ADJUST_GVAR TR_SOUND TR_PLAY_TRACK TR_PLAY_BOTH TR_PLAY_VALUE TR_VVARIO TR_HAPTIC TR_SDCLOGS "Backlight\0" TR_CFN_TEST
#else #else
#define TR_VFSWFUNC "Safety\0 ""Trainer\0 ""Inst. Trim" TR_SOUND TR_HAPTIC "Reset\0 " TR_VVARIO TR_PLAY_TRACK TR_PLAY_BOTH TR_PLAY_VALUE "Backlight\0" TR_CFN_ADJUST_GVAR TR_CFN_TEST #define TR_VFSWFUNC "Safety\0 ""Trainer\0 ""Inst. Trim""Reset\0 " TR_ADJUST_GVAR TR_SOUND TR_PLAY_TRACK TR_PLAY_BOTH TR_PLAY_VALUE TR_VVARIO TR_HAPTIC "Backlight\0" TR_CFN_TEST
#endif #endif
#define LEN_VFSWRESET TR("\004", "\011") #define LEN_VFSWRESET TR("\004", "\011")
@ -333,21 +347,26 @@
#define TR_CUSTOMSW "CS1""CS2""CS3""CS4""CS5""CS6""CS7""CS8""CS9""CSA""CSB""CSC" #define TR_CUSTOMSW "CS1""CS2""CS3""CS4""CS5""CS6""CS7""CS8""CS9""CSA""CSB""CSC"
#endif #endif
#if defined(PCBTARANIS) #define TR_TRIMS_SWITCHES "tRl""tRr""tEd""tEu""tTd""tTu""tAl""tAr"
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "One"
#else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "One"
#endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)
#define TR_ROTARY_ENCODERS_VSRCRAW "REnc" #define TR_ROTARY_ENCODERS "REa\0"
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS > 2 #define TR_ROTENC_SWITCHES "REa"
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb ""REc ""REd " #elif defined(PCBGRUVIN9X) || defined(PCBMEGA2560)
#elif defined(PCBGRUVIN9X) && ROTARY_ENCODERS <= 2 #define TR_ROTARY_ENCODERS "REa\0""REb\0"
#define TR_ROTARY_ENCODERS_VSRCRAW "REa ""REb " #define TR_ROTENC_SWITCHES "REa""REb"
#else #else
#define TR_ROTARY_ENCODERS_VSRCRAW #define TR_ROTARY_ENCODERS
#define TR_ROTENC_SWITCHES
#endif
#if defined(PCBTARANIS)
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_6POS_POTS TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW
#elif defined(CPUARM)
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW
#else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_CUSTOMSW
#endif #endif
#if defined(HELI) #if defined(HELI)
@ -356,7 +375,7 @@
#define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]" #define TR_CYC_VSRCRAW "[C1]""[C2]""[C3]"
#endif #endif
#define TR_VSRCRAW "---\0""Rud\0""Ele\0""Thr\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS_VSRCRAW "MAX\0" TR_CYC_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" TR_SW_VSRCRAW #define TR_VSRCRAW "---\0""Rud\0""Ele\0""Thr\0""Ail\0" TR_POTS_VSRCRAW TR_ROTARY_ENCODERS "MAX\0" TR_CYC_VSRCRAW "TrmR" "TrmE" "TrmT" "TrmA" TR_SW_VSRCRAW
#define LEN_VTMRMODES "\003" #define LEN_VTMRMODES "\003"
#define TR_VTMRMODES "OFF""ABS""THs""TH%""THt" #define TR_VTMRMODES "OFF""ABS""THs""TH%""THt"
@ -713,7 +732,7 @@
// Taranis column headers // Taranis column headers
#define TR_PHASES_HEADERS { " Name ", " Switch ", " Rudder Trim ", " Elevator Trim ", " Throttle Trim ", " Aileron Trim ", " Fade In ", " Fade Out " } #define TR_PHASES_HEADERS { " Name ", " Switch ", " Rudder Trim ", " Elevator Trim ", " Throttle Trim ", " Aileron Trim ", " Fade In ", " Fade Out " }
#define TR_LIMITS_HEADERS { " Name ", " Subtrim ", " Min ", " Max ", " Direction ", " Curve ", " PPM Center ", " Subtrim mode " } #define TR_LIMITS_HEADERS { " Name ", " Subtrim ", " Min ", " Max ", " Direction ", " Curve ", " PPM Center ", " Subtrim mode " }
#define TR_CSW_HEADERS { " Function ", " V1 ", " V2 ", " AND Switch ", " Duration ", " Delay " } #define TR_CSW_HEADERS { " Function ", " V1 ", " V2 ", " V2 ", " AND Switch ", " Duration ", " Delay " }
// About screen // About screen
#define TR_ABOUTUS TR(" ABOUT ", "ABOUT") #define TR_ABOUTUS TR(" ABOUT ", "ABOUT")

View file

@ -335,9 +335,9 @@
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "Uno" #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS
#else #else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "ACE""DIR""ELE""ALE""GEA""TRN" TR_CUSTOMSW "Uno" #define TR_VSWITCHES TR_9X_3POS_SWITCHES "ACE""DIR""ELE""ALE""GEA""TRN" TR_CUSTOMSW
#endif #endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)

View file

@ -335,9 +335,9 @@
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "1*\0" #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS
#else #else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "1*\0" #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW
#endif #endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)

View file

@ -337,7 +337,7 @@
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "1*\0" #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "1*\0"
#else #else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "One" #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW
#endif #endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)

View file

@ -335,9 +335,9 @@
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS " * " #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS
#else #else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "GAZ""SK ""LOT""SW ""GEA""TRN" TR_CUSTOMSW " * " #define TR_VSWITCHES TR_9X_3POS_SWITCHES "GAZ""SK ""LOT""SW ""GEA""TRN" TR_CUSTOMSW
#endif #endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)

View file

@ -335,9 +335,9 @@
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "1*\0" #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS
#else #else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "1*\0" #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW
#endif #endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)

View file

@ -335,9 +335,9 @@
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26" #define TR_6POS_POTS "P11""P12""P13""P14""P15""P16""P21""P22""P23""P24""P25""P26"
#define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS "One" #define TR_VSWITCHES "SA\300""SA-""SA\301""SB\300""SB-""SB\301""SC\300""SC-""SC\301""SD\300""SD-""SD\301""SE\300""SE-""SE\301""SF\300""SF\301""SG\300""SG-""SG\301""SH\300""SH\301" TR_CUSTOMSW TR_6POS_POTS
#else #else
#define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW "One" #define TR_VSWITCHES TR_9X_3POS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" TR_CUSTOMSW
#endif #endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)