-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(filters): Update filters example, and expose filters to x-plat l…
…ibrary (#330) * feat(filters): Expose lowpass filters to lib and update example * update example to test more permutations of filters * fix sa * add missing cpp files to cmake * readme: update
- Loading branch information
Showing
22 changed files
with
593 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
idf_component_register( | ||
INCLUDE_DIRS "include" | ||
REQUIRES format esp-dsp) | ||
SRC_DIRS "src" | ||
REQUIRES esp_timer format esp-dsp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include "format.hpp" | ||
|
||
// for allowing easy serialization/printing of the | ||
// espp::BiquadFilterDf1 | ||
template <> struct fmt::formatter<espp::BiquadFilterDf1> { | ||
template <typename ParseContext> constexpr auto parse(ParseContext &ctx) const { | ||
return ctx.begin(); | ||
} | ||
|
||
template <typename FormatContext> | ||
auto format(espp::BiquadFilterDf1 const &bqf, FormatContext &ctx) const { | ||
return fmt::format_to(ctx.out(), "DF1 - B: {}, A: {}", bqf.b_, bqf.a_); | ||
} | ||
}; | ||
|
||
// for allowing easy serialization/printing of the | ||
// espp::BiquadFilterDf2 | ||
template <> struct fmt::formatter<espp::BiquadFilterDf2> { | ||
template <typename ParseContext> constexpr auto parse(ParseContext &ctx) const { | ||
return ctx.begin(); | ||
} | ||
|
||
template <typename FormatContext> | ||
auto format(espp::BiquadFilterDf2 const &bqf, FormatContext &ctx) const { | ||
return fmt::format_to(ctx.out(), "DF2 - B: {}, A: {}", bqf.b_, bqf.a_); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
components/filters/include/butterworth_filter_formatters.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "format.hpp" | ||
|
||
// for allowing easy serialization/printing of the | ||
// espp::ButterworthFilter | ||
template <size_t ORDER, class Impl> struct fmt::formatter<espp::ButterworthFilter<ORDER, Impl>> { | ||
template <typename ParseContext> constexpr auto parse(ParseContext &ctx) const { | ||
return ctx.begin(); | ||
} | ||
|
||
template <typename FormatContext> | ||
auto format(espp::ButterworthFilter<ORDER, Impl> const &f, FormatContext &ctx) const { | ||
auto &&out = ctx.out(); | ||
fmt::format_to(out, "Butterworth - ["); | ||
if constexpr (ORDER > 0) { | ||
fmt::format_to(out, "[{}]", f.sections_[0]); | ||
} | ||
for (int i = 1; i < (ORDER + 1) / 2; i++) { | ||
fmt::format_to(out, ", [{}]", f.sections_[i]); | ||
} | ||
return fmt::format_to(out, "]"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include "format.hpp" | ||
|
||
// for allowing easy serialization/printing of the | ||
// espp::LowpassFilter | ||
template <> struct fmt::formatter<espp::LowpassFilter> { | ||
template <typename ParseContext> constexpr auto parse(ParseContext &ctx) const { | ||
return ctx.begin(); | ||
} | ||
|
||
template <typename FormatContext> | ||
auto format(espp::LowpassFilter const &f, FormatContext &ctx) const { | ||
return fmt::format_to(ctx.out(), "Lowpass - {}", f.coeffs_); | ||
} | ||
}; |
Oops, something went wrong.