From 6427b8a8bb99dba993ab57ddacb2296cc5e797c3 Mon Sep 17 00:00:00 2001 From: "bsongis@gmail.com" Date: Mon, 3 Jun 2013 20:50:00 +0000 Subject: [PATCH] Issue 41 fixed --- src/gtests.cpp | 21 ++++++++++++++++++++- src/opentx.cpp | 21 +++++++++++---------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/gtests.cpp b/src/gtests.cpp index ec7efd63b..7bdc523f7 100644 --- a/src/gtests.cpp +++ b/src/gtests.cpp @@ -583,7 +583,6 @@ TEST(Mixer, SlowAndDelayOnReplace3POSSource) g_model.mixData[0].srcRaw = MIXSRC_3POS; g_model.mixData[0].weight = 100; g_model.mixData[0].delayUp = 10; - g_model.mixData[0].delayUp = 10; g_model.mixData[0].speedUp = 10; g_model.mixData[0].speedDown = 10; @@ -601,6 +600,26 @@ TEST(Mixer, SlowAndDelayOnReplace3POSSource) CHECK_SLOW_MOVEMENT(0, +1, 250); } +TEST(Mixer, NoTrimOnInactiveMix) +{ + MODEL_RESET(); + MIXER_RESET(); + g_model.mixData[0].destCh = 0; + g_model.mixData[0].mltpx = MLTPX_ADD; + g_model.mixData[0].srcRaw = MIXSRC_Thr; + g_model.mixData[0].weight = 100; + g_model.mixData[0].swtch = SWSRC_THR; + g_model.mixData[0].speedUp = 10; + g_model.mixData[0].speedDown = 10; + setTrimValue(0, 2, 256); + + simuSetSwitch(0, 1); + CHECK_SLOW_MOVEMENT(0, 1, 100); + + simuSetSwitch(0, 0); + CHECK_SLOW_MOVEMENT(0, -1, 100); +} + TEST(Curves, LinearIntpol) { MODEL_RESET(); diff --git a/src/opentx.cpp b/src/opentx.cpp index 4b8ad71ea..ae9744904 100644 --- a/src/opentx.cpp +++ b/src/opentx.cpp @@ -2893,18 +2893,19 @@ void perOut(uint8_t mode, uint8_t tick10ms) if (apply_offset_and_curve) { int16_t offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, s_perout_flight_phase); // open.20.fsguruh if (offset) v += calc100toRESX_16Bits(offset); // @@@ open.20.fsguruh - } + //========== TRIMS =============== - if (!(mode & e_perout_mode_notrims)) { - int8_t mix_trim = md->carryTrim; - if (mix_trim < TRIM_ON) - mix_trim = -mix_trim - 1; - else if (mix_trim == TRIM_ON && k < NUM_STICKS) - mix_trim = k; - else - mix_trim = -1; - if (mix_trim >= 0) v += trims[mix_trim]; + if (!(mode & e_perout_mode_notrims)) { + int8_t mix_trim = md->carryTrim; + if (mix_trim < TRIM_ON) + mix_trim = -mix_trim - 1; + else if (mix_trim == TRIM_ON && k < NUM_STICKS) + mix_trim = k; + else + mix_trim = -1; + if (mix_trim >= 0) v += trims[mix_trim]; + } } // saves 12 bytes code if done here and not together with weight; unknown reason