View Single Post
  #3   Spotlight this post!  
Unread 02-02-2005, 15:54
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: need help w/ joystick code

Add a joystick deadzone in the code. For example:

Code:
#define JOY_DEADZONE 10
if (xJ_raw < 127-JOY_DEADZONE)
{
    xJ_raw = xJ_raw + JOY_DEADZONE;
}
else if (xJ_raw > 127+JOY_DEADZONE)
{
    xJ_raw = xJ_raw - JOY_DEADZONE;
}
else
{
    xJ_raw = 0;
}

if (yJ_raw < 127-JOY_DEADZONE)
{
    yJ_raw = yJ_raw + JOY_DEADZONE;
}
else if (yJ_raw > 127+JOY_DEADZONE)
{
    yJ_raw = yJ_raw - JOY_DEADZONE;
}
else
{
    yJ_raw = 0;
}
Of course, the above assumes that the joystick is biased at 127 and you are using unsigned variables for your joystick axes.
__________________
-
An ounce of perception is worth a pound of obscure.