N K
/
GaNtroller
a fork of priustroller
Fork of priustroller_current by
Diff: currentsensors.cpp
- Revision:
- 6:99ee0ce47fb2
- Parent:
- 1:1f58bdcf2956
- Child:
- 7:76d6ceb23e0d
diff -r ee1e6c84c302 -r 99ee0ce47fb2 currentsensors.cpp --- a/currentsensors.cpp Tue Mar 03 06:28:10 2015 +0000 +++ b/currentsensors.cpp Wed Mar 04 15:33:32 2015 +0000 @@ -8,7 +8,11 @@ } void AnalogCurrentSensor::Zero() { - _zero_level = (float) *_in; + float mean = 0; + for(int i = 1; i<=1000; i++){ + mean = 0.1f*((float) *_in) + 0.9f*mean; + } + _zero_level = mean; } float AnalogCurrentSensor::GetCurrent() {