blackbox/main.c

changeset 91
e0738355b517
parent 90
7ed95dbadf1f
child 92
c57f43f25a5c
--- a/blackbox/main.c	Sat Dec 17 13:35:40 2011 +0100
+++ b/blackbox/main.c	Sat Dec 17 14:11:16 2011 +0100
@@ -347,7 +347,6 @@
         if (controller == 5) tmp = ((getADC(CONTROLLER2_SPEED) / CONTROLLER_DIVISOR) & 0x0F);
         if (controller == 4) trackchange = (PIN(CONTROLLER_PORT) & _BV(CONTROLLER1_SW));
         if (controller == 5) trackchange = (PIN(CONTROLLER_PORT) & _BV(CONTROLLER2_SW));
-        speed = tmp;
     } else {
         // read speeds
         if ((controller == 0) && (mode!=1)) tmp = ((getADC(CONTROLLER1_SPEED) / CONTROLLER_DIVISOR) & 0x0F);
@@ -364,41 +363,35 @@
             if ((mode == 2) && (tmp != 0)) { jumpstart(controller); tmp = 0; }
             if (tmp > slot[controller].speedlimit) tmp = slot[controller].speedlimit;
             if (slot[controller].canrefuel && (tmp > PITLANE_SPEEDLIMIT)) tmp = PITLANE_SPEEDLIMIT;
-            speed = tmp;
-            tmp = tmp << 1;
         } else {
             if ((mode == 0) && (tmp < slot[controller].speedminimum)) tmp = slot[controller].speedminimum;
             if (tmp > slot[controller].speedlimit) tmp = slot[controller].speedlimit;
-            speed = tmp;
-            tmp = tmp << 1;
-            //if ( (trackchange!=0) || (slot[controller].trackswitch)) tmp |= (1<<5);
-            if (trackchange!=0) tmp |= (1<<5);
+            // //if ( (trackchange!=0) || (slot[controller].trackswitch)) tmp |= (1<<5);
         }
+    }
+    speed = tmp;
+    tmp = tmp << 1;
+    if (trackchange != 0) tmp |= (1<<5);
 
-    }
 
     switch (controller) {
         case 0:
             if (trackchange != 0) {
-                tmp |= (1<<5);
                 if (mode == 0) LED(1,0);
             } else if (mode == 0) LED(1,1);
             break;
         case 1:
             if (trackchange != 0) {
-                tmp |= (1<<5);
                 if (mode == 0) LED(2,0);
             } else if (mode == 0) LED(2,1);
             break;
         case 2:
             if (trackchange != 0) {
-                tmp |= (1<<5);
                 if (mode == 0) LED(4,0);
             } else if (mode == 0) LED(4,1);
             break;
         case 3:
             if (trackchange != 0) {
-                tmp |= (1<<5);
                 if (mode == 0) LED(5,0);
             } else if (mode == 0) LED(5,1);
             break;

mercurial