Fix motor off by one errors.
authorBernard Blackham <[email protected]>
Mon, 21 Jun 2004 11:00:51 +0000 (11:00 +0000)
committerBernard Blackham <[email protected]>
Mon, 21 Jun 2004 11:00:51 +0000 (11:00 +0000)
More useful error messages
To romK

ROM2/main_basic.c
ROM2/motors.c

index fc736d7..ae25a79 100644 (file)
@@ -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;
index 765c1b7..64158ae 100644 (file)
@@ -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;

UCC git Repository :: git.ucc.asn.au