a fork of priustroller

Dependencies:   mbed

Fork of priustroller_current by N K

Committer:
bwang
Date:
Sun Mar 01 10:51:28 2015 +0000
Revision:
1:1f58bdcf2956
Parent:
0:54cf32d35f4d
Child:
6:99ee0ce47fb2
moar

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bwang 0:54cf32d35f4d 1 #include "includes.h"
bwang 1:1f58bdcf2956 2 #include "sensors.h"
bwang 0:54cf32d35f4d 3
bwang 0:54cf32d35f4d 4 AnalogCurrentSensor::AnalogCurrentSensor(PinName pin, float volts_per_amp) {
bwang 0:54cf32d35f4d 5 _in = new AnalogIn(pin);
bwang 0:54cf32d35f4d 6 _volts_per_amp = volts_per_amp;
bwang 0:54cf32d35f4d 7 Zero();
bwang 0:54cf32d35f4d 8 }
bwang 0:54cf32d35f4d 9
bwang 0:54cf32d35f4d 10 void AnalogCurrentSensor::Zero() {
bwang 0:54cf32d35f4d 11 _zero_level = (float) *_in;
bwang 0:54cf32d35f4d 12 }
bwang 0:54cf32d35f4d 13
bwang 0:54cf32d35f4d 14 float AnalogCurrentSensor::GetCurrent() {
bwang 0:54cf32d35f4d 15 return ((float) *_in - _zero_level) * 3.3f / _volts_per_amp;
bwang 0:54cf32d35f4d 16 }