mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-18 05:45:31 +03:00
Configurable Baro Type
We can disable/configure mag, acc, but why not baro? ident
This commit is contained in:
parent
6a24295525
commit
26f89b74bd
7 changed files with 12 additions and 8 deletions
|
@ -397,6 +397,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);
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,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;
|
||||||
|
|
|
@ -465,6 +465,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)) {
|
if (!sensorsAutodetect(&masterConfig.sensorAlignmentConfig, masterConfig.gyro_lpf, masterConfig.acc_hardware, masterConfig.mag_hardware, masterConfig.baro_hardware, currentProfile->mag_declination)) {
|
||||||
// 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,14 @@
|
||||||
#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
|
||||||
} baroSensor_e;
|
} baroSensor_e;
|
||||||
|
|
||||||
#define BARO_SAMPLE_COUNT_MAX 48
|
#define BARO_SAMPLE_COUNT_MAX 48
|
||||||
|
#define BARO_MAX BARO_MS5611
|
||||||
|
|
||||||
typedef struct barometerConfig_s {
|
typedef struct barometerConfig_s {
|
||||||
uint8_t baro_sample_count; // size of baro filter array
|
uint8_t baro_sample_count; // size of baro filter array
|
||||||
|
|
|
@ -408,12 +408,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
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ void reconfigureAlignment(sensorAlignmentConfig_t *sensorAlignmentConfig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, uint8_t magHardwareToUse, int16_t magDeclinationFromConfig)
|
bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, uint8_t magHardwareToUse, uint8_t baroHardwareToUse, int16_t magDeclinationFromConfig)
|
||||||
{
|
{
|
||||||
int16_t deg, min;
|
int16_t deg, min;
|
||||||
|
|
||||||
|
@ -598,7 +598,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);
|
bool sensorsAutodetect(sensorAlignmentConfig_t *sensorAlignmentConfig, uint16_t gyroLpf, uint8_t accHardwareToUse, uint8_t magHardwareToUse, uint8_t baroHardwareToUse, int16_t magDeclinationFromConfig);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue