mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 12:25:20 +03:00
Change Pt1 cutoff from uint16_t to float
This commit is contained in:
parent
f625cb261c
commit
b8bfc7ce12
3 changed files with 5 additions and 5 deletions
|
@ -44,7 +44,7 @@ FAST_CODE float nullFilterApply(filter_t *filter, float input)
|
|||
|
||||
// PT1 Low Pass filter
|
||||
|
||||
float pt1FilterGain(uint16_t f_cut, float dT)
|
||||
float pt1FilterGain(float f_cut, float dT)
|
||||
{
|
||||
float RC = 1 / ( 2 * M_PI_FLOAT * f_cut);
|
||||
return dT / (RC + dT);
|
||||
|
|
|
@ -76,7 +76,7 @@ float filterGetNotchQ(float centerFreq, float cutoffFreq);
|
|||
void laggedMovingAverageInit(laggedMovingAverage_t *filter, uint16_t windowSize, float *buf);
|
||||
float laggedMovingAverageUpdate(laggedMovingAverage_t *filter, float input);
|
||||
|
||||
float pt1FilterGain(uint16_t f_cut, float dT);
|
||||
float pt1FilterGain(float f_cut, float dT);
|
||||
void pt1FilterInit(pt1Filter_t *filter, float k);
|
||||
void pt1FilterUpdateCutoff(pt1Filter_t *filter, float k);
|
||||
float pt1FilterApply(pt1Filter_t *filter, float input);
|
||||
|
|
|
@ -41,15 +41,15 @@ TEST(FilterUnittest, TestPt1FilterInit)
|
|||
|
||||
TEST(FilterUnittest, TestPt1FilterGain)
|
||||
{
|
||||
EXPECT_FLOAT_EQ(0.999949, pt1FilterGain(100, 31.25f));
|
||||
EXPECT_FLOAT_EQ(0.999949, pt1FilterGain(100.0f, 31.25f));
|
||||
// handle cases over uint8_t boundary
|
||||
EXPECT_FLOAT_EQ(0.99998301, pt1FilterGain(300, 31.25f));
|
||||
EXPECT_FLOAT_EQ(0.99998301, pt1FilterGain(300.0f, 31.25f));
|
||||
}
|
||||
|
||||
TEST(FilterUnittest, TestPt1FilterApply)
|
||||
{
|
||||
pt1Filter_t filter;
|
||||
pt1FilterInit(&filter, pt1FilterGain(100, 31.25f));
|
||||
pt1FilterInit(&filter, pt1FilterGain(100.0f, 31.25f));
|
||||
EXPECT_EQ(0, filter.state);
|
||||
|
||||
pt1FilterApply(&filter, 1800.0f);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue