-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ExponentialMovingAverageFilter to use a templated input type.
This requires a pull request be merged to ArduinoSTL before it will build on AVR-based platforms (e.g. UNO). mike-matera/ArduinoSTL#52
- Loading branch information
Showing
4 changed files
with
91 additions
and
40 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
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,42 @@ | ||
#include "gtest/gtest.h" | ||
|
||
#include <cstdio> | ||
#include "../src/exponential-moving-average-filter.h" | ||
#include "run-data-test.h" | ||
|
||
namespace exponential_moving_average_filter_test { | ||
|
||
TEST(ExponentialMovingAverageFloatFilter, alpha_half) { | ||
ExponentialMovingAverageFilter<float, float> *filter = new ExponentialMovingAverageFilter<float, float>(floatRead, 0.5); | ||
std::vector<InputOutput<float, float>> data = { | ||
{0, 10, 0}, | ||
{1.0, 100, 0.4, 1.0}, | ||
{1.0, 100, 1.0}, | ||
{0, 100, 0, 0.6}, | ||
{0, 100, 0, 0.001}, | ||
}; | ||
RunDataTest(filter, data, setFloatRead); | ||
} | ||
|
||
TEST(ExponentialMovingAverageFloatFilter, alpha_full) { | ||
ExponentialMovingAverageFilter<float, float> *filter = new ExponentialMovingAverageFilter<float, float>(floatRead, 1.0); | ||
std::vector<InputOutput<float, float>> data = { | ||
{0, 10, 0}, | ||
{10.0, 100, 10.0}, | ||
{0, 100, 0}, | ||
}; | ||
RunDataTest(filter, data, setFloatRead); | ||
} | ||
|
||
TEST(ExponentialMovingAverageFloatFilter, alpha_low) { | ||
ExponentialMovingAverageFilter<float, float> *filter = new ExponentialMovingAverageFilter<float, float>(floatRead, 0.001); | ||
std::vector<InputOutput<float, float>> data = { | ||
{0, 10, 0}, | ||
{1.0, 500, 0, 0.5}, | ||
{1.0, 5000, 0, 1.0}, | ||
{1.0, 100, 0.99, 1.0}, | ||
}; | ||
RunDataTest(filter, data, setFloatRead); | ||
} | ||
|
||
} |
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