so, on reflection, i was thinking that fixed point math would be your best bet here. hmm, but there is no fixed point math on the arduino. it's easy enough to fake it though.
assuming that my assertions above are correct, we need to calculate degrees * (205/180). 205/180 is 1.13888889. multiply that by 256 to get 292, which will be the fixed point, 8 bit integer + 8 bit fractional, representation of 1.13888889.
so multiply the position you want in degrees by 292, add 128 to round the result, and shift the whole thing right 8 bits to get just the integer part, then add 205 and you've got the off time for the servo.
- Code: Select all | TOGGLE FULL SIZE
setPWM (channel, 0, ((degress * 292 + 128) >> 8) + 205);
why? you may ask. because floating point arithmetic on the arduino is god awful slow.
i think i've demonstrated already, that my work should be checked.
"If I had known it was harmless, I would have killed it myself." - Phillip K. Dick, A Scanner Darkly