Latest version of my quadcopter controller with an LPC1768 and MPU9250.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MAfilter.cpp Source File

MAfilter.cpp

00001 // Coded by Erik van de Coevering 
00002 
00003 #include "MAfilter.h"
00004 
00005 float MAfilter::run(float input)
00006         {
00007             for(i=1; i<200; i++)
00008             {
00009                 filterbuff[i] = filterbuff[i-1];
00010             }
00011             filterbuff[0] = input;
00012             
00013             for(i=0; i<200; i++) out = out + (filterbuff[i]/200);
00014             
00015             return out;
00016         }
00017         
00018 float MAfilter10::run(float input)
00019         {
00020             for(i=1; i<10; i++)
00021             {
00022                 filterbuff[i] = filterbuff[i-1];
00023             }
00024             filterbuff[0] = input;
00025             
00026             out = 0;
00027             for(i=0; i<10; i++) out = out + (filterbuff[i]*0.1);
00028             
00029             return out;
00030         }
00031