Bayley Wang
/
priustroller_3
temp repo
Fork of priustroller_2 by
Embed:
(wiki syntax)
Show/hide line numbers
throttle.cpp
00001 #include "includes.h" 00002 #include "sensors.h" 00003 00004 Throttle::Throttle(PinName pin, float min, float max) { 00005 _in = new AnalogVoltageSensor(pin, 1.0f); 00006 _min = min; 00007 _max = max; 00008 } 00009 00010 float Throttle::GetThrottle() { 00011 float v = _in->GetVoltage(); 00012 v = (v - _min) / (_max - _min); 00013 if (v > 1.0f) return 1.0f; 00014 if (v < 0.0f) return 0.0f; 00015 return v; 00016 }
Generated on Tue Jul 12 2022 20:58:06 by 1.7.2