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

Preparation for conversion to parameter groups 3

This commit is contained in:
Martin Budden 2017-02-01 10:32:27 +00:00
parent 5d5845d9af
commit a3951a3340
6 changed files with 67 additions and 46 deletions

View file

@ -24,6 +24,8 @@
#include "common/utils.h"
#include "config/feature.h"
#include "config/parameter_group.h"
#include "config/parameter_group_ids.h"
#include "fc/config.h"
#include "fc/runtime_config.h"
@ -52,50 +54,40 @@ static bool sonarDetect(void)
}
#endif
bool sensorsAutodetect(const gyroConfig_t *gyroConfig,
const accelerometerConfig_t *accelerometerConfig,
const compassConfig_t *compassConfig,
const barometerConfig_t *barometerConfig,
const sonarConfig_t *sonarConfig)
bool sensorsAutodetect(void)
{
// gyro must be initialised before accelerometer
if (!gyroInit(gyroConfig)) {
if (!gyroInit()) {
return false;
}
accInit(accelerometerConfig, gyro.targetLooptime);
accInit(accelerometerConfig(), gyro.targetLooptime);
mag.magneticDeclination = 0.0f; // TODO investigate if this is actually needed if there is no mag sensor or if the value stored in the config should be used.
#ifdef MAG
if (compassDetect(&mag.dev, compassConfig->mag_hardware)) {
compassInit(compassConfig);
if (compassDetect(&mag.dev, compassConfig()->mag_hardware)) {
compassInit(compassConfig());
}
#else
UNUSED(compassConfig);
#endif
#ifdef BARO
baroDetect(&baro.dev, barometerConfig->baro_hardware);
#else
UNUSED(barometerConfig);
baroDetect(&baro.dev, barometerConfig()->baro_hardware);
#endif
#ifdef SONAR
if (sonarDetect()) {
sonarInit(sonarConfig);
sonarInit(sonarConfig());
}
#else
UNUSED(sonarConfig);
#endif
if (gyroConfig->gyro_align != ALIGN_DEFAULT) {
gyro.dev.gyroAlign = gyroConfig->gyro_align;
if (gyroConfig()->gyro_align != ALIGN_DEFAULT) {
gyro.dev.gyroAlign = gyroConfig()->gyro_align;
}
if (accelerometerConfig->acc_align != ALIGN_DEFAULT) {
acc.dev.accAlign = accelerometerConfig->acc_align;
if (accelerometerConfig()->acc_align != ALIGN_DEFAULT) {
acc.dev.accAlign = accelerometerConfig()->acc_align;
}
if (compassConfig->mag_align != ALIGN_DEFAULT) {
mag.dev.magAlign = compassConfig->mag_align;
if (compassConfig()->mag_align != ALIGN_DEFAULT) {
mag.dev.magAlign = compassConfig()->mag_align;
}
return true;