Here’s another very, very tiny function I think might be a good idea to add to the firmware. Basically, it maps a number from one scale to another. I use this function almost constantly and it comes on the Arduino. Maybe something to add to the exMath library?
/// <summary>
/// M map a number from one scale to another
/// </summary>
/// <param name="x"></param>
/// <param name="in_min"></param>
/// <param name="in_max"></param>
/// <param name="out_min"></param>
/// <param name="out_max"></param>
/// <returns></returns>
public long map(int x, int in_min, int in_max, int out_min, int out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}