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

}

Committer:
c0ax
Date:
Mon Mar 03 19:43:51 2014 +0000
Revision:
0:04d95412bcd3
Initial release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
c0ax 0:04d95412bcd3 1 #include "mbed.h"
c0ax 0:04d95412bcd3 2
c0ax 0:04d95412bcd3 3 class reScale {
c0ax 0:04d95412bcd3 4 public:
c0ax 0:04d95412bcd3 5 reScale(long in_min, long in_max, long out_min, long out_max);
c0ax 0:04d95412bcd3 6
c0ax 0:04d95412bcd3 7 long from(long value);
c0ax 0:04d95412bcd3 8 protected:
c0ax 0:04d95412bcd3 9 long _inMin ,_inMax ,_outMin ,_outMax ;
c0ax 0:04d95412bcd3 10 };