https://github.com/pilotak/movingaveragefloat
Arduino & Mbed Library for averaging float numbers
https://github.com/pilotak/movingaveragefloat
arduino arduino-library averaging-filter filter float floating-point mbed mbed-os moving-average
Last synced: 19 days ago
JSON representation
Arduino & Mbed Library for averaging float numbers
- Host: GitHub
- URL: https://github.com/pilotak/movingaveragefloat
- Owner: pilotak
- License: mit
- Created: 2018-09-07T15:45:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-23T10:21:53.000Z (about 4 years ago)
- Last Synced: 2025-01-16T19:37:30.350Z (11 months ago)
- Topics: arduino, arduino-library, averaging-filter, filter, float, floating-point, mbed, mbed-os, moving-average
- Language: C++
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Moving average filter for float numbers
[](https://github.com/pilotak/MovingAverageFloat/actions)
[](https://arduino.cc)
[](https://os.mbed.com/)
## Arduino example
Please see `examples` folder
## Mbed example
```cpp
#include "mbed.h"
#include "MovingAverageFloat.h"
// Buffer will be 16 samples long, it will take 16 * sizeof(float) = 64 bytes of RAM
MovingAverageFloat <16> filter;
int main() {
printf("result: %.2f\n", filter.add(1.5)); // insert new number and get result
printf("result: %.2f\n", filter.add(2.5)); // insert new number and get result
printf("result: %.2f\n", filter.add(2.4)); // insert new number and get result
printf("result: %.2f\n", filter.get()); // get last result, without adding a newone
return 0;
}
```
### Output
> result: 1.50
>
> result: 1.56
>
> result: 1.62
>
> result: 1.62