A library that maps one range onto another range.
Dependents: Heiko Simran_Servo_2410 HYDRO-pH-BASIC NucleoBoard_1 ... more
Diff: Map.cpp
- Revision:
- 1:dad975e2e150
- Parent:
- 0:f274b178a2d4
diff -r f274b178a2d4 -r dad975e2e150 Map.cpp --- a/Map.cpp Wed Sep 28 01:44:45 2016 +0000 +++ b/Map.cpp Wed Sep 28 04:02:59 2016 +0200 @@ -0,0 +1,14 @@ +#include "Map.hpp" + +Map::Map(float inMin, float inMax, float outMin, float outMax) +{ + _inMin = inMin; + _inMax = inMax; + _outMin = outMin; + _outMax = outMax; +} + +float Map::Calculate(float inVal) +{ + return ( (inVal - _inMin)*(_outMax - _outMin)/(_inMax - _inMin) + _outMin ); +}