mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +03:00
Changes from review
Used HZ_TO_INTERVAL_US() instead of hardcoded 500us. Moved tests into a dedicated function.
This commit is contained in:
parent
f411b82eb6
commit
25c6b038d9
5 changed files with 9 additions and 4 deletions
|
@ -60,6 +60,7 @@
|
|||
#include "sensors/acceleration.h"
|
||||
#include "sensors/battery.h"
|
||||
#include "sensors/gyro.h"
|
||||
#include "sensors/gyroanalyse.h"
|
||||
|
||||
#ifndef USE_OSD_SLAVE
|
||||
pidProfile_t *currentPidProfile;
|
||||
|
@ -410,10 +411,12 @@ static void validateAndFixConfig(void)
|
|||
#ifndef USE_OSD_SLAVE
|
||||
void validateAndFixGyroConfig(void)
|
||||
{
|
||||
#ifdef USE_GYRO_DATA_ANALYSE
|
||||
// Disable dynamic filter if gyro loop is less than 2KHz
|
||||
if (gyro.targetLooptime > GYRO_LOOPTIME_2KHZ) {
|
||||
if (!dynamicFilterAllowed()) {
|
||||
featureClear(FEATURE_DYNAMIC_FILTER);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Prevent invalid notch cutoff
|
||||
if (gyroConfig()->gyro_soft_notch_cutoff_1 >= gyroConfig()->gyro_soft_notch_hz_1) {
|
||||
|
|
|
@ -743,7 +743,7 @@ static void gyroInitFilterNotch2(gyroSensor_t *gyroSensor, uint16_t notchHz, uin
|
|||
#ifdef USE_GYRO_DATA_ANALYSE
|
||||
static bool isDynamicFilterActive(void)
|
||||
{
|
||||
return feature(FEATURE_DYNAMIC_FILTER) && (gyro.targetLooptime <= GYRO_LOOPTIME_2KHZ);
|
||||
return feature(FEATURE_DYNAMIC_FILTER) && dynamicFilterAllowed();
|
||||
}
|
||||
|
||||
static void gyroInitFilterDynamicNotch(gyroSensor_t *gyroSensor)
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
#include "drivers/bus.h"
|
||||
#include "drivers/sensor.h"
|
||||
|
||||
#define GYRO_LOOPTIME_2KHZ 500
|
||||
|
||||
typedef enum {
|
||||
GYRO_NONE = 0,
|
||||
GYRO_DEFAULT,
|
||||
|
|
|
@ -304,4 +304,7 @@ static FAST_CODE_NOINLINE void gyroDataAnalyseUpdate(gyroAnalyseState_t *state,
|
|||
state->updateStep = (state->updateStep + 1) % STEP_COUNT;
|
||||
}
|
||||
|
||||
bool dynamicFilterAllowed(void) {
|
||||
return (gyro.targetLooptime <= HZ_TO_INTERVAL_US(2000));
|
||||
}
|
||||
#endif // USE_GYRO_DATA_ANALYSE
|
||||
|
|
|
@ -61,3 +61,4 @@ void gyroDataAnalyseInit(void);
|
|||
void gyroDataAnalyseStateInit(gyroAnalyseState_t *gyroAnalyse, uint32_t targetLooptime);
|
||||
void gyroDataAnalysePush(gyroAnalyseState_t *gyroAnalyse, int axis, float sample);
|
||||
void gyroDataAnalyse(gyroAnalyseState_t *gyroAnalyse, biquadFilter_t *notchFilterDyn);
|
||||
bool dynamicFilterAllowed(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue