A library that maps one range onto another range.

Dependents:   CANtran2

Revision:
2:ac294c579449
Parent:
1:dad975e2e150
--- a/Map.cpp	Wed Sep 28 04:02:59 2016 +0200
+++ b/Map.cpp	Fri Dec 27 17:52:39 2019 +0000
@@ -10,5 +10,12 @@
 
 float Map::Calculate(float inVal)
 {
-  return ( (inVal - _inMin)*(_outMax - _outMin)/(_inMax - _inMin) + _outMin );
+  float rval = (inVal - _inMin)*(_outMax - _outMin)/(_inMax - _inMin) + _outMin ;
+  if (rval < _outMin) {
+      rval = _outMin;
+      }
+  if  (rval > _outMax) {
+      rval = _outMax;
+      }
+  return rval;
 }