My team wants to subtract 127 from each joystick to change the range from 0 to 255 to -127 to 127. We originally had trouble with this statement:
x_joy_1 = p1_x - 127; // Makes the range -127 to 127
y_joy_1 = p1_y - 127;
p1_x is a defined term from the rcdata. x_joy_1 is an int. I'm not precisely sure why we had trouble - I suspect it's because p1_x is of the wrong type (it's a define, not an int).
Changing it as one of the team members suggested:
int(p1_x) and int(p1_y) resulted in a syntax error.
Our final result was this, which works fine:
x_joy_1 = p1_x;
y_joy_1 = p1_y;
x_joy_1 = x_joy_1 - 127; // Makes the range -127 to 127
y_joy_1 = y_joy_1 - 127;
printf("x_joy_1 is %d\r\n",x_joy_1);
printf("y_joy_1 is %d\r\n",y_joy_1);
Could someone shine some light on why this works the way it does? I'm sick of trial and error with variable int types

Isn't there a much more elegant way of coding this?