Moving Average

Dependents:   MovingAverage_HelloWorld Levitator EMG_Realtime_Filter EMG_Calibration ... more

Fork of MoyenneMobile by Alexandre Proulx

Files at this revision

API Documentation at this revision

Comitter:
fblanc
Date:
Tue Dec 16 08:27:15 2014 +0000
Parent:
3:54b3249b6ad8
Commit message:
test ok

Changed in this revision

MovingAverage.h Show annotated file Show diff for this revision Revisions of this file
diff -r 54b3249b6ad8 -r ad69440a9bef MovingAverage.h
--- a/MovingAverage.h	Wed Dec 10 12:53:38 2014 +0000
+++ b/MovingAverage.h	Tue Dec 16 08:27:15 2014 +0000
@@ -1,7 +1,44 @@
+ /* Copyright (c) 2014 LAAS-CNRS
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
 #ifndef MOVING_AVERAGE_H
 #define MOVING_AVERAGE_H
 
 template <class T>
+/** class of moving average
+* Example:
+ * @code
+ * #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()); 
+ * }
+ * @endcode
+ */
+ 
 class MovingAverage
 {
 private:
@@ -11,8 +48,18 @@
     unsigned char NextElement;
     unsigned char MaxLength;
 public:
+    /** Create  moving average
+     * @param maxLength is length of moving average
+     * @param value is initial value
+     */
     MovingAverage(unsigned char maxLength, T defaultValue);
+    /** Get the value of the moving average
+     * @return value of the moving average
+     */
     T GetAverage();
+    /** Insert a element in moving average
+     * @param value is the element inserted in moving average
+     */
 
     void Insert(T value);
 };
@@ -44,4 +91,4 @@
         NextElement=0;
     
 }
-#endif
\ No newline at end of file
+#endif //MOVING_AVERAGE_H
\ No newline at end of file