a fork of priustroller

Dependencies:   mbed

Fork of priustroller_current by N K

Revision:
33:e7b132029bae
Parent:
30:2b6d426f3bfc
Child:
54:e8d9bc885723
--- a/sensors/sensors.h	Mon Mar 16 02:43:19 2015 +0000
+++ b/sensors/sensors.h	Mon Mar 16 03:09:48 2015 +0000
@@ -3,15 +3,10 @@
 
 #include "includes.h"
 
-class NativeAnalogIn {
+class CurrentSensor {
 public:
-    NativeAnalogIn(PinName pin);
-    float Read();
-    operator float() {return Read();}
-    static unsigned char PinToAdcChannel(PinName pin);
-private:
-    unsigned char _channel;
-    float _dummy;
+    virtual float GetCurrent() {return 0.0f;}
+    virtual void Zero() {}
 };
 
 class VoltageSensor {
@@ -30,6 +25,16 @@
     virtual float GetTemp() {return 0.0f;}
 };
 
+class AnalogCurrentSensor: public CurrentSensor {
+public:
+    AnalogCurrentSensor(PinName pin, float volts_per_amp);
+    virtual void Zero();
+    virtual float GetCurrent();
+private:
+    float _zero_level, _volts_per_amp;
+    AnalogIn *_in;
+};
+
 class AnalogVoltageSensor: public VoltageSensor {
 public:
     AnalogVoltageSensor(PinName pin, float scale);
@@ -37,7 +42,7 @@
     virtual float GetVoltage();
 private:
     float _zero_level, _scale;
-    NativeAnalogIn *_in;
+    AnalogIn *_in;
 };
 
 class AnalogHallPositionSensor: public PositionSensor {
@@ -49,7 +54,7 @@
     float _cal1_a, _cal2_a;
     float _cal1_b, _cal2_b;
     float _offset;
-    NativeAnalogIn *_in_a, *_in_b;
+    AnalogIn *_in_a, *_in_b;
 };
 
 class NtcTempSensor: public TempSensor {
@@ -58,7 +63,7 @@
     virtual float GetTemp();
 private:
     float _ntc_a, _ntc_b, _r_divider;
-    NativeAnalogIn *_in;
+    AnalogIn *_in;
 };
 
 class Throttle {