Merge pull request #6036 from opentx/bsongis/revert_PR#5664

Fixes #6032
This commit is contained in:
Bertrand Songis
2018-07-12 11:40:08 +02:00
committed by GitHub
4 changed files with 19 additions and 10 deletions
+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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)
-6
View File
@@ -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
+16 -1
View File
@@ -75,7 +75,6 @@ TEST_F(TrimsTest, throttleTrim)
setTrimValue(0, THR_STICK, TRIM_MIN);
evalMixes(1);
EXPECT_EQ(channelOutputs[2], -1024);
// now the same tests with extended Trims
g_model.extendedTrims = 1;
// stick max + trim max
@@ -392,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();