View Single Post
  #2   Spotlight this post!  
Unread 29-05-2006, 16:53
foobert foobert is offline
Registered User
no team
 
Join Date: May 2005
Location: oakland, ca
Posts: 87
foobert is a jewel in the roughfoobert is a jewel in the roughfoobert is a jewel in the rough
Re: Vex Library and Sample Code

Quote:
Originally Posted by tacman1123
Code:
   if (get_input(1) == 0) { // limit switch pressed
      set_motor(1, motor_speed);
   }
without having to write get_input() and set_motor(), but with the ability to modify them?
well, gee, if you're not going to read your inputs and check your outputs it doesn't seem like there's much left for you to do.

if you just want to hide implementation details you can always use defines. for instance...

#define LIMIT_SWITCH_PRESSED get_input(1) == 0

...

if (LIMIT_SWITCH_PRESSED)
set_motor (1, motor_speed / 5 + 100);

which will damp your motor speed to values between 100 and 150. maybe another definition might help, e.g.

#define set_left (a) set_motor (1, (a) / 5 + 100)

so you get

if (LIMIT_SWITCH_PRESSED) set_left (motor_speed);
Reply With Quote