View Single Post
  #9   Spotlight this post!  
Unread 24-04-2008, 10:54
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Joystick Input Mapping

The lookup tables suggested earlier are definitely the way to go.

If you're looking for a quick and dirty method to test things out, you can also try:

Code:
temp_p1_long = (signed long)p1_y - 127;
pwm01 = (unsigned char)(((temp_p1_long * temp_p1_long * temp_p1_long)  >> 14) + 127);

temp_p2_long = (signed long)p2_y - 127;
pwm02 = (unsigned char)(((temp_p2_long * temp_p2_long * temp_p2_long)  >> 14) + 127);
It's a cubic transfer function that we've used since 2004. If it works for you, you're eventually better off calculating the values from the function, and using a look-up table for competition. The long integer operations are a bit wasteful, but it's four quick lines of code for testing!
__________________
In life, what you give, you keep. What you fail to give, you lose forever...