mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Some fixes for persistent stats.
This commit is contained in:
parent
ad00c6b66b
commit
1920a61226
4 changed files with 91 additions and 43 deletions
|
@ -270,7 +270,6 @@ static int adjustmentRangeValue = -1;
|
|||
|
||||
static int applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t adjustmentFunction, int delta)
|
||||
{
|
||||
|
||||
beeperConfirmationBeeps(delta > 0 ? 2 : 1);
|
||||
int newValue;
|
||||
switch (adjustmentFunction) {
|
||||
|
@ -427,7 +426,6 @@ static int applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t a
|
|||
break;
|
||||
};
|
||||
|
||||
setConfigDirty();
|
||||
return newValue;
|
||||
}
|
||||
|
||||
|
@ -435,10 +433,6 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
|
|||
{
|
||||
int newValue;
|
||||
|
||||
if (!controlRateConfig || !currentPidProfile) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (adjustmentFunction) {
|
||||
case ADJUSTMENT_RC_RATE:
|
||||
case ADJUSTMENT_ROLL_RC_RATE:
|
||||
|
@ -593,7 +587,6 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
|
|||
break;
|
||||
};
|
||||
|
||||
setConfigDirty();
|
||||
return newValue;
|
||||
}
|
||||
|
||||
|
@ -653,7 +646,6 @@ static uint8_t applySelectAdjustment(adjustmentFunction_e adjustmentFunction, ui
|
|||
beeperConfirmationBeeps(beeps);
|
||||
}
|
||||
|
||||
setConfigDirty();
|
||||
return position;
|
||||
}
|
||||
|
||||
|
@ -757,6 +749,9 @@ static void processStepwiseAdjustments(controlRateConfig_t *controlRateConfig, c
|
|||
}
|
||||
|
||||
int newValue = applyStepAdjustment(controlRateConfig, adjustmentFunction, delta);
|
||||
|
||||
setConfigDirty();
|
||||
|
||||
pidInitConfig(currentPidProfile);
|
||||
|
||||
adjustmentState->ready = false;
|
||||
|
@ -770,6 +765,14 @@ static void processStepwiseAdjustments(controlRateConfig_t *controlRateConfig, c
|
|||
}
|
||||
}
|
||||
|
||||
static void setConfigDirtyIfNotPermanent(const channelRange_t *range)
|
||||
{
|
||||
if (range->startStep == MIN_MODE_RANGE_STEP && range->endStep == MAX_MODE_RANGE_STEP) {
|
||||
// Only set the configuration dirty if this range is NOT permanently enabled (and the config thus never used).
|
||||
setConfigDirty();
|
||||
}
|
||||
}
|
||||
|
||||
static void processContinuosAdjustments(controlRateConfig_t *controlRateConfig)
|
||||
{
|
||||
for (int i = 0; i < continuosAdjustmentCount; i++) {
|
||||
|
@ -797,6 +800,8 @@ static void processContinuosAdjustments(controlRateConfig_t *controlRateConfig)
|
|||
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 &&
|
||||
|
@ -804,6 +809,9 @@ static void processContinuosAdjustments(controlRateConfig_t *controlRateConfig)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue