Quote:
Originally posted by rbayer
Here's the code we use:
p1_y=p1_y_filt+(softChangeCoeff*(2000+p1_y-p1_y_filt)/100) - (20*softChangeCoeff)
p1_x=p1_x_filt+(softChangeCoeff*(2000+p1_x-p1_x_filt)/100) - (20*softChangeCoeff)
it handles all cases and doesn't require any special condition testing
|
For the last couple of years, we have used the following code to filter our joystick inputs.
Code:
GAIN con 30
DIVISOR con 100
newJoystick = ((prevJoystick*(DIVISOR-GAIN)) + (newJoystick*GAIN)) / DIVISOR
I derived my algorithm by rearranging and simplifying IFI's code (basically the same as Rob's code above). I believe that as long as GAIN is chosen to be less than DIVISOR, and DIVISOR is less than 129 (to be extremely safe) mine will work perfectly.
It seems so much more straightforward than IFI's. If anyone can point out why it wouldn't work... or is less than optimal, I would appreciate you pointing it out to me.