N K
/
GaNtroller
a fork of priustroller
Fork of priustroller_current by
currentsensors.cpp
- Committer:
- bwang
- Date:
- 2015-03-01
- Revision:
- 0:54cf32d35f4d
- Child:
- 1:1f58bdcf2956
File content as of revision 0:54cf32d35f4d:
#include "includes.h" #include "classes.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; }