MAP like derivation function485

Avocadodude private msg quote post Address this user
In a derived stream is there a way to map values. In Arduino case it would be something like:
val = map(val, 0, 1023, 0, 255);
I suppose I can just write the math function, just seeing if I missed something in the deviation functions.
Post 1 IP   flag post
MikeMills private msg quote post Address this user
Never heard of that function. From the arduino site I found out it is doing this:

long map(long x, long in_min, long in_max, long out_min, long out_max)
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;

Do you think this is a common function and would be worth adding to our derivation library?
Post 2 IP   flag post
2678 2 2
Log in or sign up to compose a reply.