From 6bd38ce13a89ade70aa8e83914063464a8d9750a Mon Sep 17 00:00:00 2001 From: 3djc Date: Sun, 4 Mar 2018 13:11:22 +0100 Subject: [PATCH] Replicate center trim beep behavior also when crossing trims (#5693) * Replicate center trim beep behavior also when crossing trims * Cosmetics --- radio/src/mixer.cpp | 2 +- radio/src/opentx.cpp | 4 ++-- radio/src/opentx.h | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index fbf37c0d4..9ce1b579a 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -647,7 +647,7 @@ int getStickTrimValue(int stick, int stickValue) return 0; int trim = trims[stick]; - if (stick == virtualInputsTrims[THR_STICK]) { + if (IS_THROTTLE_TRIM(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 fbecb6665..788f0501b 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1352,7 +1352,7 @@ uint8_t checkTrim(event_t event) #else before = getRawTrimValue(phase, idx); #endif - thro = (idx==THR_STICK && g_model.thrTrim); + thro = (IS_THROTTLE_TRIM(idx) && g_model.thrTrim); } #else phase = getTrimFlightMode(mixerCurrentFlightMode, idx); @@ -1361,7 +1361,7 @@ uint8_t checkTrim(event_t event) #else before = getRawTrimValue(phase, idx); #endif - thro = (idx==THR_STICK && g_model.thrTrim); + thro = (IS_THROTTLE_TRIM(idx) && 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 a748ced3f..a2187dcd9 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -338,6 +338,12 @@ 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