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);