Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MoyenneMobile by
MovingAverage< T > Class Template Reference
class of moving average Example: More...
#include <MovingAverage.h>
Public Member Functions | |
| MovingAverage (unsigned char maxLength, T defaultValue) | |
| Create moving average. | |
| T | GetAverage () |
| Get the value of the moving average. | |
| void | Insert (T value) |
| Insert a element in moving average. | |
Detailed Description
template<class T>
class MovingAverage< T >
class of moving average Example:
#include "mbed.h" #include "MovingAverage.h" #define NSAMPLE 100 Ticker flipperADC; AnalogIn ain(A0); MovingAverage <float>vavg(NSAMPLE,0.0); void flipADC() { vavg.Insert(ain.read()); } int main() { flipperADC.attach_us(&flipADC, 10000); while (true) printf("analog= %f \r\n",vavg.GetAverage()); }
Definition at line 42 of file MovingAverage.h.
Constructor & Destructor Documentation
| MovingAverage | ( | unsigned char | maxLength, |
| T | defaultValue | ||
| ) |
Create moving average.
- Parameters:
-
maxLength is length of moving average value is initial value
Definition at line 68 of file MovingAverage.h.
Member Function Documentation
| T GetAverage | ( | ) |
Get the value of the moving average.
- Returns:
- value of the moving average
Definition at line 81 of file MovingAverage.h.
| void Insert | ( | T | value ) |
Insert a element in moving average.
- Parameters:
-
value is the element inserted in moving average
Definition at line 87 of file MovingAverage.h.
Generated on Tue Jul 12 2022 19:22:26 by
1.7.2
