From e10cbed69f10d8b1ec45b5955f7fb3b6de5b73a1 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 11 Jul 2018 22:51:10 +0200 Subject: [PATCH 1/4] Fixes #6032 --- radio/src/opentx.cpp | 4 ++-- radio/src/opentx.h | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 92baf0835..ab092b73e 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1386,7 +1386,7 @@ uint8_t checkTrim(event_t event) #else before = getRawTrimValue(phase, idx); #endif - thro = (IS_THROTTLE_TRIM(idx) && g_model.thrTrim); + thro = (idx==THR_STICK && g_model.thrTrim); } #else phase = getTrimFlightMode(mixerCurrentFlightMode, idx); @@ -1395,7 +1395,7 @@ uint8_t checkTrim(event_t event) #else before = getRawTrimValue(phase, idx); #endif - 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 7a4195ea1..2fb37381c 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -334,12 +334,6 @@ void memswap(void * a, void * b, uint8_t size); #define IS_MULTIPOS_CALIBRATED(cal) (false) #endif -#if defined(VIRTUAL_INPUTS) - #define IS_THROTTLE_TRIM(x) (x == virtualInputsTrims[THR_STICK]) -#else - #define IS_THROTTLE_TRIM(x) (x == THR_STICK) -#endif - #if defined(PWR_BUTTON_PRESS) #define pwrOffPressed() pwrPressed() #else From 94bd8a237d5a873c9792cd2cc6019ea7e6ad4103 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Thu, 12 Jul 2018 00:42:38 +0200 Subject: [PATCH 2/4] Revert "Apply THR trim when cross triming (#5664)" This reverts commit 1ebd289 --- radio/src/mixer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index 9e8d1a0ac..fa59432e1 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -650,7 +650,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); From 69d3e9be0a13cd124e2548b210c6a001898de7f7 Mon Sep 17 00:00:00 2001 From: 3djc Date: Thu, 12 Jul 2018 07:40:57 +0200 Subject: [PATCH 3/4] Add Gtest (fullfilling my debt !) --- radio/src/tests/mixer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/radio/src/tests/mixer.cpp b/radio/src/tests/mixer.cpp index 9d3c439e5..be98ee981 100644 --- a/radio/src/tests/mixer.cpp +++ b/radio/src/tests/mixer.cpp @@ -75,6 +75,12 @@ TEST_F(TrimsTest, throttleTrim) setTrimValue(0, THR_STICK, TRIM_MIN); evalMixes(1); EXPECT_EQ(channelOutputs[2], -1024); + // 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[1], 1024-250); // now the same tests with extended Trims g_model.extendedTrims = 1; From 89656d81952d25e637d6e7f8a7d9bfeb801e441a Mon Sep 17 00:00:00 2001 From: 3djc Date: Thu, 12 Jul 2018 08:56:03 +0200 Subject: [PATCH 4/4] Fix Gtest (fullfilling my debt !) --- radio/src/tests/mixer.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/radio/src/tests/mixer.cpp b/radio/src/tests/mixer.cpp index be98ee981..367f6db13 100644 --- a/radio/src/tests/mixer.cpp +++ b/radio/src/tests/mixer.cpp @@ -75,13 +75,6 @@ TEST_F(TrimsTest, throttleTrim) setTrimValue(0, THR_STICK, TRIM_MIN); evalMixes(1); EXPECT_EQ(channelOutputs[2], -1024); - // 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[1], 1024-250); - // now the same tests with extended Trims g_model.extendedTrims = 1; // stick max + trim max @@ -398,6 +391,22 @@ TEST_F(TrimsTest, InstantTrimNegativeCurve) } #endif +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); +} + TEST(Curves, LinearIntpol) { SYSTEM_RESET();