pitlane checkout bug resolved, prepare for customized pitlane speedlimit

Sun, 28 Oct 2012 17:41:10 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Sun, 28 Oct 2012 17:41:10 +0100
changeset 104
95b2c23cb973
parent 103
52fd4283cd2c
child 105
1defce561e64

pitlane checkout bug resolved, prepare for customized pitlane speedlimit

blackbox/main.c file | annotate | diff | comparison | revisions
pitlane/Makefile file | annotate | diff | comparison | revisions
pitlane/main.c file | annotate | diff | comparison | revisions
slotUI/SlotCli.py file | annotate | diff | comparison | revisions
trackswitch/Makefile file | annotate | diff | comparison | revisions
--- 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;
--- a/pitlane/Makefile	Sun Oct 28 16:18:53 2012 +0100
+++ b/pitlane/Makefile	Sun Oct 28 17:41:10 2012 +0100
@@ -13,6 +13,11 @@
 BAUD=38400
 
 ISP_BAUD = 115200
+ifdef USB
+PORT=/dev/ttyUSB$(USB)
+else
+PORT=/dev/ttyS0
+endif
 
 #SRC = main.c seriald.c driver/ADC.c driver/clock.c driver/timer.c
 #SRC = main.c driver/rs232.c driver/manchester.c
@@ -74,7 +79,10 @@
 	rm $(PRG).map
 
 program: code
-	$(AVRDUDE) -c stk500v2 -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i
+	$(AVRDUDE) -P $(PORT) -c stk500v2 -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i
+
+backup:
+	$(AVRDUDE) -P $(PORT) -c stk500v2 -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:r:$(PRG)_backup.hex:i
 
 fuse:
 	$(AVRDUDE) -c stk500 -p $(MCU) -V $(FUSES)
--- a/pitlane/main.c	Sun Oct 28 16:18:53 2012 +0100
+++ b/pitlane/main.c	Sun Oct 28 17:41:10 2012 +0100
@@ -356,12 +356,16 @@
         // we have to detect which car is passing sensor2 - but at the moment we are lack of external interrupt source
         if ( (PIN(SENS2_PORT) & _BV(SENS2_PIN)) != 0 ) {
                 // set inside status
-                for (tmp=0; tmp<MAX_SLOTS; tmp++)
-                    if (slot[tmp].inside) {
-                    slot[tmp].inside = 0;
+                for (tmp=0; tmp<MAX_SLOTS; tmp++) {
+                    // workaround: only reset tanking on cars which have speed>0, so parking cars will not get "outside"
+                    if (slot[tmp].inside && (slot[tmp].speed > 0)) {
+                        slot[tmp].inside = 0;
+                        response = 7;
+                        response_car = tmp;
+                    }
                 }
-                response = 6;
-                response_car = 0;
+                //response = 6;
+                //response_car = 0;
                 RS232_puts_p(PSTR("PIT:EXIT\n"));
         }
 
--- a/slotUI/SlotCli.py	Sun Oct 28 16:18:53 2012 +0100
+++ b/slotUI/SlotCli.py	Sun Oct 28 17:41:10 2012 +0100
@@ -462,7 +462,7 @@
                             if (status == 5):
                                 self.slot[slot]["status"] = "PITLANE"
                                 trigger_sound("pitlane_enter")
-                            if (status == 6):
+                            if (status == 7):
                                 self.slot[slot]["status"] = "IN-RACE"
                                 trigger_sound("pitlane_exit")
 
--- a/trackswitch/Makefile	Sun Oct 28 16:18:53 2012 +0100
+++ b/trackswitch/Makefile	Sun Oct 28 17:41:10 2012 +0100
@@ -13,6 +13,11 @@
 BAUD=38400
 
 ISP_BAUD = 115200
+ifdef USB
+PORT=/dev/ttyUSB$(USB)
+else
+PORT=/dev/ttyS0
+endif
 
 #SRC = main.c seriald.c driver/ADC.c driver/clock.c driver/timer.c
 #SRC = main.c driver/rs232.c driver/manchester.c
@@ -74,7 +79,10 @@
 	rm $(PRG).map
 
 program: code
-	$(AVRDUDE) -c stk500v2 -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i
+	$(AVRDUDE) -P $(PORT) -c stk500v2 -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i
+
+backup:
+	$(AVRDUDE) -P $(PORT) -c stk500v2 -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:r:$(PRG)_backup.hex:i
 
 fuse:
 	$(AVRDUDE) -c stk500 -p $(MCU) -V $(FUSES)

mercurial