uint16_t tween(uint16_t rpm){
const uint16_t rpm_table[] = {0,800,1000,2000,3000,4000,5000,6000,7000,8000,65535};
const int16_t adj_table[] = {0,50,100,50,0,-50,-100,-100,-150,0,0};
uint16_t low,high;
int16_t adjLow,adjHigh;
int32_t adjust;
uint8_t p=0;
while(!(rpm<rpm_table[p+1]))
p++;
//p now points to the lower of the two rpm values it's between.
low=rpm_table[p];
high=rpm_table[p+1];
adjLow=adj_table[p];
adjHigh=adj_table[p+1];
adjust=rpm-low; //how far into the triangle are we?
adjust=adjust*(adjHigh-adjLow); //multiply by the height of the triangle
adjust/=(high-low); //divide by the width of the triangle
return(rpm+adjust+adjLow);
}