1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 23:35:34 +03:00

Perform compass reads in the background

This commit is contained in:
Steve Evans 2022-02-27 13:56:32 +00:00
parent 7b4415f062
commit 8ac81f86b2
7 changed files with 125 additions and 58 deletions

View file

@ -264,6 +264,20 @@ static void taskUpdateBaro(timeUs_t currentTimeUs)
}
#endif
#ifdef USE_MAG
static void taskUpdateMag(timeUs_t currentTimeUs)
{
UNUSED(currentTimeUs);
if (sensors(SENSOR_MAG)) {
const uint32_t newDeadline = compassUpdate(currentTimeUs);
if (newDeadline != 0) {
rescheduleTask(TASK_SELF, newDeadline);
}
}
}
#endif
#if defined(USE_RANGEFINDER)
void taskUpdateRangefinder(timeUs_t currentTimeUs)
{
@ -356,7 +370,7 @@ task_attribute_t task_attributes[TASK_COUNT] = {
#endif
#ifdef USE_MAG
[TASK_COMPASS] = DEFINE_TASK("COMPASS", NULL, NULL, compassUpdate,TASK_PERIOD_HZ(10), TASK_PRIORITY_LOW),
[TASK_COMPASS] = DEFINE_TASK("COMPASS", NULL, NULL, taskUpdateMag, TASK_PERIOD_HZ(10), TASK_PRIORITY_LOW),
#endif
#ifdef USE_BARO