working-est copy with class-based code. still open loop

Dependencies:   mbed

Fork of analoghalls6 by N K

throttle.cpp

Committer:
bwang
Date:
2015-03-01
Revision:
1:1f58bdcf2956
Child:
10:b4abecccec7a

File content as of revision 1:1f58bdcf2956:

#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();
    return (v - _min) / (_max - _min);
}