From b0483d4669cf572289718305bb69b3188d0c22d4 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Mon, 11 Nov 2019 11:10:40 -0500 Subject: [PATCH] Fix multi-range profile type adjustments Fixes support for the multi-range method of configuring profile type adjustments that stopped working when "slots" were removed. Although this type of setup will now work again, the correct method is to have a single adjustment set to the full channel range. --- src/main/fc/rc_adjustments.c | 72 ++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/fc/rc_adjustments.c b/src/main/fc/rc_adjustments.c index 44f395c1f..cb06279db 100644 --- a/src/main/fc/rc_adjustments.c +++ b/src/main/fc/rc_adjustments.c @@ -782,45 +782,45 @@ static void processContinuosAdjustments(controlRateConfig_t *controlRateConfig) const adjustmentConfig_t *adjustmentConfig = &defaultAdjustmentConfigs[adjustmentRange->adjustmentConfig - ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET]; const adjustmentFunction_e adjustmentFunction = adjustmentConfig->adjustmentFunction; - if (!isRangeActive(adjustmentRange->auxChannelIndex, &adjustmentRange->range) || - adjustmentFunction == ADJUSTMENT_NONE || - rcData[channelIndex] == adjustmentState->lastRcData) { - continue; - } - - adjustmentState->lastRcData = rcData[channelIndex]; - - int newValue = -1; - - if (adjustmentConfig->mode == ADJUSTMENT_MODE_SELECT) { - int switchPositions = adjustmentConfig->data.switchPositions; - if (adjustmentFunction == ADJUSTMENT_RATE_PROFILE && systemConfig()->rateProfile6PosSwitch) { - switchPositions = 6; - } - const uint16_t rangeWidth = (2100 - 900) / switchPositions; - const uint8_t position = (constrain(rcData[channelIndex], 900, 2100 - 1) - 900) / rangeWidth; - newValue = applySelectAdjustment(adjustmentFunction, position); - - setConfigDirtyIfNotPermanent(&adjustmentRange->range); - } else { - // If setting is defined for step adjustment and center value has been specified, apply values directly (scaled) from aux channel - if (adjustmentRange->adjustmentCenter && - (adjustmentConfig->mode == ADJUSTMENT_MODE_STEP)) { - int value = (((rcData[channelIndex] - PWM_RANGE_MIDDLE) * adjustmentRange->adjustmentScale) / (PWM_RANGE_MIDDLE - PWM_RANGE_MIN)) + adjustmentRange->adjustmentCenter; - - newValue = applyAbsoluteAdjustment(controlRateConfig, adjustmentFunction, value); - - setConfigDirtyIfNotPermanent(&adjustmentRange->range); - - pidInitConfig(currentPidProfile); - } - } - + if (isRangeActive(adjustmentRange->auxChannelIndex, &adjustmentRange->range) && + adjustmentFunction != ADJUSTMENT_NONE) { + + if (rcData[channelIndex] != adjustmentState->lastRcData) { + int newValue = -1; + + if (adjustmentConfig->mode == ADJUSTMENT_MODE_SELECT) { + int switchPositions = adjustmentConfig->data.switchPositions; + if (adjustmentFunction == ADJUSTMENT_RATE_PROFILE && systemConfig()->rateProfile6PosSwitch) { + switchPositions = 6; + } + const uint16_t rangeWidth = (2100 - 900) / switchPositions; + const uint8_t position = (constrain(rcData[channelIndex], 900, 2100 - 1) - 900) / rangeWidth; + newValue = applySelectAdjustment(adjustmentFunction, position); + + setConfigDirtyIfNotPermanent(&adjustmentRange->range); + } else { + // If setting is defined for step adjustment and center value has been specified, apply values directly (scaled) from aux channel + if (adjustmentRange->adjustmentCenter && + (adjustmentConfig->mode == ADJUSTMENT_MODE_STEP)) { + int value = (((rcData[channelIndex] - PWM_RANGE_MIDDLE) * adjustmentRange->adjustmentScale) / (PWM_RANGE_MIDDLE - PWM_RANGE_MIN)) + adjustmentRange->adjustmentCenter; + + newValue = applyAbsoluteAdjustment(controlRateConfig, adjustmentFunction, value); + + setConfigDirtyIfNotPermanent(&adjustmentRange->range); + + pidInitConfig(currentPidProfile); + } + } #if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS) - updateOsdAdjustmentData(newValue, adjustmentConfig->adjustmentFunction); + updateOsdAdjustmentData(newValue, adjustmentConfig->adjustmentFunction); #else - UNUSED(newValue); + UNUSED(newValue); #endif + adjustmentState->lastRcData = rcData[channelIndex]; + } + } else { + adjustmentState->lastRcData = 0; + } } } -- 2.11.4.GIT