a fork of priustroller

Dependencies:   mbed

Fork of priustroller_current by N K

Revision:
28:af9d43bcb371
Parent:
11:dccbaa9274c5
Child:
29:cb03760ba9ea
diff -r 846c08fb3697 -r af9d43bcb371 sensors/sensors.h
--- a/sensors/sensors.h	Sat Mar 14 18:51:36 2015 +0000
+++ b/sensors/sensors.h	Sat Mar 14 19:18:34 2015 +0000
@@ -3,6 +3,17 @@
 
 #include "includes.h"
 
+class NativeAnalogIn {
+public:
+    NativeAnalogIn(PinName pin);
+    float Read();
+    operator float() {return Read();}
+private:
+    unsigned char PinToAdcChannel(PinName pin);
+private:
+    unsigned char _channel;
+};
+
 class CurrentSensor {
 public:
     virtual float GetCurrent() {return 0.0f;}
@@ -32,7 +43,7 @@
     virtual float GetCurrent();
 private:
     float _zero_level, _volts_per_amp;
-    AnalogIn *_in;
+    NativeAnalogIn *_in;
 };
 
 class AnalogVoltageSensor: public VoltageSensor {
@@ -42,7 +53,7 @@
     virtual float GetVoltage();
 private:
     float _zero_level, _scale;
-    AnalogIn *_in;
+    NativeAnalogIn *_in;
 };
 
 class AnalogHallPositionSensor: public PositionSensor {
@@ -54,7 +65,7 @@
     float _cal1_a, _cal2_a;
     float _cal1_b, _cal2_b;
     float _offset;
-    AnalogIn *_in_a, *_in_b;
+    NativeAnalogIn *_in_a, *_in_b;
 };
 
 class NtcTempSensor: public TempSensor {
@@ -63,7 +74,7 @@
     virtual float GetTemp();
 private:
     float _ntc_a, _ntc_b, _r_divider;
-    AnalogIn *_in;
+    NativeAnalogIn *_in;
 };
 
 class Throttle {