This code is (almost) identical to the code in sensors.c.  Is it worth factoring it out and parameterizing the scale and bias vectors or is something preventing that?