blackbox/main.c

changeset 104
95b2c23cb973
parent 103
52fd4283cd2c
child 105
1defce561e64
--- a/blackbox/main.c	Sun Oct 28 16:18:53 2012 +0100
+++ b/blackbox/main.c	Sun Oct 28 17:41:10 2012 +0100
@@ -32,7 +32,7 @@
 #define FUEL_FULL       10000
 #define FUEL_JUMPSTART  5000
 #define FUEL_DIV_DEFAULT 25
-#define PITLANE_SPEEDLIMIT 4
+#define PITLANE_SPEEDLIMIT 6
 volatile uint8_t fuel_divisor = FUEL_DIV_DEFAULT; // default, can be set via serial command
 
 typedef struct {
@@ -41,6 +41,7 @@
     unsigned seccnt:4; // 4 bits tenth seconds counter
     unsigned accel:4; // 4 bits last configured acceleration
     unsigned speed:4; // 4 bits last speed
+    unsigned pitlane_limit:4; // 4bits speedlimit
     unsigned trackswitch:1; // 1bit bool
     unsigned canrefuel:1; // 1bit bool
     unsigned unlimitedfuel:1; // 1bit bool
@@ -152,6 +153,7 @@
         // pitlane response
         if (status == 5) slot[car].canrefuel = 1;
         if (status == 6) for (data=0; data<MAX_SLOTS; data++) slot[data].canrefuel = 0;
+        if (status == 7) slot[car].canrefuel = 0;
     }
     RS232_puts("RW:");
     RS232_putc(car + '0');
@@ -365,7 +367,7 @@
             if (tmp < slot[controller].speedminimum) tmp = slot[controller].speedminimum;
             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;
+            if (slot[controller].canrefuel && (tmp > slot[controller].pitlane_limit)) tmp = slot[controller].pitlane_limit;
         } else {
             if ((mode == 0) && (tmp < slot[controller].speedminimum)) tmp = slot[controller].speedminimum;
             if (tmp > slot[controller].speedlimit) tmp = slot[controller].speedlimit;
@@ -490,6 +492,7 @@
         slot[i].seccnt = 0;
         slot[i].accel = 15; // full acceleration per default - TODO
         slot[i].canrefuel = 0;
+        slot[i].pitlane_limit = PITLANE_SPEEDLIMIT;
         if (i<4) slot[i].unlimitedfuel = 0; else slot[i].unlimitedfuel = 1;
         slot[i].lap_time_start.value = 0;
         slot[i].lap_time.value = 0;

mercurial