https://github.com/pilotak/movingaverageangle
Arduino & Mbed Library for averaging angles 0-360°
https://github.com/pilotak/movingaverageangle
angle arduino arduino-library averaging-filter compass filter float mbed mbed-os moving-average
Last synced: 11 months ago
JSON representation
Arduino & Mbed Library for averaging angles 0-360°
- Host: GitHub
- URL: https://github.com/pilotak/movingaverageangle
- Owner: pilotak
- License: mit
- Created: 2018-09-07T17:09:01.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-13T19:06:58.000Z (over 2 years ago)
- Last Synced: 2025-01-16T19:37:24.164Z (about 1 year ago)
- Topics: angle, arduino, arduino-library, averaging-filter, compass, filter, float, mbed, mbed-os, moving-average
- Language: C++
- Homepage:
- Size: 29.3 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Moving average filter for angles 0-360°
[](https://github.com/pilotak/MovingAverageAngle/actions)
[](https://arduino.cc)
[](https://os.mbed.com/)
This library requires [MovingAverage](https://github.com/pilotak/MovingAverage) library.
## Arduino example
Please see `examples` folder
## Mbed example
```cpp
#include "mbed.h"
#include "MovingAverageAngle.h" // https://github.com/pilotak/MovingAverageAngle
// Buffer will be 4 samples long, it will take 4 * sizeof(float) = 16 bytes of RAM
MovingAverageAngle <4> filter;
int main() {
printf("result: %.2f\n", filter.add(350.0)); // insert new number and get result
printf("result: %.2f\n", filter.add(20.0)); // insert new number and get result
printf("result: %.2f\n", filter.add(30.0)); // insert new number and get result
printf("result: %.2f\n", filter.add(40.0)); // insert new number and get result
printf("result: %.2f\n", filter.get()); // get last result, without adding a newone
return 0;
}
```
### Output
> result: 350.00
>
> result: 357.37
>
> result: 7.47
>
> result: 20.24
>
> result: 20.24