1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 15:25:36 +03:00

Merge pull request #11439 from SteveCEvans/compass_timing

Perform compass reads in the background
This commit is contained in:
haslinghuis 2022-03-01 21:37:07 +01:00 committed by GitHub
commit 5b5df65934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 125 additions and 58 deletions

View file

@ -259,6 +259,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)
{
@ -351,7 +365,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