View Single Post
  #3   Spotlight this post!  
Unread 17-02-2008, 10:34
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Mentor, LRI, MN RPC
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,815
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: reducing sensativity of joystick for precision?

The cubic equation is actually fairly easy to use. It looks something like this:

Code:
long temp;
long answer;
long divisor = 127;
temp =((int)p1_y) - 127; //this centers the input range between -127 and 127
answer = (temp*temp*temp) / (divisor*divisor);
answer = answer + 127; //shift the answer back over to the range 0-255
Just make sure you use longs, because you'll overflow an int! The basic idea is that you have a very shallow curve near 0, and a steeper curve near the extremes (-127 and 127). You get all the way to the extremes because 127^3/127^2 is 127. Throw in a couple of more values, and you see that moving the joystick 30 away from center gives you an answer that's only 3 or 4 away, and it can really help.