diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index b33e650df..4fff4fc51 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -531,7 +531,7 @@ int getStickTrimValue(int stick, int stickValue) return 0; int trim = trims[stick]; - if (IS_THROTTLE_TRIM(stick)) { + if (stick == THR_STICK) { if (g_model.thrTrim) { int trimMin = g_model.extendedTrims ? 2*TRIM_EXTENDED_MIN : 2*TRIM_MIN; trim = ((g_model.throttleReversed ? (trim+trimMin) : (trim-trimMin)) * (RESX-stickValue)) >> (RESX_SHIFT+1); diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 3dbe6b01b..81b5c2438 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1141,12 +1141,12 @@ void checkTrims() else { phase = getTrimFlightMode(mixerCurrentFlightMode, idx); before = getTrimValue(phase, idx); - thro = (IS_THROTTLE_TRIM(idx) && g_model.thrTrim); + thro = (idx==THR_STICK && g_model.thrTrim); } #else phase = getTrimFlightMode(mixerCurrentFlightMode, idx); before = getTrimValue(phase, idx); - thro = (IS_THROTTLE_TRIM(idx) && g_model.thrTrim); + thro = (idx==THR_STICK && g_model.thrTrim); #endif int8_t trimInc = g_model.trimInc + 1; int8_t v = (trimInc==-1) ? min(32, abs(before)/4+1) : (1 << trimInc); // TODO flash saving if (trimInc < 0) diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 62a5cbaf5..6bcce1594 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -292,8 +292,6 @@ void memswap(void * a, void * b, uint8_t size); #define IS_MULTIPOS_CALIBRATED(cal) (false) #endif -#define IS_THROTTLE_TRIM(x) (x == virtualInputsTrims[THR_STICK]) - #if defined(PWR_BUTTON_PRESS) #define pwrOffPressed() pwrPressed() #else diff --git a/radio/src/tests/mixer.cpp b/radio/src/tests/mixer.cpp index 97fa34a71..8f92ac4de 100644 --- a/radio/src/tests/mixer.cpp +++ b/radio/src/tests/mixer.cpp @@ -553,6 +553,21 @@ TEST_F(MixerTest, SlowOnMultiply) CHECK_NO_MOVEMENT(0, CHANNEL_MAX, 250); } +TEST_F(TrimsTest, throttleTrimEle) { + SYSTEM_RESET(); + MODEL_RESET(); + MIXER_RESET(); + modelDefault(0); + g_eeGeneral.templateSetup = 17; + applyDefaultTemplate(); + g_model.thrTrim = 1; +// checks ELE sticks are not affected by throttleTrim +// stick max + trim min + anaInValues[ELE_STICK] = +1024; + setTrimValue(0, ELE_STICK, TRIM_MIN); + evalMixes(1); + EXPECT_EQ(channelOutputs[2], 1024 - 250); +} #if defined(HELI) TEST(Heli, BasicTest)