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 priustroller by
Diff: currentsensors.cpp
- Revision:
- 6:99ee0ce47fb2
- Parent:
- 1:1f58bdcf2956
- Child:
- 7:76d6ceb23e0d
--- 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() {