forked from 7Bot/7Bot-Arduino-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForceFilter.cpp
More file actions
39 lines (29 loc) · 696 Bytes
/
ForceFilter.cpp
File metadata and controls
39 lines (29 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/****************************************************
/* 7Bot class for Arduino platform
/* Author: Jerry Peng
/* Date: 26 April 2016
/*
/* Version 1.00
/* www.7bot.cc
/*
/* Description:
/*
/*
/***************************************************/
#include "ForceFilter.h"
ForceFilter::ForceFilter() {
for(int i=0; i<forceFilterSize; i++){
filerElements[i] = 0;
}
}
int ForceFilter::filter(int dataIn) {
int sum = 0;
// 1- in put data
for(int i=forceFilterSize-1; i>0; i--){
filerElements[i] = filerElements[i-1];
sum += filerElements[i];
}
filerElements[0] = dataIn;
sum += filerElements[0];
return (int)( sum / forceFilterSize );
}