mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-25 17:25:18 +03:00
Add back sensor autodetection; Autodetection is used to update and save config
This commit is contained in:
parent
00a58e0450
commit
8909cd8374
11 changed files with 183 additions and 52 deletions
|
@ -505,9 +505,24 @@ static void resetConf(void)
|
||||||
gyroConfig()->gyroMovementCalibrationThreshold = 32;
|
gyroConfig()->gyroMovementCalibrationThreshold = 32;
|
||||||
|
|
||||||
accelerometerConfig()->acc_hardware = ACC_AUTODETECT; // default/autodetect
|
accelerometerConfig()->acc_hardware = ACC_AUTODETECT; // default/autodetect
|
||||||
|
|
||||||
|
#ifdef MAG
|
||||||
|
compassConfig()->mag_hardware = MAG_AUTODETECT;
|
||||||
|
#else
|
||||||
compassConfig()->mag_hardware = MAG_NONE;
|
compassConfig()->mag_hardware = MAG_NONE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BARO
|
||||||
|
barometerConfig()->baro_hardware = BARO_AUTODETECT;
|
||||||
|
#else
|
||||||
barometerConfig()->baro_hardware = BARO_NONE;
|
barometerConfig()->baro_hardware = BARO_NONE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PITOT
|
||||||
|
pitotmeterConfig()->pitot_hardware = PITOT_AUTODETECT;
|
||||||
|
#else
|
||||||
pitotmeterConfig()->pitot_hardware = PITOT_NONE;
|
pitotmeterConfig()->pitot_hardware = PITOT_NONE;
|
||||||
|
#endif
|
||||||
|
|
||||||
resetBatteryConfig(&masterConfig.batteryConfig);
|
resetBatteryConfig(&masterConfig.batteryConfig);
|
||||||
|
|
||||||
|
|
|
@ -234,13 +234,13 @@ static const char * const gyroNames[] = { "NONE", "AUTO", "MPU6050", "L3G4200D",
|
||||||
// sync with accelerationSensor_e
|
// sync with accelerationSensor_e
|
||||||
static const char * const accNames[] = { "NONE", "AUTO", "ADXL345", "MPU6050", "MMA845x", "BMA280", "LSM303DLHC", "MPU6000", "MPU6500", "MPU9250", "FAKE"};
|
static const char * const accNames[] = { "NONE", "AUTO", "ADXL345", "MPU6050", "MMA845x", "BMA280", "LSM303DLHC", "MPU6000", "MPU6500", "MPU9250", "FAKE"};
|
||||||
// sync with baroSensor_e
|
// sync with baroSensor_e
|
||||||
static const char * const baroNames[] = { "NONE", "BMP085", "MS5611", "BMP280", "FAKE"};
|
static const char * const baroNames[] = { "NONE", "AUTO", "BMP085", "MS5611", "BMP280", "FAKE"};
|
||||||
// sync with magSensor_e
|
// sync with magSensor_e
|
||||||
static const char * const magNames[] = { "NONE", "HMC5883", "AK8975", "GPSMAG", "MAG3110", "AK8963", "IST8310", "FAKE"};
|
static const char * const magNames[] = { "NONE", "AUTO", "HMC5883", "AK8975", "GPSMAG", "MAG3110", "AK8963", "IST8310", "FAKE"};
|
||||||
// sycn with rangefinderType_e
|
// sycn with rangefinderType_e
|
||||||
static const char * const rangefinderNames[] = { "NONE", "HCSR04", "SRF10"};
|
static const char * const rangefinderNames[] = { "NONE", "HCSR04", "SRF10"};
|
||||||
// sync with pitotSensor_e
|
// sync with pitotSensor_e
|
||||||
static const char * const pitotmeterNames[] = { "NONE", "MS4525", "FAKE"};
|
static const char * const pitotmeterNames[] = { "NONE", "AUTO", "MS4525", "FAKE"};
|
||||||
|
|
||||||
#if (FLASH_SIZE > 64)
|
#if (FLASH_SIZE > 64)
|
||||||
// sync this with sensors_e
|
// sync this with sensors_e
|
||||||
|
|
|
@ -102,7 +102,11 @@ retry:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
; // fallthrough
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (accHardwareToUse != ACC_AUTODETECT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ACC_LSM303DLHC:
|
case ACC_LSM303DLHC:
|
||||||
#ifdef USE_ACC_LSM303DLHC
|
#ifdef USE_ACC_LSM303DLHC
|
||||||
if (lsm303dlhcAccDetect(dev)) {
|
if (lsm303dlhcAccDetect(dev)) {
|
||||||
|
@ -113,7 +117,11 @@ retry:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
; // fallthrough
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (accHardwareToUse != ACC_AUTODETECT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ACC_MPU6050: // MPU6050
|
case ACC_MPU6050: // MPU6050
|
||||||
#ifdef USE_ACC_MPU6050
|
#ifdef USE_ACC_MPU6050
|
||||||
if (mpu6050AccDetect(dev)) {
|
if (mpu6050AccDetect(dev)) {
|
||||||
|
@ -124,7 +132,11 @@ retry:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
; // fallthrough
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (accHardwareToUse != ACC_AUTODETECT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ACC_MMA8452: // MMA8452
|
case ACC_MMA8452: // MMA8452
|
||||||
#ifdef USE_ACC_MMA8452
|
#ifdef USE_ACC_MMA8452
|
||||||
#ifdef NAZE
|
#ifdef NAZE
|
||||||
|
@ -140,7 +152,11 @@ retry:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
; // fallthrough
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (accHardwareToUse != ACC_AUTODETECT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ACC_BMA280: // BMA280
|
case ACC_BMA280: // BMA280
|
||||||
#ifdef USE_ACC_BMA280
|
#ifdef USE_ACC_BMA280
|
||||||
if (bma280Detect(dev)) {
|
if (bma280Detect(dev)) {
|
||||||
|
@ -151,7 +167,11 @@ retry:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
; // fallthrough
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (accHardwareToUse != ACC_AUTODETECT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ACC_MPU6000:
|
case ACC_MPU6000:
|
||||||
#ifdef USE_ACC_SPI_MPU6000
|
#ifdef USE_ACC_SPI_MPU6000
|
||||||
if (mpu6000SpiAccDetect(dev)) {
|
if (mpu6000SpiAccDetect(dev)) {
|
||||||
|
@ -162,7 +182,11 @@ retry:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
; // fallthrough
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (accHardwareToUse != ACC_AUTODETECT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ACC_MPU6500:
|
case ACC_MPU6500:
|
||||||
#if defined(USE_ACC_MPU6500) || defined(USE_ACC_SPI_MPU6500)
|
#if defined(USE_ACC_MPU6500) || defined(USE_ACC_SPI_MPU6500)
|
||||||
#ifdef USE_ACC_SPI_MPU6500
|
#ifdef USE_ACC_SPI_MPU6500
|
||||||
|
@ -177,6 +201,11 @@ retry:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (accHardwareToUse != ACC_AUTODETECT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ACC_MPU9250:
|
case ACC_MPU9250:
|
||||||
#ifdef USE_ACC_SPI_MPU9250
|
#ifdef USE_ACC_SPI_MPU9250
|
||||||
if (mpu9250SpiAccDetect(dev)) {
|
if (mpu9250SpiAccDetect(dev)) {
|
||||||
|
@ -187,7 +216,11 @@ retry:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
; // fallthrough
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (accHardwareToUse != ACC_AUTODETECT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ACC_FAKE:
|
case ACC_FAKE:
|
||||||
#ifdef USE_FAKE_ACC
|
#ifdef USE_FAKE_ACC
|
||||||
if (fakeAccDetect(dev)) {
|
if (fakeAccDetect(dev)) {
|
||||||
|
@ -195,17 +228,14 @@ retry:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
; // fallthrough
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
case ACC_NONE: // disable ACC
|
if (accHardwareToUse != ACC_AUTODETECT) {
|
||||||
accHardware = ACC_NONE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Found anything? Check if error or ACC is really missing.
|
case ACC_NONE: // disable ACC
|
||||||
if (accHardware == ACC_NONE && accHardwareToUse != ACC_AUTODETECT && accHardwareToUse != ACC_NONE) {
|
accHardware = ACC_NONE;
|
||||||
// Nothing was found and we have a forced sensor that isn't present.
|
break;
|
||||||
accHardwareToUse = ACC_AUTODETECT;
|
|
||||||
goto retry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addBootlogEvent6(BOOT_EVENT_ACC_DETECTION, BOOT_EVENT_FLAGS_NONE, accHardware, 0, 0, 0);
|
addBootlogEvent6(BOOT_EVENT_ACC_DETECTION, BOOT_EVENT_FLAGS_NONE, accHardware, 0, 0, 0);
|
||||||
|
|
|
@ -79,37 +79,54 @@ bool baroDetect(baroDev_t *dev, baroSensor_e baroHardwareToUse)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (baroHardwareToUse) {
|
switch (baroHardwareToUse) {
|
||||||
|
case BARO_AUTODETECT:
|
||||||
case BARO_BMP085:
|
case BARO_BMP085:
|
||||||
#ifdef USE_BARO_BMP085
|
#ifdef USE_BARO_BMP085
|
||||||
if (bmp085Detect(bmp085Config, dev)) {
|
if (bmp085Detect(bmp085Config, dev)) {
|
||||||
baroHardware = BARO_BMP085;
|
baroHardware = BARO_BMP085;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (baroHardwareToUse != BARO_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case BARO_MS5611:
|
case BARO_MS5611:
|
||||||
#ifdef USE_BARO_MS5611
|
#ifdef USE_BARO_MS5611
|
||||||
if (ms5611Detect(dev)) {
|
if (ms5611Detect(dev)) {
|
||||||
baroHardware = BARO_MS5611;
|
baroHardware = BARO_MS5611;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (baroHardwareToUse != BARO_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case BARO_BMP280:
|
case BARO_BMP280:
|
||||||
#if defined(USE_BARO_BMP280) || defined(USE_BARO_SPI_BMP280)
|
#if defined(USE_BARO_BMP280) || defined(USE_BARO_SPI_BMP280)
|
||||||
if (bmp280Detect(dev)) {
|
if (bmp280Detect(dev)) {
|
||||||
baroHardware = BARO_BMP280;
|
baroHardware = BARO_BMP280;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (baroHardwareToUse != BARO_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case BARO_FAKE:
|
case BARO_FAKE:
|
||||||
#ifdef USE_FAKE_BARO
|
#ifdef USE_FAKE_BARO
|
||||||
if (fakeBaroDetect(dev)) {
|
if (fakeBaroDetect(dev)) {
|
||||||
baroHardware = BARO_FAKE;
|
baroHardware = BARO_FAKE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (baroHardwareToUse != BARO_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case BARO_NONE:
|
case BARO_NONE:
|
||||||
baroHardware = BARO_NONE;
|
baroHardware = BARO_NONE;
|
||||||
|
|
|
@ -21,10 +21,11 @@
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BARO_NONE = 0,
|
BARO_NONE = 0,
|
||||||
BARO_BMP085 = 1,
|
BARO_AUTODETECT = 1,
|
||||||
BARO_MS5611 = 2,
|
BARO_BMP085 = 2,
|
||||||
BARO_BMP280 = 3,
|
BARO_MS5611 = 3,
|
||||||
BARO_FAKE = 4,
|
BARO_BMP280 = 4,
|
||||||
|
BARO_FAKE = 5,
|
||||||
BARO_MAX = BARO_FAKE
|
BARO_MAX = BARO_FAKE
|
||||||
} baroSensor_e;
|
} baroSensor_e;
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse)
|
||||||
dev->magAlign = ALIGN_DEFAULT;
|
dev->magAlign = ALIGN_DEFAULT;
|
||||||
|
|
||||||
switch(magHardwareToUse) {
|
switch(magHardwareToUse) {
|
||||||
|
case MAG_AUTODETECT:
|
||||||
case MAG_HMC5883:
|
case MAG_HMC5883:
|
||||||
#ifdef USE_MAG_HMC5883
|
#ifdef USE_MAG_HMC5883
|
||||||
if (hmc5883lDetect(dev, hmc5883Config)) {
|
if (hmc5883lDetect(dev, hmc5883Config)) {
|
||||||
|
@ -101,9 +102,13 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse)
|
||||||
dev->magAlign = MAG_HMC5883_ALIGN;
|
dev->magAlign = MAG_HMC5883_ALIGN;
|
||||||
#endif
|
#endif
|
||||||
magHardware = MAG_HMC5883;
|
magHardware = MAG_HMC5883;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (magHardwareToUse != MAG_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MAG_AK8975:
|
case MAG_AK8975:
|
||||||
#ifdef USE_MAG_AK8975
|
#ifdef USE_MAG_AK8975
|
||||||
|
@ -112,9 +117,13 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse)
|
||||||
dev->magAlign = MAG_AK8975_ALIGN;
|
dev->magAlign = MAG_AK8975_ALIGN;
|
||||||
#endif
|
#endif
|
||||||
magHardware = MAG_AK8975;
|
magHardware = MAG_AK8975;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (magHardwareToUse != MAG_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MAG_AK8963:
|
case MAG_AK8963:
|
||||||
#ifdef USE_MAG_AK8963
|
#ifdef USE_MAG_AK8963
|
||||||
|
@ -123,9 +132,13 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse)
|
||||||
dev->magAlign = MAG_AK8963_ALIGN;
|
dev->magAlign = MAG_AK8963_ALIGN;
|
||||||
#endif
|
#endif
|
||||||
magHardware = MAG_AK8963;
|
magHardware = MAG_AK8963;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (magHardwareToUse != MAG_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MAG_GPS:
|
case MAG_GPS:
|
||||||
#ifdef GPS
|
#ifdef GPS
|
||||||
|
@ -134,9 +147,13 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse)
|
||||||
dev->magAlign = MAG_GPS_ALIGN;
|
dev->magAlign = MAG_GPS_ALIGN;
|
||||||
#endif
|
#endif
|
||||||
magHardware = MAG_GPS;
|
magHardware = MAG_GPS;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (magHardwareToUse != MAG_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MAG_MAG3110:
|
case MAG_MAG3110:
|
||||||
#ifdef USE_MAG_MAG3110
|
#ifdef USE_MAG_MAG3110
|
||||||
|
@ -145,9 +162,13 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse)
|
||||||
dev->magAlign = MAG_MAG3110_ALIGN;
|
dev->magAlign = MAG_MAG3110_ALIGN;
|
||||||
#endif
|
#endif
|
||||||
magHardware = MAG_MAG3110;
|
magHardware = MAG_MAG3110;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (magHardwareToUse != MAG_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MAG_IST8310:
|
case MAG_IST8310:
|
||||||
#ifdef USE_MAG_IST8310
|
#ifdef USE_MAG_IST8310
|
||||||
|
@ -156,17 +177,25 @@ bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse)
|
||||||
dev->magAlign = MAG_IST8310_ALIGN;
|
dev->magAlign = MAG_IST8310_ALIGN;
|
||||||
#endif
|
#endif
|
||||||
magHardware = MAG_IST8310;
|
magHardware = MAG_IST8310;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (magHardwareToUse != MAG_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MAG_FAKE:
|
case MAG_FAKE:
|
||||||
#ifdef USE_FAKE_MAG
|
#ifdef USE_FAKE_MAG
|
||||||
if (fakeMagDetect(dev)) {
|
if (fakeMagDetect(dev)) {
|
||||||
magHardware = MAG_FAKE;
|
magHardware = MAG_FAKE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (magHardwareToUse != MAG_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MAG_NONE:
|
case MAG_NONE:
|
||||||
magHardware = MAG_NONE;
|
magHardware = MAG_NONE;
|
||||||
|
|
|
@ -26,13 +26,14 @@
|
||||||
// Type of magnetometer used/detected
|
// Type of magnetometer used/detected
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MAG_NONE = 0,
|
MAG_NONE = 0,
|
||||||
MAG_HMC5883 = 1,
|
MAG_AUTODETECT = 1,
|
||||||
MAG_AK8975 = 2,
|
MAG_HMC5883 = 2,
|
||||||
MAG_GPS = 3,
|
MAG_AK8975 = 3,
|
||||||
MAG_MAG3110 = 4,
|
MAG_GPS = 4,
|
||||||
MAG_AK8963 = 5,
|
MAG_MAG3110 = 5,
|
||||||
MAG_IST8310 = 6,
|
MAG_AK8963 = 6,
|
||||||
MAG_FAKE = 7,
|
MAG_IST8310 = 7,
|
||||||
|
MAG_FAKE = 8,
|
||||||
MAG_MAX = MAG_FAKE
|
MAG_MAX = MAG_FAKE
|
||||||
} magSensor_e;
|
} magSensor_e;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
|
#include "config/config_eeprom.h"
|
||||||
|
|
||||||
#include "drivers/logging.h"
|
#include "drivers/logging.h"
|
||||||
|
|
||||||
|
@ -42,11 +43,13 @@ uint8_t detectedSensors[SENSOR_INDEX_COUNT] = { GYRO_NONE, ACC_NONE, BARO_NONE,
|
||||||
|
|
||||||
|
|
||||||
bool sensorsAutodetect(const gyroConfig_t *gyroConfig,
|
bool sensorsAutodetect(const gyroConfig_t *gyroConfig,
|
||||||
const accelerometerConfig_t *accConfig,
|
accelerometerConfig_t *accConfig,
|
||||||
const compassConfig_t *compassConfig,
|
compassConfig_t *compassConfig,
|
||||||
const barometerConfig_t *baroConfig,
|
barometerConfig_t *baroConfig,
|
||||||
const pitotmeterConfig_t *pitotConfig)
|
pitotmeterConfig_t *pitotConfig)
|
||||||
{
|
{
|
||||||
|
bool eepromUpdatePending = false;
|
||||||
|
|
||||||
if (!gyroInit(gyroConfig)) {
|
if (!gyroInit(gyroConfig)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -99,5 +102,30 @@ bool sensorsAutodetect(const gyroConfig_t *gyroConfig,
|
||||||
mag.dev.magAlign = compassConfig->mag_align;
|
mag.dev.magAlign = compassConfig->mag_align;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if sensor autodetection was requested for some sensors and */
|
||||||
|
if (accConfig->acc_hardware == ACC_AUTODETECT) {
|
||||||
|
accConfig->acc_hardware = detectedSensors[SENSOR_INDEX_ACC];
|
||||||
|
eepromUpdatePending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (baroConfig->baro_hardware == BARO_AUTODETECT) {
|
||||||
|
baroConfig->baro_hardware = detectedSensors[SENSOR_INDEX_BARO];
|
||||||
|
eepromUpdatePending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compassConfig->mag_hardware == MAG_AUTODETECT) {
|
||||||
|
compassConfig->mag_hardware = detectedSensors[SENSOR_INDEX_MAG];
|
||||||
|
eepromUpdatePending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pitotConfig->pitot_hardware == PITOT_AUTODETECT) {
|
||||||
|
pitotConfig->pitot_hardware = detectedSensors[SENSOR_INDEX_PITOT];
|
||||||
|
eepromUpdatePending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (eepromUpdatePending) {
|
||||||
|
writeEEPROM();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
bool sensorsAutodetect(const gyroConfig_t *gyroConfig,
|
bool sensorsAutodetect(const gyroConfig_t *gyroConfig,
|
||||||
const accelerometerConfig_t *accConfig,
|
accelerometerConfig_t *accConfig,
|
||||||
const compassConfig_t *compassConfig,
|
compassConfig_t *compassConfig,
|
||||||
const barometerConfig_t *baroConfig,
|
barometerConfig_t *baroConfig,
|
||||||
const pitotmeterConfig_t *pitotConfig);
|
pitotmeterConfig_t *pitotConfig);
|
||||||
|
|
|
@ -54,21 +54,30 @@ bool pitotDetect(pitotDev_t *dev, uint8_t pitotHardwareToUse)
|
||||||
requestedSensors[SENSOR_INDEX_PITOT] = pitotHardwareToUse;
|
requestedSensors[SENSOR_INDEX_PITOT] = pitotHardwareToUse;
|
||||||
|
|
||||||
switch (pitotHardwareToUse) {
|
switch (pitotHardwareToUse) {
|
||||||
|
case PITOT_AUTODETECT:
|
||||||
case PITOT_MS4525:
|
case PITOT_MS4525:
|
||||||
#ifdef USE_PITOT_MS4525
|
#ifdef USE_PITOT_MS4525
|
||||||
if (ms4525Detect(dev)) {
|
if (ms4525Detect(dev)) {
|
||||||
pitotHardware = PITOT_MS4525;
|
pitotHardware = PITOT_MS4525;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (pitotHardwareToUse != PITOT_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case PITOT_FAKE:
|
case PITOT_FAKE:
|
||||||
#ifdef USE_PITOT_FAKE
|
#ifdef USE_PITOT_FAKE
|
||||||
if (fakePitotDetect(&pitot)) {
|
if (fakePitotDetect(&pitot)) {
|
||||||
pitotHardware = PITOT_FAKE;
|
pitotHardware = PITOT_FAKE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
|
||||||
|
if (pitotHardwareToUse != PITOT_AUTODETECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case PITOT_NONE:
|
case PITOT_NONE:
|
||||||
pitotHardware = PITOT_NONE;
|
pitotHardware = PITOT_NONE;
|
||||||
|
|
|
@ -21,8 +21,9 @@
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PITOT_NONE = 0,
|
PITOT_NONE = 0,
|
||||||
PITOT_MS4525 = 1,
|
PITOT_AUTODETECT = 1,
|
||||||
PITOT_FAKE = 2,
|
PITOT_MS4525 = 2,
|
||||||
|
PITOT_FAKE = 3,
|
||||||
} pitotSensor_e;
|
} pitotSensor_e;
|
||||||
|
|
||||||
#define PITOT_MAX PITOT_FAKE
|
#define PITOT_MAX PITOT_FAKE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue