diff --git a/docs/Cli.md b/docs/Cli.md index 93b5bf182..f07eedbf9 100644 --- a/docs/Cli.md +++ b/docs/Cli.md @@ -201,7 +201,7 @@ Re-apply any new defaults as desired. | failsafe_min_usec | | 100 | 2000 | 985 | Profile | UINT16 | | failsafe_max_usec | | 100 | 3000 | 2115 | Profile | UINT16 | | gimbal_flags | When feature SERVO_TILT is enabled, this can be a combination of the following numbers: 1=normal gimbal (default), 2=tiltmix gimbal, 4=in PPM (or SERIALRX) input mode, this will forward AUX1..4 RC inputs to PWM5..8 pins | 0 | 255 | 1 | Profile | UINT8 | -| acc_hardware | This is used to suggest which accelerometer driver should load, or to force no accelerometer in case gyro-only flight is needed. Default (0) will attempt to auto-detect among enabled drivers. Otherwise, to force a particular device, set it to 1 for ADXL345, 2 for MPU6050 integrated accelerometer, 3 for MMA8452, 4 for BMA280, or 5 to disable accelerometer alltogether - resulting in gyro-only operation. | 0 | 9 | 0 | Master | UINT8 | +| acc_hardware | This is used to suggest which accelerometer driver should load, or to force no accelerometer in case gyro-only flight is needed. Default (0) will attempt to auto-detect among enabled drivers. Otherwise, to force a particular device, set it to 2 for ADXL345, 3 for MPU6050 integrated accelerometer, 4 for MMA8452, 5 for BMA280, 6 for LSM303DLHC, 7 for SPI_MPU6000, 8 for SPI_MPU6500 or 1 to disable accelerometer alltogether - resulting in gyro-only operation. | 0 | 9 | 0 | Master | UINT8 | | acc_lpf_factor | | 0 | 250 | 4 | Profile | UINT8 | | accxy_deadband | | 0 | 100 | 40 | Profile | UINT8 | | accz_deadband | | 0 | 100 | 40 | Profile | UINT8 | diff --git a/src/main/config/config.c b/src/main/config/config.c index ee1bfca7e..a9adeb3f6 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -119,7 +119,7 @@ profile_t *currentProfile; static uint8_t currentControlRateProfileIndex = 0; controlRateConfig_t *currentControlRateProfile; -static const uint8_t EEPROM_CONF_VERSION = 92; +static const uint8_t EEPROM_CONF_VERSION = 93; static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims) { diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index de9bf0d84..de20b073d 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -161,13 +161,11 @@ static const char * const sensorTypeNames[] = { "GYRO", "ACC", "BARO", "MAG", "SONAR", "GPS", "GPS+MAG", NULL }; -// FIXME the next time the EEPROM is bumped change the order of acc and gyro names so that "None" is second. - #define SENSOR_NAMES_MASK (SENSOR_GYRO | SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) static const char * const sensorHardwareNames[4][11] = { { "", "None", "MPU6050", "L3G4200D", "MPU3050", "L3GD20", "MPU6000", "MPU6500", "FAKE", NULL }, - { "", "ADXL345", "MPU6050", "MMA845x", "BMA280", "LSM303DLHC", "MPU6000", "MPU6500", "FAKE", "None", NULL }, + { "", "None", "ADXL345", "MPU6050", "MMA845x", "BMA280", "LSM303DLHC", "MPU6000", "MPU6500", "FAKE", NULL }, { "", "None", "BMP085", "MS5611", NULL }, { "", "None", "HMC5883", "AK8975", NULL } }; diff --git a/src/main/sensors/acceleration.h b/src/main/sensors/acceleration.h index 5b925b01d..198b12778 100644 --- a/src/main/sensors/acceleration.h +++ b/src/main/sensors/acceleration.h @@ -20,15 +20,15 @@ // Type of accelerometer used/detected typedef enum { ACC_DEFAULT = 0, - ACC_ADXL345 = 1, - ACC_MPU6050 = 2, - ACC_MMA8452 = 3, - ACC_BMA280 = 4, - ACC_LSM303DLHC = 5, - ACC_SPI_MPU6000 = 6, - ACC_SPI_MPU6500 = 7, - ACC_FAKE = 8, - ACC_NONE = 9 + ACC_NONE = 1, + ACC_ADXL345 = 2, + ACC_MPU6050 = 3, + ACC_MMA8452 = 4, + ACC_BMA280 = 5, + ACC_LSM303DLHC = 6, + ACC_SPI_MPU6000 = 7, + ACC_SPI_MPU6500 = 8, + ACC_FAKE = 9, } accelerationSensor_e; extern sensor_align_e accAlign; diff --git a/src/main/sensors/initialisation.c b/src/main/sensors/initialisation.c index cd90c28f3..d3bf32a0e 100644 --- a/src/main/sensors/initialisation.c +++ b/src/main/sensors/initialisation.c @@ -110,7 +110,7 @@ const mpu6050Config_t *selectMPU6050Config(void) #ifdef USE_FAKE_GYRO static void fakeGyroInit(void) {} static void fakeGyroRead(int16_t *gyroData) { - UNUSED(gyroData); + memset(gyroData, 0, sizeof(int16_t[XYZ_AXIS_COUNT])); } static void fakeGyroReadTemp(int16_t *tempData) { UNUSED(tempData); @@ -129,7 +129,7 @@ bool fakeGyroDetect(gyro_t *gyro, uint16_t lpf) #ifdef USE_FAKE_ACC static void fakeAccInit(void) {} static void fakeAccRead(int16_t *accData) { - UNUSED(accData); + memset(accData, 0, sizeof(int16_t[XYZ_AXIS_COUNT])); } bool fakeAccDetect(acc_t *acc) @@ -267,14 +267,6 @@ retry: switch (accHardwareToUse) { case ACC_DEFAULT: ; // fallthrough - case ACC_FAKE: -#ifdef USE_FAKE_ACC - if (fakeAccDetect(&acc)) { - accHardware = ACC_FAKE; - break; - } -#endif - ; // fallthrough case ACC_ADXL345: // ADXL345 #ifdef USE_ACC_ADXL345 acc_params.useFifo = false; @@ -365,6 +357,14 @@ retry: accHardware = ACC_SPI_MPU6500; break; } +#endif + ; // fallthrough + case ACC_FAKE: +#ifdef USE_FAKE_ACC + if (fakeAccDetect(&acc)) { + accHardware = ACC_FAKE; + break; + } #endif ; // fallthrough case ACC_NONE: // disable ACC