Like Arduinos "map" function reScale converts values from different sizes.
Dependents: jrh52_a3 TBI_FIAT_FEEDFORWARD Ignition accuBlast_display ... more
Usage
#include "mbed.h" #include "reScale.h" reScale _scale(0,100,0,10); int main() { uint8_t value=_scale.from(50); // value is now set to 5 }
Revision 1:ebb951147122, committed 2014-03-03
- Comitter:
- c0ax
- Date:
- Mon Mar 03 19:57:45 2014 +0000
- Parent:
- 0:04d95412bcd3
- Commit message:
- Changed description. Usage example is now on library homepahe
Changed in this revision
reScale.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 04d95412bcd3 -r ebb951147122 reScale.cpp --- a/reScale.cpp Mon Mar 03 19:43:51 2014 +0000 +++ b/reScale.cpp Mon Mar 03 19:57:45 2014 +0000 @@ -5,6 +5,7 @@ { } + long reScale::from(long value) { return (value - _inMin) * (_outMax - _outMin) / (_inMax - _inMin) + _outMin;