mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 23:05:19 +03:00
Fix multi-range profile type adjustments (#9162)
Fix multi-range profile type adjustments
This commit is contained in:
commit
ab43b3a1e5
1 changed files with 30 additions and 30 deletions
|
@ -782,45 +782,45 @@ static void processContinuosAdjustments(controlRateConfig_t *controlRateConfig)
|
||||||
const adjustmentConfig_t *adjustmentConfig = &defaultAdjustmentConfigs[adjustmentRange->adjustmentConfig - ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET];
|
const adjustmentConfig_t *adjustmentConfig = &defaultAdjustmentConfigs[adjustmentRange->adjustmentConfig - ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET];
|
||||||
const adjustmentFunction_e adjustmentFunction = adjustmentConfig->adjustmentFunction;
|
const adjustmentFunction_e adjustmentFunction = adjustmentConfig->adjustmentFunction;
|
||||||
|
|
||||||
if (!isRangeActive(adjustmentRange->auxChannelIndex, &adjustmentRange->range) ||
|
if (isRangeActive(adjustmentRange->auxChannelIndex, &adjustmentRange->range) &&
|
||||||
adjustmentFunction == ADJUSTMENT_NONE ||
|
adjustmentFunction != ADJUSTMENT_NONE) {
|
||||||
rcData[channelIndex] == adjustmentState->lastRcData) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
adjustmentState->lastRcData = rcData[channelIndex];
|
if (rcData[channelIndex] != adjustmentState->lastRcData) {
|
||||||
|
int newValue = -1;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (adjustmentConfig->mode == ADJUSTMENT_MODE_SELECT) {
|
setConfigDirtyIfNotPermanent(&adjustmentRange->range);
|
||||||
int switchPositions = adjustmentConfig->data.switchPositions;
|
} else {
|
||||||
if (adjustmentFunction == ADJUSTMENT_RATE_PROFILE && systemConfig()->rateProfile6PosSwitch) {
|
// If setting is defined for step adjustment and center value has been specified, apply values directly (scaled) from aux channel
|
||||||
switchPositions = 6;
|
if (adjustmentRange->adjustmentCenter &&
|
||||||
}
|
(adjustmentConfig->mode == ADJUSTMENT_MODE_STEP)) {
|
||||||
const uint16_t rangeWidth = (2100 - 900) / switchPositions;
|
int value = (((rcData[channelIndex] - PWM_RANGE_MIDDLE) * adjustmentRange->adjustmentScale) / (PWM_RANGE_MIDDLE - PWM_RANGE_MIN)) + adjustmentRange->adjustmentCenter;
|
||||||
const uint8_t position = (constrain(rcData[channelIndex], 900, 2100 - 1) - 900) / rangeWidth;
|
|
||||||
newValue = applySelectAdjustment(adjustmentFunction, position);
|
|
||||||
|
|
||||||
setConfigDirtyIfNotPermanent(&adjustmentRange->range);
|
newValue = applyAbsoluteAdjustment(controlRateConfig, adjustmentFunction, value);
|
||||||
} 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);
|
||||||
|
|
||||||
setConfigDirtyIfNotPermanent(&adjustmentRange->range);
|
|
||||||
|
|
||||||
pidInitConfig(currentPidProfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
pidInitConfig(currentPidProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
|
#if defined(USE_OSD) && defined(USE_OSD_ADJUSTMENTS)
|
||||||
updateOsdAdjustmentData(newValue, adjustmentConfig->adjustmentFunction);
|
updateOsdAdjustmentData(newValue, adjustmentConfig->adjustmentFunction);
|
||||||
#else
|
#else
|
||||||
UNUSED(newValue);
|
UNUSED(newValue);
|
||||||
#endif
|
#endif
|
||||||
|
adjustmentState->lastRcData = rcData[channelIndex];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
adjustmentState->lastRcData = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue