Quote:
|
Originally Posted by Leav
somewhat related.... why does the limit max funxtion require that you add 2000, only to disregard it in the function itself?
|
That's carried over from the PBASIC controller which didn't deal with negative numbers correctly (or at all, I can't remember). I scrapped the Limit_Mix function and wrote my own MIN & MAX macros. Here's what our code looks like:
Code:
int right_drive_speed, left_drive_speed
right_drive_speed = (int)Oi_drive_y + (int)Oi_drive_x - 127;
MIN(right_drive_speed, 0);
MAX(right_drive_speed, 254);
left_drive_speed = (int)Oi_drive_y - (int)Oi_drive_x + 127;
MIN(left_drive_speed, 0);
MAX(left_drive_speed, 254);
In my opinion it's much more readable than the code IFI gave us, and it doesn't have the unnecessary 2000 addition / subtraction.