blackbox/main.c

changeset 124
0b12a8bf23b2
parent 123
ec623e5fcbca
child 125
edaf6a50276a
--- a/blackbox/main.c	Sat Dec 15 22:55:30 2012 +0100
+++ b/blackbox/main.c	Sat Dec 15 23:15:32 2012 +0100
@@ -32,7 +32,7 @@
 #define FUEL_FULL       10000
 #define FUEL_JUMPSTART  5000
 #define FUEL_DIV_DEFAULT 25
-#define PITLANE_SPEEDLIMIT 15
+#define PITLANE_SPEEDLIMIT 10
 volatile uint8_t fuel_divisor = FUEL_DIV_DEFAULT; // default, can be set via serial command
 
 typedef struct {
@@ -63,9 +63,10 @@
 extern uint8_t  btn_start = _BV(SW_START);
 extern uint8_t  old_start = _BV(SW_START);
 
-
+// todo: pack as bit structure:
 uint8_t  liveinfo = 0;
 uint8_t  fuel_enabled = 1;
+uint8_t  pitlane_finishline = 0;
 
 volatile u32 sysclk;
 volatile uint8_t sysclk_packettimer = 0;
@@ -151,7 +152,10 @@
     uint8_t type = (data & 0b111);
     if (type == 4) {
         // pitlane response
-        if (status == 5) slot[car].canrefuel = 1;
+        if (status == 5) {
+            slot[car].canrefuel = 1;
+            if (pitlane_finishline) slot[car].laps++;
+        }
         if (status == 6) for (data=0; data<MAX_SLOTS; data++) slot[data].canrefuel = 0;
         if (status == 7) slot[car].canrefuel = 0;
     }
@@ -277,6 +281,13 @@
                     RS232_puts_p(ok);
                     break;
 
+                case 'X': // set Pitlane act as finish line
+                    // this can be used if pitlane exit comes after finish line while pitlane entry is before finish line
+                    pitlane_finishline = buffer[1]-'0';
+                    RS232_puts_p(ok);
+                    break;
+
+
                 case '#': // remote start button press
                     RS232_puts_p(ok);
                     startbutton();

mercurial