Quote:
|
Originally Posted by X-Istence
Code:
char joystick_input_2 = 0;
char drive_output = 0;
Why are these straight up char's and not unsigned?
|
Because of the line,
Code:
joystick_input_2 = joystick_input - 127;
joystick_input can be 0 to 255 so the result of this line can be a negative value, so the variables being assigned to must be signed.
Have you commented out the calls to SlowDrive() to prove that is where the runtime error comes from?
I don't know what this particular compiler does but I wonder about this line,
Code:
joystick_input_2 = joystick_input - 127;
joystick_input is unsigned, so the temporary variable created is unsigned, then 127 is subtracted from that, then the temporary is assigned to joystick_input_2. Maybe that is it? To test this theory change that one line to this,
Code:
joystick_input_2 = joystick_input;
joystick_input_2 = joystick_input_2 - 127;
The first line handles the type change then the second line does exactly what you expect.