Prius IPM controller

Dependencies:   mbed

Fork of analoghalls5_5 by N K

Revision:
11:dccbaa9274c5
Parent:
10:b4abecccec7a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sensors/throttle.cpp	Sun Mar 08 08:37:38 2015 +0000
@@ -0,0 +1,16 @@
+#include "includes.h"
+#include "sensors.h"
+
+Throttle::Throttle(PinName pin, float min, float max) {
+    _in = new AnalogVoltageSensor(pin, 1.0f);
+    _min = min;
+    _max = max;
+}
+
+float Throttle::GetThrottle() {
+    float v = _in->GetVoltage();
+    v = (v - _min) / (_max - _min);
+    if (v > 1.0f) return 1.0f;
+    if (v < 0.0f) return 0.0f;
+    return v;
+}
\ No newline at end of file