From: Bernard Blackham Date: Mon, 21 Jun 2004 11:00:51 +0000 (+0000) Subject: Fix motor off by one errors. X-Git-Tag: ROMW~37 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=deac3b8b66af0f499d6da73cf5bf8479c7d9fad9;p=uccvend-snackrom.git Fix motor off by one errors. More useful error messages To romK --- diff --git a/ROM2/main_basic.c b/ROM2/main_basic.c index fc736d7..ae25a79 100644 --- a/ROM2/main_basic.c +++ b/ROM2/main_basic.c @@ -242,9 +242,21 @@ int main() { motor_num = cur_motor[0]%10; motor_num *= 10; motor_num += cur_motor[1]; - dispense_motor(motor_num); + switch (dispense_motor(motor_num)) { + case MOTOR_HOME_FAIL: + set_msg(" HOME FAIL "); + break; + case MOTOR_CURRENT_FAIL: + set_msg(" OVER CRNT "); + break; + case MOTOR_SUCCESS: + set_msg("THANK YOU"); + break; + default: + set_msg("ERRRRRRRR?"); + break; + } - set_msg("THANK YOU"); display_buf[0] = ' '; display_buf[1] = ' '; cur_motor[0] = 0xff; diff --git a/ROM2/motors.c b/ROM2/motors.c index 765c1b7..64158ae 100644 --- a/ROM2/motors.c +++ b/ROM2/motors.c @@ -97,7 +97,7 @@ bool is_motor(u8 slot) { bool left_home(u8 slot) { u8 i, r = slot%10; if (r >= 5) r--; - r = 1 << r; + r = 1 << (r-1); for (i = 0; i < 5; i++) if ((home_sensors & r) == 0) return 1; @@ -109,7 +109,7 @@ bool left_home(u8 slot) { bool back_home(u8 slot) { u8 i, r = slot%10; if (r >= 5) r--; - r = 1 << r; + r = 1 << (r-1); for (i = 0; i < 5; i++) { if (home_sensors & r) return 1;