return motor_here(slot);
}
-bool left_home(u8 slot) {
+bool start_motor(u8 slot) {
u16 i;
u8 r = slot%10;
if (r >= 5) r--;
r = 1 << (r-1);
+ motor_on(slot);
+ delay(100);
for (i = 0; i < 1000; i++) {
if ((home_sensors & r) != 0) return 1;
delay(1);
}
/* it never left */
+ motors_off();
return 0;
}
for (i = 0; i < 5; i++) {
if ((home_sensors & r) == 0) return 1;
+ delay(1);
}
/* it never arrived */
u8 dispense_motor(u8 slot) {
if (!is_motor(slot)) return MOTOR_NOSLOT;
-
- motor_on(slot);
-
- if (!left_home(slot)) {
- motors_off();
- return MOTOR_HOME_FAIL;
- }
+ if (!start_motor(slot)) return MOTOR_HOME_FAIL;
while (1) {
if (motor_overcurrent()) {