mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Avoided compass task wrapper function
This commit is contained in:
parent
b71fe232c3
commit
78cc4f65a1
3 changed files with 11 additions and 19 deletions
|
@ -262,9 +262,9 @@ bool compassInit(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
void compassUpdate(uint32_t currentTime, flightDynamicsTrims_t *magZero)
|
||||
void compassUpdate(timeUs_t currentTimeUs)
|
||||
{
|
||||
static uint32_t tCal = 0;
|
||||
static timeUs_t tCal = 0;
|
||||
static flightDynamicsTrims_t magZeroTempMin;
|
||||
static flightDynamicsTrims_t magZeroTempMax;
|
||||
|
||||
|
@ -274,8 +274,9 @@ void compassUpdate(uint32_t currentTime, flightDynamicsTrims_t *magZero)
|
|||
}
|
||||
alignSensors(mag.magADC, magDev.magAlign);
|
||||
|
||||
flightDynamicsTrims_t *magZero = &compassConfigMutable()->magZero;
|
||||
if (STATE(CALIBRATE_MAG)) {
|
||||
tCal = currentTime;
|
||||
tCal = currentTimeUs;
|
||||
for (int axis = 0; axis < 3; axis++) {
|
||||
magZero->raw[axis] = 0;
|
||||
magZeroTempMin.raw[axis] = mag.magADC[axis];
|
||||
|
@ -291,7 +292,7 @@ void compassUpdate(uint32_t currentTime, flightDynamicsTrims_t *magZero)
|
|||
}
|
||||
|
||||
if (tCal != 0) {
|
||||
if ((currentTime - tCal) < 30000000) { // 30s: you have 30s to turn the multi in all directions
|
||||
if ((currentTimeUs - tCal) < 30000000) { // 30s: you have 30s to turn the multi in all directions
|
||||
LED0_TOGGLE;
|
||||
for (int axis = 0; axis < 3; axis++) {
|
||||
if (mag.magADC[axis] < magZeroTempMin.raw[axis])
|
||||
|
|
|
@ -17,12 +17,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "pg/pg.h"
|
||||
|
||||
#include "drivers/io.h"
|
||||
#include "drivers/io_types.h"
|
||||
#include "drivers/sensor.h"
|
||||
#include "common/time.h"
|
||||
#include "pg/pg.h"
|
||||
#include "sensors/sensors.h"
|
||||
|
||||
|
||||
// Type of magnetometer used/detected
|
||||
typedef enum {
|
||||
MAG_DEFAULT = 0,
|
||||
|
@ -56,6 +57,5 @@ typedef struct compassConfig_s {
|
|||
PG_DECLARE(compassConfig_t, compassConfig);
|
||||
|
||||
bool compassInit(void);
|
||||
union flightDynamicsTrims_u;
|
||||
void compassUpdate(uint32_t currentTime, union flightDynamicsTrims_u *magZero);
|
||||
void compassUpdate(timeUs_t currentTime);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue