View Single Post
  #4   Spotlight this post!  
Unread 11-02-2005, 11:27
Mike Soukup's Avatar
Mike Soukup Mike Soukup is offline
Software guy
FRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Schaumburg, IL
Posts: 797
Mike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond reputeMike Soukup has a reputation beyond repute
Re: using limit_switch_max/min in autonomus

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.