mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 22:05:17 +03:00
Selectable BARO (set baro_hardware)
Disabling baro will boost performance on FULL boards
This commit is contained in:
parent
f2c6822c81
commit
5390cdc804
7 changed files with 14 additions and 9 deletions
|
@ -128,7 +128,7 @@ static uint32_t activeFeaturesLatch = 0;
|
||||||
static uint8_t currentControlRateProfileIndex = 0;
|
static uint8_t currentControlRateProfileIndex = 0;
|
||||||
controlRateConfig_t *currentControlRateProfile;
|
controlRateConfig_t *currentControlRateProfile;
|
||||||
|
|
||||||
static const uint8_t EEPROM_CONF_VERSION = 104;
|
static const uint8_t EEPROM_CONF_VERSION = 105;
|
||||||
|
|
||||||
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
||||||
{
|
{
|
||||||
|
@ -392,6 +392,7 @@ static void resetConf(void)
|
||||||
masterConfig.gyroConfig.gyroMovementCalibrationThreshold = 32;
|
masterConfig.gyroConfig.gyroMovementCalibrationThreshold = 32;
|
||||||
|
|
||||||
masterConfig.mag_hardware = MAG_DEFAULT; // default/autodetect
|
masterConfig.mag_hardware = MAG_DEFAULT; // default/autodetect
|
||||||
|
masterConfig.baro_hardware = BARO_DEFAULT; // default/autodetect
|
||||||
|
|
||||||
resetBatteryConfig(&masterConfig.batteryConfig);
|
resetBatteryConfig(&masterConfig.batteryConfig);
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ typedef struct master_t {
|
||||||
gyroConfig_t gyroConfig;
|
gyroConfig_t gyroConfig;
|
||||||
|
|
||||||
uint8_t mag_hardware; // Which mag hardware to use on boards with more than one device
|
uint8_t mag_hardware; // Which mag hardware to use on boards with more than one device
|
||||||
|
uint8_t baro_hardware; // Barometer hardware to use
|
||||||
|
|
||||||
uint16_t max_angle_inclination; // max inclination allowed in angle (level) mode. default 500 (50 degrees).
|
uint16_t max_angle_inclination; // max inclination allowed in angle (level) mode. default 500 (50 degrees).
|
||||||
flightDynamicsTrims_t accZero;
|
flightDynamicsTrims_t accZero;
|
||||||
|
|
|
@ -464,6 +464,7 @@ const clivalue_t valueTable[] = {
|
||||||
{ "baro_noise_lpf", VAR_FLOAT | PROFILE_VALUE, &masterConfig.profile[0].barometerConfig.baro_noise_lpf, 0, 1 },
|
{ "baro_noise_lpf", VAR_FLOAT | PROFILE_VALUE, &masterConfig.profile[0].barometerConfig.baro_noise_lpf, 0, 1 },
|
||||||
{ "baro_cf_vel", VAR_FLOAT | PROFILE_VALUE, &masterConfig.profile[0].barometerConfig.baro_cf_vel, 0, 1 },
|
{ "baro_cf_vel", VAR_FLOAT | PROFILE_VALUE, &masterConfig.profile[0].barometerConfig.baro_cf_vel, 0, 1 },
|
||||||
{ "baro_cf_alt", VAR_FLOAT | PROFILE_VALUE, &masterConfig.profile[0].barometerConfig.baro_cf_alt, 0, 1 },
|
{ "baro_cf_alt", VAR_FLOAT | PROFILE_VALUE, &masterConfig.profile[0].barometerConfig.baro_cf_alt, 0, 1 },
|
||||||
|
{ "baro_hardware", VAR_UINT8 | MASTER_VALUE, &masterConfig.baro_hardware, 0, BARO_MAX },
|
||||||
|
|
||||||
{ "mag_hardware", VAR_UINT8 | MASTER_VALUE, &masterConfig.mag_hardware, 0, MAG_MAX },
|
{ "mag_hardware", VAR_UINT8 | MASTER_VALUE, &masterConfig.mag_hardware, 0, MAG_MAX },
|
||||||
{ "mag_declination", VAR_INT16 | PROFILE_VALUE, &masterConfig.profile[0].mag_declination, -18000, 18000 },
|
{ "mag_declination", VAR_INT16 | PROFILE_VALUE, &masterConfig.profile[0].mag_declination, -18000, 18000 },
|
||||||
|
|
|
@ -371,7 +371,7 @@ void init(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!sensorsAutodetect(&masterConfig.sensorAlignmentConfig, masterConfig.gyro_lpf, masterConfig.acc_hardware, masterConfig.mag_hardware, currentProfile->mag_declination, masterConfig.looptime, masterConfig.syncGyroToLoop)) {
|
if (!sensorsAutodetect(&masterConfig.sensorAlignmentConfig, masterConfig.gyro_lpf, masterConfig.acc_hardware, masterConfig.mag_hardware, masterConfig.baro_hardware, currentProfile->mag_declination, masterConfig.looptime, masterConfig.syncGyroToLoop)) {
|
||||||
// if gyro was not detected due to whatever reason, we give up now.
|
// if gyro was not detected due to whatever reason, we give up now.
|
||||||
failureMode(3);
|
failureMode(3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BARO_NONE = 0,
|
BARO_DEFAULT = 0,
|
||||||
BARO_DEFAULT = 1,
|
BARO_NONE = 1,
|
||||||
BARO_BMP085 = 2,
|
BARO_BMP085 = 2,
|
||||||
BARO_MS5611 = 3,
|
BARO_MS5611 = 3,
|
||||||
BARO_BMP280 = 4
|
BARO_BMP280 = 4
|
||||||
} baroSensor_e;
|
} baroSensor_e;
|
||||||
|
|
||||||
|
#define BARO_MAX BARO_BMP280
|
||||||
|
|
||||||
#define BARO_SAMPLE_COUNT_MAX 48
|
#define BARO_SAMPLE_COUNT_MAX 48
|
||||||
|
|
||||||
typedef struct barometerConfig_s {
|
typedef struct barometerConfig_s {
|
||||||
|
|
|
@ -410,12 +410,12 @@ retry:
|
||||||
sensorsSet(SENSOR_ACC);
|
sensorsSet(SENSOR_ACC);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void detectBaro()
|
static void detectBaro(baroSensor_e baroHardwareToUse)
|
||||||
{
|
{
|
||||||
#ifdef BARO
|
#ifdef BARO
|
||||||
// Detect what pressure sensors are available. baro->update() is set to sensor-specific update function
|
// Detect what pressure sensors are available. baro->update() is set to sensor-specific update function
|
||||||
|
|
||||||
baroSensor_e baroHardware = BARO_DEFAULT;
|
baroSensor_e baroHardware = baroHardwareToUse;
|
||||||
|
|
||||||
#ifdef USE_BARO_BMP085
|
#ifdef USE_BARO_BMP085
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ void reconfigureAlignment(sensorAlignmentConfig_t *sensorAlignmentConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, uint8_t magHardwareToUse, int16_t magDeclinationFromConfig, uint32_t looptime, uint8_t syncGyroToLoop)
|
bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, uint8_t magHardwareToUse, uint8_t baroHardwareToUse, int16_t magDeclinationFromConfig, uint32_t looptime, uint8_t syncGyroToLoop)
|
||||||
{
|
{
|
||||||
int16_t deg, min;
|
int16_t deg, min;
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
detectAcc(accHardwareToUse);
|
detectAcc(accHardwareToUse);
|
||||||
detectBaro();
|
detectBaro(baroHardwareToUse);
|
||||||
|
|
||||||
|
|
||||||
// Now time to init things, acc first
|
// Now time to init things, acc first
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, uint8_t magHardwareToUse, int16_t magDeclinationFromConfig, uint32_t looptime, uint8_t syncGyroToLoop);
|
bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, uint8_t magHardwareToUse, uint8_t baroHardwareToUse, int16_t magDeclinationFromConfig, uint32_t looptime, uint8_t syncGyroToLoop);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue