Only allow gyro_to_use = BOTH if both detected gyros are the same type
Since we currently don't have per gyro configuration, trying to use two different gyro types simultaneously may not provide good results or lead to other unforeseen situations like attempting to initialize with settings not applicable to both hardware types. This logic looks at the detected gyro types and resets to use only the first one if the user selected "BOTH" and they're different hardware types.
This commit is contained in:
parent
cb19bb16d4
commit
ff59c37fdb
|
@ -27,6 +27,7 @@
|
|||
#include "drivers/bus.h"
|
||||
#include "drivers/sensor.h"
|
||||
#include "drivers/accgyro/accgyro_mpu.h"
|
||||
#include "sensors/gyro.h"
|
||||
#pragma GCC diagnostic push
|
||||
#if defined(SIMULATOR_BUILD) && defined(SIMULATOR_MULTITHREAD)
|
||||
#include <pthread.h>
|
||||
|
@ -81,7 +82,7 @@ typedef struct gyroDev_s {
|
|||
uint8_t mpuDividerDrops;
|
||||
ioTag_t mpuIntExtiTag;
|
||||
uint8_t gyroHasOverflowProtection;
|
||||
uint8_t filler[1];
|
||||
gyroSensor_e gyroHardware;
|
||||
} gyroDev_t;
|
||||
|
||||
typedef struct accDev_s {
|
||||
|
|
|
@ -437,6 +437,7 @@ static bool gyroInitSensor(gyroSensor_t *gyroSensor)
|
|||
#endif
|
||||
|
||||
const gyroSensor_e gyroHardware = gyroDetect(&gyroSensor->gyroDev);
|
||||
gyroSensor->gyroDev.gyroHardware = gyroHardware;
|
||||
if (gyroHardware == GYRO_NONE) {
|
||||
return false;
|
||||
}
|
||||
|
@ -603,7 +604,21 @@ bool gyroInit(void)
|
|||
}
|
||||
gyroHasOverflowProtection = gyroHasOverflowProtection && gyroSensor2.gyroDev.gyroHasOverflowProtection;
|
||||
}
|
||||
#endif
|
||||
#endif // USE_DUAL_GYRO
|
||||
|
||||
#ifdef USE_DUAL_GYRO
|
||||
// Only allow using both gyros simultaneously if they are the same hardware type.
|
||||
// If the user selected "BOTH" and they are not the same type, then reset to using only the first gyro.
|
||||
if (gyroToUse == GYRO_CONFIG_USE_GYRO_BOTH) {
|
||||
if (gyroSensor1.gyroDev.gyroHardware != gyroSensor2.gyroDev.gyroHardware) {
|
||||
gyroToUse = GYRO_CONFIG_USE_GYRO_1;
|
||||
gyroConfigMutable()->gyro_to_use = GYRO_CONFIG_USE_GYRO_1;
|
||||
detectedSensors[SENSOR_INDEX_GYRO] = gyroSensor1.gyroDev.gyroHardware;
|
||||
sensorsSet(SENSOR_GYRO);
|
||||
|
||||
}
|
||||
}
|
||||
#endif // USE_DUAL_GYRO
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -697,7 +697,10 @@ void initRcProcessing(void) {}
|
|||
void changePidProfile(uint8_t) {}
|
||||
void pidInitConfig(const pidProfile_t *) {}
|
||||
void accSetCalibrationCycles(uint16_t) {}
|
||||
void gyroStartCalibration(void) {}
|
||||
void gyroStartCalibration(bool isFirstArmingCalibration)
|
||||
{
|
||||
UNUSED(isFirstArmingCalibration);
|
||||
}
|
||||
void applyAndSaveAccelerometerTrimsDelta(rollAndPitchTrims_t*) {}
|
||||
void handleInflightCalibrationStickPosition(void) {}
|
||||
bool feature(uint32_t) { return false;}
|
||||
|
|
Loading…
Reference in New Issue