stock mbed AnalogReads current loop closed and working
Fork of priustroller by
throttle.cpp
- Committer:
- nki
- Date:
- 2015-03-08
- Revision:
- 10:b4abecccec7a
- Parent:
- 1:1f58bdcf2956
File content as of revision 10:b4abecccec7a:
#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; }