new option to set pitlane entry as finish line too to increase laps

Sat, 15 Dec 2012 23:15:32 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Sat, 15 Dec 2012 23:15:32 +0100
changeset 124
0b12a8bf23b2
parent 123
ec623e5fcbca
child 125
edaf6a50276a

new option to set pitlane entry as finish line too to increase laps

blackbox/main.c file | annotate | diff | comparison | revisions
slotUI/slotCli.py file | annotate | diff | comparison | revisions
--- 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();
--- a/slotUI/slotCli.py	Sat Dec 15 22:55:30 2012 +0100
+++ b/slotUI/slotCli.py	Sat Dec 15 23:15:32 2012 +0100
@@ -79,6 +79,7 @@
     def __init__(self, test = None, dev=""):
         self.box = Blackbox()
         self.nofuel = False
+        self.pitfinish = False
         if (not test):
             self.box.connect(dev)
             self.rpcserver = SlotServer(self.box)
@@ -300,6 +301,13 @@
         else:
             #print cli.box.fueldivisor(25)
             self.box.query("F1\n") # set fuel logic enabled
+
+        if self.pitfinish:
+            self.box.query("X1\n") # set pitlane finish function
+        else:
+            #print cli.box.fueldivisor(25)
+            self.box.query("X0\n")
+
         self.box.query("*%i\n" % live) # set live fuel info
 
     def monitor_learn(self, slot):
@@ -646,6 +654,8 @@
         help="Run Live monitor on console", metavar="[0-5]")
     parser.add_option("--nofuel", dest="nofuel", action="store_true", default=False,
         help="Disable Freeslot fuel management", metavar="[0-5]")
+    parser.add_option("--pit", dest="pitfinish", action="store_true", default=False,
+        help="Pitlane entry acts as finish line too", metavar="[0-5]")
     parser.add_option("--learn", dest="learn", action="store_true", default=False,
         help="Run Learning mode for [slot]", metavar="[0-5]")
     parser.add_option("--teach", dest="playback", 
@@ -683,6 +693,7 @@
     if options.live:
         # start the live monitor
         cli.nofuel = options.nofuel
+        cli.pitfinish = options.pitfinish
         cli.monitor()
         sys.exit(0)
 

mercurial