N K
/
GaNtroller
a fork of priustroller
Fork of priustroller_current by
currentsensors.cpp
- Committer:
- bwang
- Date:
- 2015-03-01
- Revision:
- 1:1f58bdcf2956
- Parent:
- 0:54cf32d35f4d
- Child:
- 6:99ee0ce47fb2
File content as of revision 1:1f58bdcf2956:
#include "includes.h" #include "sensors.h" AnalogCurrentSensor::AnalogCurrentSensor(PinName pin, float volts_per_amp) { _in = new AnalogIn(pin); _volts_per_amp = volts_per_amp; Zero(); } void AnalogCurrentSensor::Zero() { _zero_level = (float) *_in; } float AnalogCurrentSensor::GetCurrent() { return ((float) *_in - _zero_level) * 3.3f / _volts_per_amp; }