Fixes #1543
This commit is contained in:
+20
-2
@@ -171,6 +171,24 @@ void getSwitchesPosition(bool startup)
|
||||
}
|
||||
#define SWITCH_POSITION(sw) (switchesPos & (1<<(sw)))
|
||||
#define POT_POSITION(sw) ((potsPos[(sw)/XPOTS_MULTIPOS_COUNT] & 0x0f) == ((sw) % XPOTS_MULTIPOS_COUNT))
|
||||
|
||||
getvalue_t getValueForLogicalSwitch(uint8_t i)
|
||||
{
|
||||
getvalue_t result = getValue(i);
|
||||
if (i>=MIXSRC_FIRST_INPUT && i<=MIXSRC_LAST_INPUT) {
|
||||
int8_t trimIdx = virtualInputsTrims[i-MIXSRC_FIRST_INPUT];
|
||||
if (trimIdx >= 0) {
|
||||
int16_t trim = trims[trimIdx];
|
||||
if (trimIdx == THR_STICK && g_model.throttleReversed)
|
||||
result -= trim;
|
||||
else
|
||||
result += trim;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
#define getValueForLogicalSwitch(i) getValue(i)
|
||||
#endif
|
||||
|
||||
bool getLogicalSwitch(uint8_t idx)
|
||||
@@ -219,10 +237,10 @@ bool getLogicalSwitch(uint8_t idx)
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
getvalue_t x = getValue(ls->v1);
|
||||
getvalue_t x = getValueForLogicalSwitch(ls->v1);
|
||||
getvalue_t y;
|
||||
if (s == LS_FAMILY_COMP) {
|
||||
y = getValue(ls->v2);
|
||||
y = getValueForLogicalSwitch(ls->v2);
|
||||
|
||||
switch (ls->func) {
|
||||
case LS_FUNC_EQUAL:
|
||||
|
||||
@@ -57,6 +57,7 @@ TEST(getSwitch, undefCSW)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(CPUARM)
|
||||
TEST(getSwitch, circularCSW)
|
||||
{
|
||||
MODEL_RESET();
|
||||
@@ -70,6 +71,7 @@ TEST(getSwitch, circularCSW)
|
||||
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
|
||||
EXPECT_EQ(getSwitch(-SWSRC_SW2), true);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
TEST(getSwitch, OldTypeStickyCSW)
|
||||
@@ -109,7 +111,6 @@ TEST(getSwitch, nullSW)
|
||||
EXPECT_EQ(getSwitch(0), true);
|
||||
}
|
||||
|
||||
|
||||
#if defined(PCBTARANIS) && defined(FRSKY)
|
||||
TEST(getSwitch, VfasWithDelay)
|
||||
{
|
||||
@@ -340,3 +341,23 @@ TEST(getSwitch, recursiveSW)
|
||||
EXPECT_EQ(getSwitch(SWSRC_SW2), false);
|
||||
}
|
||||
#endif // #if !defined(CPUARM)
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
TEST(getSwitch, inputWithTrim)
|
||||
{
|
||||
MODEL_RESET();
|
||||
modelDefault(0);
|
||||
MIXER_RESET();
|
||||
|
||||
g_model.logicalSw[0] = { MIXSRC_FIRST_INPUT, 0, 0, LS_FUNC_VPOS };
|
||||
|
||||
doMixerCalculations();
|
||||
evalLogicalSwitches();
|
||||
EXPECT_EQ(getSwitch(SWSRC_SW1), false);
|
||||
|
||||
setTrimValue(0, 0, 32);
|
||||
doMixerCalculations();
|
||||
evalLogicalSwitches();
|
||||
EXPECT_EQ(getSwitch(SWSRC_SW1), true);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user