Skip to content

Commit

Permalink
Filter: fixed test suite
Browse files Browse the repository at this point in the history
fill in a parameters structure
  • Loading branch information
tridge committed Nov 2, 2023
1 parent 71a8431 commit 85be47b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions libraries/Filter/HarmonicNotchFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,26 @@ class HarmonicNotchFilterParams : public NotchFilterParams {

// set the fundamental center frequency of the harmonic notch
void set_center_freq_hz(float center_freq) { _center_freq_hz.set(center_freq); }

// set the bandwidth of the harmonic notch
void set_bandwidth_hz(float bandwidth_hz) { _bandwidth_hz.set(bandwidth_hz); }

// set the attenuation of the harmonic notch
void set_attenuation(float attenuation_dB) { _attenuation_dB.set(attenuation_dB); }

// harmonics enabled on the harmonic notch
uint32_t harmonics(void) const { return _harmonics; }

// set the harmonics value
void set_harmonics(uint32_t hmncs) { _harmonics.set(hmncs); }

// has the user set the harmonics value
void set_default_harmonics(uint32_t hmncs) { _harmonics.set_default(hmncs); }

// reference value of the harmonic notch
float reference(void) const { return _reference; }
void set_reference(float ref) { _reference.set(ref); }

// notch options
bool hasOption(Options option) const { return _options & uint16_t(option); }
// notch dynamic tracking mode
Expand Down
8 changes: 7 additions & 1 deletion libraries/Filter/tests/test_notchfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ TEST(NotchFilterTest, HarmonicNotchTest)
for (uint8_t c=0; c<chained_filters; c++) {
auto &f = filters[i][c];
f.allocate_filters(num_harmonics, harmonics, double_notch?2:1);
f.init(rate_hz, base_freq, bandwidth, attenuation_dB);
HarmonicNotchFilterParams notch_params {};
notch_params.set_attenuation(attenuation_dB);
notch_params.set_bandwidth_hz(bandwidth);
notch_params.set_center_freq_hz(base_freq);
notch_params.set_freq_min_ratio(1.0);
f.init(rate_hz, notch_params);
f.update(base_freq);
}
}

Expand Down

0 comments on commit 85be47b

Please sign in to comment.