1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Dynamic notch refactoring

+ added new parameter group for Dyn Notch
This commit is contained in:
KarateBrot 2021-08-27 08:42:38 +02:00 committed by Michael Keller
parent 4c9eb210a9
commit 8649f1003f
19 changed files with 297 additions and 240 deletions

View file

@ -117,6 +117,7 @@
#include "pg/beeper.h"
#include "pg/board.h"
#include "pg/dyn_notch.h"
#include "pg/gyrodev.h"
#include "pg/motor.h"
#include "pg/rx.h"
@ -1779,11 +1780,11 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst)
sbufWriteU16(dst, 0);
#endif
// Added in MSP API 1.42
#if defined(USE_GYRO_DATA_ANALYSE)
#if defined(USE_DYN_NOTCH_FILTER)
sbufWriteU8(dst, 0); // DEPRECATED 1.43: dyn_notch_range
sbufWriteU8(dst, 0); // DEPRECATED 1.44: dyn_notch_width_percent
sbufWriteU16(dst, gyroConfig()->dyn_notch_q);
sbufWriteU16(dst, gyroConfig()->dyn_notch_min_hz);
sbufWriteU16(dst, dynNotchConfig()->dyn_notch_q);
sbufWriteU16(dst, dynNotchConfig()->dyn_notch_min_hz);
#else
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);
@ -1797,9 +1798,9 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst)
sbufWriteU8(dst, 0);
sbufWriteU8(dst, 0);
#endif
#if defined(USE_GYRO_DATA_ANALYSE)
#if defined(USE_DYN_NOTCH_FILTER)
// Added in MSP API 1.43
sbufWriteU16(dst, gyroConfig()->dyn_notch_max_hz);
sbufWriteU16(dst, dynNotchConfig()->dyn_notch_max_hz);
#else
sbufWriteU16(dst, 0);
#endif
@ -1809,8 +1810,8 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst)
#else
sbufWriteU8(dst, 0);
#endif
#if defined(USE_GYRO_DATA_ANALYSE)
sbufWriteU8(dst, gyroConfig()->dyn_notch_count);
#if defined(USE_DYN_NOTCH_FILTER)
sbufWriteU8(dst, dynNotchConfig()->dyn_notch_count);
#else
sbufWriteU8(dst, 0);
#endif
@ -2653,11 +2654,11 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
}
if (sbufBytesRemaining(src) >= 8) {
// Added in MSP API 1.42
#if defined(USE_GYRO_DATA_ANALYSE)
#if defined(USE_DYN_NOTCH_FILTER)
sbufReadU8(src); // DEPRECATED 1.43: dyn_notch_range
sbufReadU8(src); // DEPRECATED 1.44: dyn_notch_width_percent
gyroConfigMutable()->dyn_notch_q = sbufReadU16(src);
gyroConfigMutable()->dyn_notch_min_hz = sbufReadU16(src);
dynNotchConfigMutable()->dyn_notch_q = sbufReadU16(src);
dynNotchConfigMutable()->dyn_notch_min_hz = sbufReadU16(src);
#else
sbufReadU8(src);
sbufReadU8(src);
@ -2673,9 +2674,9 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
#endif
}
if (sbufBytesRemaining(src) >= 2) {
#if defined(USE_GYRO_DATA_ANALYSE)
#if defined(USE_DYN_NOTCH_FILTER)
// Added in MSP API 1.43
gyroConfigMutable()->dyn_notch_max_hz = sbufReadU16(src);
dynNotchConfigMutable()->dyn_notch_max_hz = sbufReadU16(src);
#else
sbufReadU16(src);
#endif
@ -2687,8 +2688,8 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
#else
sbufReadU8(src);
#endif
#if defined(USE_GYRO_DATA_ANALYSE)
gyroConfigMutable()->dyn_notch_count = sbufReadU8(src);
#if defined(USE_DYN_NOTCH_FILTER)
dynNotchConfigMutable()->dyn_notch_count = sbufReadU8(src);
#else
sbufReadU8(src);
#endif