|
Re: Joystick Input Mapping
We do a few things, first we make everything into a signed char, and set the middle point of the joystick or PWM to 0, to get a range of -128 to 127, this makes things a bit easier to handle.
For our joystick input we put everything through a curve that we calc' in a speadsheet and then convert to a table like this:
#define curveXX curve18
char curve18[] =
{
0 , 0 , 0 , 1 , 1 , 1 , 2 , 2 , 3 , 3 , 4 , 4 , 5 , 5 , 6 , 6 ,
7 , 8 , 8 , 9 , 10 , 10 , 11 , 12 , 12 , 13 , 14 , 15 , 15 , 16 , 17 , 18 ,
18, 19 , 20 , 21 , 22 , 23 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 ,
33 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 47 , 48 ,
49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 60 , 61 , 62 , 63 , 64 , 65 ,
66 , 68 , 69 , 70 , 71 , 72 , 74 , 75 , 76 , 77 , 78 , 80 , 81 , 82 , 83 , 85 ,
86 , 87 , 88 , 90 , 91 , 92 , 93 , 95 , 96 , 97 , 99 , 100, 101, 103, 104, 105,
107, 108, 109, 111, 112, 113, 115, 116, 117, 119, 120, 121, 123, 124, 126, 127
};
char GetCurve(char raw)
{
if (raw < 0)
return -curveXX[-raw];
else
return curveXX[raw];
}
This alows us to tweek the curve by hand if we need to.
-Jim
|