mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
Move smoothing of rcData to rcCommand
This commit is contained in:
parent
2b722b6f82
commit
a31a962467
1 changed files with 8 additions and 6 deletions
|
@ -683,13 +683,13 @@ void filterRc(void){
|
||||||
// Set RC refresh rate for sampling and channels to filter
|
// Set RC refresh rate for sampling and channels to filter
|
||||||
initRxRefreshRate(&rxRefreshRate);
|
initRxRefreshRate(&rxRefreshRate);
|
||||||
|
|
||||||
filteredCycleTime = filterApplyPt1(cycleTime, &filteredCycleTimeState, 1, dT);
|
filteredCycleTime = filterApplyPt1(cycleTime, &filteredCycleTimeState, 1, dT);
|
||||||
rcInterpolationFactor = rxRefreshRate / filteredCycleTime + 1;
|
rcInterpolationFactor = rxRefreshRate / filteredCycleTime + 1;
|
||||||
|
|
||||||
if (isRXDataNew) {
|
if (isRXDataNew) {
|
||||||
for (int channel=0; channel < 4; channel++) {
|
for (int channel=0; channel < 4; channel++) {
|
||||||
deltaRC[channel] = rcData[channel] - (lastCommand[channel] - deltaRC[channel] * factor / rcInterpolationFactor);
|
deltaRC[channel] = rcCommand[channel] - (lastCommand[channel] - deltaRC[channel] * factor / rcInterpolationFactor);
|
||||||
lastCommand[channel] = rcData[channel];
|
lastCommand[channel] = rcCommand[channel];
|
||||||
}
|
}
|
||||||
|
|
||||||
isRXDataNew = false;
|
isRXDataNew = false;
|
||||||
|
@ -698,16 +698,17 @@ void filterRc(void){
|
||||||
factor--;
|
factor--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interpolate steps of rcData
|
// Interpolate steps of rcCommand
|
||||||
if (factor > 0) {
|
if (factor > 0) {
|
||||||
for (int channel=0; channel < 4; channel++) {
|
for (int channel=0; channel < 4; channel++) {
|
||||||
rcData[channel] = lastCommand[channel] - deltaRC[channel] * factor/rcInterpolationFactor;
|
rcCommand[channel] = lastCommand[channel] - deltaRC[channel] * factor/rcInterpolationFactor;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
factor = 0;
|
factor = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop(void)
|
void loop(void)
|
||||||
{
|
{
|
||||||
static uint32_t loopTime;
|
static uint32_t loopTime;
|
||||||
|
@ -791,9 +792,10 @@ void loop(void)
|
||||||
|
|
||||||
filterApply7TapFIR(gyroADC);
|
filterApply7TapFIR(gyroADC);
|
||||||
|
|
||||||
|
annexCode();
|
||||||
|
|
||||||
filterRc();
|
filterRc();
|
||||||
|
|
||||||
annexCode();
|
|
||||||
#if defined(BARO) || defined(SONAR)
|
#if defined(BARO) || defined(SONAR)
|
||||||
haveProcessedAnnexCodeOnce = true;
|
haveProcessedAnnexCodeOnce = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue