a fork of priustroller

Dependencies:   mbed

Fork of priustroller_current by N K

Revision:
0:54cf32d35f4d
Child:
1:1f58bdcf2956
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/currentsensors.cpp	Sun Mar 01 06:16:01 2015 +0000
@@ -0,0 +1,16 @@
+#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;
+}
\ No newline at end of file