1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 08:15:17 +03:00

Issue #741 fixed - a==x added in logical switches functions

This commit is contained in:
Bertrand Songis 2014-02-24 07:30:59 +01:00
parent c98e718e16
commit 2a8abd08da
18 changed files with 90 additions and 15 deletions

View file

@ -428,6 +428,8 @@ QString LogicalSwitchData::funcToString()
case LS_FN_DAPOS: case LS_FN_DAPOS:
return QObject::tr("|d|>=x"); return QObject::tr("|d|>=x");
case LS_FN_VEQUAL: case LS_FN_VEQUAL:
return QObject::tr("a=x");
case LS_FN_VALMOSTEQUAL:
return QObject::tr("a~x"); return QObject::tr("a~x");
case LS_FN_TIMER: case LS_FN_TIMER:
return QObject::tr("Timer"); return QObject::tr("Timer");

View file

@ -597,6 +597,7 @@ enum CSFunction {
LS_FN_DPOS, LS_FN_DPOS,
LS_FN_DAPOS, LS_FN_DAPOS,
LS_FN_VEQUAL, // added at the end to avoid everything renumbered LS_FN_VEQUAL, // added at the end to avoid everything renumbered
LS_FN_VALMOSTEQUAL,
LS_FN_TIMER, LS_FN_TIMER,
LS_FN_STICKY, LS_FN_STICKY,
LS_FN_STAY, LS_FN_STAY,

View file

@ -1063,8 +1063,10 @@ class LogicalSwitchesFunctionsTable: public ConversionTable {
int val=0; int val=0;
bool afterrelease21March2013 = IS_AFTER_RELEASE_21_MARCH_2013(board, version); bool afterrelease21March2013 = IS_AFTER_RELEASE_21_MARCH_2013(board, version);
addConversion(LS_FN_OFF, val++); addConversion(LS_FN_OFF, val++);
if (afterrelease21March2013) if (IS_ARM(board) && version >= 216)
addConversion(LS_FN_VEQUAL, val++); addConversion(LS_FN_VEQUAL, val++);
if (afterrelease21March2013)
addConversion(LS_FN_VALMOSTEQUAL, val++);
addConversion(LS_FN_VPOS, val++); addConversion(LS_FN_VPOS, val++);
addConversion(LS_FN_VNEG, val++); addConversion(LS_FN_VNEG, val++);
if (IS_ARM(board) && version >= 216) val++; // later RANGE if (IS_ARM(board) && version >= 216) val++; // later RANGE

View file

@ -643,6 +643,7 @@ void populateCSWCB(QComboBox *b, int value)
int order[] = { int order[] = {
LS_FN_OFF, LS_FN_OFF,
LS_FN_VEQUAL, // added at the end to avoid everything renumbered LS_FN_VEQUAL, // added at the end to avoid everything renumbered
LS_FN_VALMOSTEQUAL, // added at the end to avoid everything renumbered
LS_FN_VPOS, LS_FN_VPOS,
LS_FN_VNEG, LS_FN_VNEG,
// LS_FN_RANGE, // LS_FN_RANGE,

View file

@ -121,7 +121,7 @@ void LogicalSwitchesPanel::v1Edited(int value)
if (model.customSw[i].getFunctionFamily() == LS_FAMILY_VOFS) { if (model.customSw[i].getFunctionFamily() == LS_FAMILY_VOFS) {
RawSource source = RawSource(model.customSw[i].val1, &model); RawSource source = RawSource(model.customSw[i].val1, &model);
if (source.type == SOURCE_TYPE_TELEMETRY) { if (source.type == SOURCE_TYPE_TELEMETRY) {
if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) { if (model.customSw[i].func == LS_FN_DPOS || model.customSw[i].func == LS_FN_DAPOS) {
model.customSw[i].val2 = 0; model.customSw[i].val2 = 0;
} }
else { else {
@ -130,7 +130,7 @@ void LogicalSwitchesPanel::v1Edited(int value)
} }
else { else {
RawSourceRange range = source.getRange(); RawSourceRange range = source.getRange();
if (model.customSw[i].func > LS_FN_ELESS && model.customSw[i].func < LS_FN_VEQUAL) { if (model.customSw[i].func == LS_FN_DPOS || model.customSw[i].func == LS_FN_DAPOS) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step); model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
} }
else { else {
@ -208,7 +208,7 @@ void LogicalSwitchesPanel::edited()
{ {
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>LS_FN_ELESS && model.customSw[i].func<LS_FN_VEQUAL) { if (model.customSw[i].func == LS_FN_DPOS || model.customSw[i].func == LS_FN_DAPOS) {
model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step); model.customSw[i].val2 = (cswitchOffset[i]->value() / range.step);
cswitchOffset[i]->setValue(model.customSw[i].val2*range.step); cswitchOffset[i]->setValue(model.customSw[i].val2*range.step);
} }
@ -269,7 +269,7 @@ void LogicalSwitchesPanel::setSwitchWidgetVisibility(int i)
populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0)); populateSourceCB(cswitchSource1[i], source, model, POPULATE_SOURCES | POPULATE_VIRTUAL_INPUTS | POPULATE_TRIMS | POPULATE_SWITCHES | POPULATE_TELEMETRY | (GetEepromInterface()->getCapability(GvarsInCS) ? POPULATE_GVARS : 0));
cswitchOffset[i]->setDecimals(range.decimals); cswitchOffset[i]->setDecimals(range.decimals);
cswitchOffset[i]->setSingleStep(range.step); cswitchOffset[i]->setSingleStep(range.step);
if (model.customSw[i].func>LS_FN_ELESS && model.customSw[i].func<LS_FN_VEQUAL) { if (model.customSw[i].func == LS_FN_DPOS || model.customSw[i].func == LS_FN_DAPOS) {
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);

View file

@ -466,6 +466,7 @@ void ConvertModel_215_to_216(ModelData &model)
for (uint8_t i=0; i<32; i++) { for (uint8_t i=0; i<32; i++) {
LogicalSwitchData & sw = g_model.customSw[i]; LogicalSwitchData & sw = g_model.customSw[i];
sw.func = oldModel.customSw[i].func; sw.func = oldModel.customSw[i].func;
if (sw.func >= LS_FUNC_VEQUAL) sw.func += 1;
if (sw.func >= LS_FUNC_RANGE) sw.func += 1; if (sw.func >= LS_FUNC_RANGE) sw.func += 1;
if (sw.func >= LS_FUNC_STAY) sw.func += 1; if (sw.func >= LS_FUNC_STAY) sw.func += 1;
sw.v1 = oldModel.customSw[i].v1; sw.v1 = oldModel.customSw[i].v1;

View file

@ -686,7 +686,10 @@ PACK( union u_int8int16_t {
enum LogicalSwitchesFunctions { enum LogicalSwitchesFunctions {
LS_FUNC_NONE, LS_FUNC_NONE,
#if defined(CPUARM)
LS_FUNC_VEQUAL, // v==offset LS_FUNC_VEQUAL, // v==offset
#endif
LS_FUNC_VALMOSTEQUAL, // v~=offset
LS_FUNC_VPOS, // v>offset LS_FUNC_VPOS, // v>offset
LS_FUNC_VNEG, // v<offset LS_FUNC_VNEG, // v<offset
#if defined(CPUARM) #if defined(CPUARM)

View file

@ -1545,7 +1545,12 @@ bool getSwitch(int8_t swtch)
#endif #endif
switch (cs->func) { switch (cs->func) {
#if defined(CPUARM)
case LS_FUNC_VEQUAL: case LS_FUNC_VEQUAL:
result = (x==y);
break;
#endif
case LS_FUNC_VALMOSTEQUAL:
#if defined(GVARS) #if defined(GVARS)
if (v1 >= MIXSRC_GVAR1 && v1 <= MIXSRC_LAST_GVAR) if (v1 >= MIXSRC_GVAR1 && v1 <= MIXSRC_LAST_GVAR)
result = (x==y); result = (x==y);

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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 "\013" #define LEN_VFSWFUNC "\013"

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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"

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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"

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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"

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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"

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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 "\015" #define LEN_VFSWFUNC "\015"

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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 "\015" #define LEN_VFSWFUNC "\015"

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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 "\013" #define LEN_VFSWFUNC "\013"

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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 "\015" #define LEN_VFSWFUNC "\015"

View file

@ -167,8 +167,14 @@
#endif #endif
#endif #endif
#if defined(CPUARM)
#define TR_CSWEQUAL "a=x\0 "
#else
#define TR_CSWEQUAL
#endif
#define LEN_VCSWFUNC "\005" #define LEN_VCSWFUNC "\005"
#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 TR_VCSWFUNC "---\0 " TR_CSWEQUAL "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"