1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00

Split config_storage.h into config_master.h and config_profile.h to

separate concerns and help reduce and clarify dependencies.

cfg and mcfg are too similarly named and are not obvious.  Renamed cfg
to currentProfile and mcfg to masterConfig.  This will increase source
code line length somewhat but that's ok; lines of code doing too much
are now easier to spot.
This commit is contained in:
Dominic Clifton 2014-04-21 23:08:25 +01:00
parent dab04de35e
commit f8d0dd98f7
18 changed files with 677 additions and 672 deletions

View file

@ -38,12 +38,12 @@ void sensorsAutodetect(void)
memset(&gyro, sizeof(gyro), 0);
// Autodetect gyro hardware. We have MPU3050 or MPU6050.
if (mpu6050Detect(&acc, &gyro, mcfg.gyro_lpf)) {
if (mpu6050Detect(&acc, &gyro, masterConfig.gyro_lpf)) {
haveMpu6k = true;
gyroAlign = CW0_DEG; // default NAZE alignment
} else if (l3g4200dDetect(&gyro, mcfg.gyro_lpf)) {
} else if (l3g4200dDetect(&gyro, masterConfig.gyro_lpf)) {
gyroAlign = CW0_DEG;
} else if (mpu3050Detect(&gyro, mcfg.gyro_lpf)) {
} else if (mpu3050Detect(&gyro, masterConfig.gyro_lpf)) {
gyroAlign = CW0_DEG;
} else {
// if this fails, we get a beep + blink pattern. we're doomed, no gyro or i2c error.
@ -52,7 +52,7 @@ void sensorsAutodetect(void)
// Accelerometer. Fuck it. Let user break shit.
retry:
switch (mcfg.acc_hardware) {
switch (masterConfig.acc_hardware) {
case ACC_NONE: // disable ACC
sensorsClear(SENSOR_ACC);
break;
@ -64,15 +64,15 @@ retry:
accHardware = ACC_ADXL345;
accAlign = CW270_DEG; // default NAZE alignment
}
if (mcfg.acc_hardware == ACC_ADXL345)
if (masterConfig.acc_hardware == ACC_ADXL345)
break;
; // fallthrough
case ACC_MPU6050: // MPU6050
if (haveMpu6k) {
mpu6050Detect(&acc, &gyro, mcfg.gyro_lpf); // yes, i'm rerunning it again. re-fill acc struct
mpu6050Detect(&acc, &gyro, masterConfig.gyro_lpf); // yes, i'm rerunning it again. re-fill acc struct
accHardware = ACC_MPU6050;
accAlign = CW0_DEG; // default NAZE alignment
if (mcfg.acc_hardware == ACC_MPU6050)
if (masterConfig.acc_hardware == ACC_MPU6050)
break;
}
; // fallthrough
@ -81,7 +81,7 @@ retry:
if (mma8452Detect(&acc)) {
accHardware = ACC_MMA8452;
accAlign = CW90_DEG; // default NAZE alignment
if (mcfg.acc_hardware == ACC_MMA8452)
if (masterConfig.acc_hardware == ACC_MMA8452)
break;
}
; // fallthrough
@ -89,7 +89,7 @@ retry:
if (bma280Detect(&acc)) {
accHardware = ACC_BMA280;
accAlign = CW0_DEG; //
if (mcfg.acc_hardware == ACC_BMA280)
if (masterConfig.acc_hardware == ACC_BMA280)
break;
}
#endif
@ -97,9 +97,9 @@ retry:
// Found anything? Check if user fucked up or ACC is really missing.
if (accHardware == ACC_DEFAULT) {
if (mcfg.acc_hardware > ACC_DEFAULT) {
if (masterConfig.acc_hardware > ACC_DEFAULT) {
// Nothing was found and we have a forced sensor type. Stupid user probably chose a sensor that isn't present.
mcfg.acc_hardware = ACC_DEFAULT;
masterConfig.acc_hardware = ACC_DEFAULT;
goto retry;
} else {
// We're really screwed
@ -118,14 +118,14 @@ retry:
}
#endif
if (mcfg.gyro_align != ALIGN_DEFAULT) {
gyroAlign = mcfg.gyro_align;
if (masterConfig.gyro_align != ALIGN_DEFAULT) {
gyroAlign = masterConfig.gyro_align;
}
if (mcfg.acc_align != ALIGN_DEFAULT) {
accAlign = mcfg.acc_align;
if (masterConfig.acc_align != ALIGN_DEFAULT) {
accAlign = masterConfig.acc_align;
}
if (mcfg.mag_align != ALIGN_DEFAULT) {
magAlign = mcfg.mag_align;
if (masterConfig.mag_align != ALIGN_DEFAULT) {
magAlign = masterConfig.mag_align;
}
@ -145,8 +145,8 @@ retry:
if (sensors(SENSOR_MAG)) {
// calculate magnetic declination
deg = cfg.mag_declination / 100;
min = cfg.mag_declination % 100;
deg = currentProfile.mag_declination / 100;
min = currentProfile.mag_declination % 100;
magneticDeclination = (deg + ((float)min * (1.0f / 60.0f))) * 10; // heading is in 0.1deg units
} else {