From d60b544e8c638309e5900f9cf599fa16a4d7443d Mon Sep 17 00:00:00 2001 From: 3djc Date: Mon, 3 Jul 2023 03:08:38 +0200 Subject: [PATCH] fix: Throttle stick not being detected properly (#3733) * Fix thottle timer * More THR source fixes --- radio/src/mixer.cpp | 6 +++--- radio/src/opentx.cpp | 4 ++-- radio/src/switches.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index 6904a769d5e..b49af813cf4 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -527,7 +527,7 @@ void evalInputs(uint8_t mode) #if defined(STICK_DEAD_ZONE) // dead zone invented by FlySky in my opinion it should goes into ADC // float calculations are not efficient - if (g_eeGeneral.stickDeadZone && ch != THR_STICK) { + if (g_eeGeneral.stickDeadZone && ch != inputMappingConvertMode(inputMappingGetThrottle())) { if (v > P_OFFSET) { // y=ax+b v = (int)((aParam * (float)v) - bParam); @@ -540,7 +540,7 @@ void evalInputs(uint8_t mode) } #endif - if (g_model.throttleReversed && ch==THR_STICK) { + if (g_model.throttleReversed && ch==inputMappingConvertMode(inputMappingGetThrottle())) { v = -v; } @@ -1174,7 +1174,7 @@ void doMixerPeriodicUpdates() val=0; // prevent val be negative, which would corrupt throttle trace and timers; could occur if safetyswitch is smaller than limits } else { - val = RESX + calibratedAnalogs[g_model.thrTraceSrc == 0 ? THR_STICK : g_model.thrTraceSrc + MAX_STICKS - 1]; + val = RESX + calibratedAnalogs[g_model.thrTraceSrc == 0 ? inputMappingConvertMode(inputMappingGetThrottle()) : g_model.thrTraceSrc + MAX_STICKS - 1]; } val >>= (RESX_SHIFT-6); // calibrate it (resolution increased by factor 4) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index ddb0b7222dd..88cf8b9934c 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -939,7 +939,7 @@ void checkTrims() #else phase = getTrimFlightMode(mixerCurrentFlightMode, idx); before = getTrimValue(phase, idx); - thro = (idx==THR_STICK && g_model.thrTrim); + thro = (idx==inputMappingConvertMode(inputMappingGetThrottle()) && 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) @@ -1223,7 +1223,7 @@ void instantTrim() auto controls = adcGetMaxInputs(ADC_INPUT_MAIN); for (uint8_t stick = 0; stick < controls; stick++) { - if (stick != THR_STICK) { // don't instant trim the throttle stick + if (stick != inputMappingConvertMode(inputMappingGetThrottle())) { // don't instant trim the throttle stick bool addTrim = false; int16_t delta = 0; uint8_t trimFlightMode = getTrimFlightMode(mixerCurrentFlightMode, stick); diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index f94766087ff..9d627dae5e2 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -352,7 +352,7 @@ getvalue_t getValueForLogicalSwitch(mixsrc_t i) int8_t trimIdx = virtualInputsTrims[i-MIXSRC_FIRST_INPUT]; if (trimIdx >= 0) { int16_t trim = trims[trimIdx]; - if (trimIdx == THR_STICK && g_model.throttleReversed) + if (trimIdx == inputMappingConvertMode(inputMappingGetThrottle()) && g_model.throttleReversed) result -= trim; else result += trim;