mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 09:45:37 +03:00
Split rx processing into three states to eliminate cycle time jitter
Allow tasks with state machines to control which state determines task duration Fix unit tests
This commit is contained in:
parent
bc4372588b
commit
25fcacf4c5
11 changed files with 89 additions and 20 deletions
|
@ -51,6 +51,8 @@
|
|||
|
||||
#include "sensors/sensors.h"
|
||||
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
#include "barometer.h"
|
||||
|
||||
baro_t baro; // barometer access functions
|
||||
|
@ -349,7 +351,7 @@ static uint32_t recalculateBarometerTotal(uint32_t pressureTotal, int32_t newPre
|
|||
nextSampleIndex = 0;
|
||||
baroReady = true;
|
||||
} else {
|
||||
nextSampleIndex = (currentSampleIndex + 1);
|
||||
nextSampleIndex = (currentSampleIndex + 1);
|
||||
}
|
||||
barometerSamples[currentSampleIndex] = applyBarometerMedianFilter(newPressureReading);
|
||||
|
||||
|
@ -385,6 +387,12 @@ uint32_t baroUpdate(void)
|
|||
debug[0] = state;
|
||||
}
|
||||
|
||||
// Tell the scheduler to ignore how long this task takes unless the pressure is being read
|
||||
// as that takes the longest
|
||||
if (state != BAROMETER_NEEDS_PRESSURE_READ) {
|
||||
ignoreTaskTime();
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
default:
|
||||
case BAROMETER_NEEDS_TEMPERATURE_START:
|
||||
|
@ -414,6 +422,8 @@ uint32_t baroUpdate(void)
|
|||
case BAROMETER_NEEDS_PRESSURE_READ:
|
||||
if (baro.dev.read_up(&baro.dev)) {
|
||||
state = BAROMETER_NEEDS_PRESSURE_SAMPLE;
|
||||
} else {
|
||||
ignoreTaskTime();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue