betatest corrections

Thu, 15 Dec 2011 17:58:22 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Thu, 15 Dec 2011 17:58:22 +0100
changeset 81
4f2f94a043fd
parent 80
393b63b8c95f
child 82
c89221096db7

betatest corrections

blackbox/main.c file | annotate | diff | comparison | revisions
slotUI/SlotCli.py file | annotate | diff | comparison | revisions
--- a/blackbox/main.c	Wed Dec 14 20:43:08 2011 +0100
+++ b/blackbox/main.c	Thu Dec 15 17:58:22 2011 +0100
@@ -26,6 +26,7 @@
 } u32;
 
 #define FUEL_FULL       10000
+#define FUEL_JUMPSTART  5000
 #define FUEL_DIV_DEFAULT 25
 volatile uint8_t fuel_divisor = FUEL_DIV_DEFAULT; // default, can be set via serial command
 
@@ -272,11 +273,12 @@
     if (slot[controller].jumpstart_time == 0) {
         slot[controller].jumpstart_time = sysclk.word[0]; // low word
         RS232_putc('~');
-        RS232_putc('0'-controller);
+        RS232_putc('0'+controller);
         RS232_putc(':');
         itoa(slot[controller].jumpstart_time, s, 16);
         RS232_puts(s);
         RS232_putc('\n');
+        slot[controller].fuel = FUEL_JUMPSTART; // suck 50% off that bitch!
     }
 
 }
@@ -316,7 +318,8 @@
             if (tmp > slot[controller].speedlimit) tmp = slot[controller].speedlimit;
             speed = tmp;
             tmp = tmp << 1;
-            if (trackchange || slot[controller].trackswitch) tmp |= (1<<5);
+            //if ( (trackchange!=0) || (slot[controller].trackswitch)) tmp |= (1<<5);
+            if (trackchange!=0) tmp |= (1<<5);
         }
 
     }
--- a/slotUI/SlotCli.py	Wed Dec 14 20:43:08 2011 +0100
+++ b/slotUI/SlotCli.py	Thu Dec 15 17:58:22 2011 +0100
@@ -12,7 +12,7 @@
 from copy import copy
 import curses
 
-VERSION = "1.3"
+VERSION = "1.4"
 MAXSLOTS = 6
 TERM = {
     "caption": "\033[1;37m\033[1;44m",
@@ -22,11 +22,18 @@
 # disable debug log output
 LOGLEVEL = 10
 
+SOUNDPREFIX = "quake-"
+
 SOUNDS = {
-        "countdown_start": os.path.abspath("sound/countdown.mp3"),
-        "race_start":      os.path.abspath("sound/racestart.mp3"),
-        "race_prepare":    os.path.abspath("sound/siren.mp3"),
-        "lap_record":      os.path.abspath("sound/laprecord.mp3"),
+        "countdown_start": os.path.abspath(SOUNDPREFIX + "sound/countdown.mp3"),
+        "race_start":      os.path.abspath(SOUNDPREFIX + "sound/racestart.mp3"),
+        "race_prepare":    os.path.abspath(SOUNDPREFIX + "sound/siren.mp3"),
+        "lap_record":      os.path.abspath(SOUNDPREFIX + "sound/laprecord.mp3"),
+        "fuel_warning1":   os.path.abspath(SOUNDPREFIX + "sound/fuel1.mp3"),
+        "fuel_warning2":   os.path.abspath(SOUNDPREFIX + "sound/fuel2.mp3"),
+        "fuel_full":       os.path.abspath(SOUNDPREFIX + "sound/fuel_full.mp3"),
+        "pitlane_enter":   os.path.abspath(SOUNDPREFIX + "sound/pitlane_enter.mp3"),
+        "pitlane_exit":    os.path.abspath(SOUNDPREFIX + "sound/pitlane_exit.mp3"),
     }
 
 def trigger_sound(what):
@@ -45,6 +52,7 @@
             "last": 0.00,
             "best": 0.00,
             "fuel": 0,
+            "fuel_last": 0,
             "position": 0,
             "drive": 0,
             "status": "Idle",
@@ -68,6 +76,7 @@
             slt["last"] = 0.00
             slt["best"] = 0.00
             slt["fuel"] = 0
+            slt["fuel_last"] = 0
             slt["position"] = idx
             slt["car"] = idx # used for sort order calculation
             slt["status"] = self.slot_dummy["status"]
@@ -207,7 +216,26 @@
                     f = int(data[2], 16)
                     f = f / 100 # fuel in percent
                     self.sysclk = int(data[3], 16) / 2000.00
+                    self.slot[slot]["fuel_last"] = self.slot[slot]["fuel"]
                     self.slot[slot]["fuel"] = f
+                    if self.slot[slot]["fuel_last"] != f:
+                        # 10 percent fuel, set speed limit for car to 8
+                        if (self.slot[slot]["fuel_last"] == 11) and (f == 10):
+                            # warning sound
+                            trigger_sound("fuel_warning1")
+                            cli.box.speedlimit(slot, 8)
+                        # 5 percent, set speed limit for car to 4
+                        if (self.slot[slot]["fuel_last"] == 6) and (f == 5):
+                            # warning sound
+                            trigger_sound("fuel_warning2")
+                            cli.box.speedlimit(slot, 4)
+                        if (self.slot[slot]["fuel_last"] == 1) and (f == 0):
+                            # set speedlimit to 2
+                            cli.box.speedlimit(slot, 2)
+                        if (self.slot[slot]["fuel_last"] < f) and (f >= 11) and (f < 20):
+                            cli.box.speedlimit(slot, 15)
+                        if (self.slot[slot]["fuel_last"] < f) and (f == 100):
+                            trigger_sound("fuel_full")
                     self.render_slots()
 
                 if rx[:1] == "~":
@@ -226,8 +254,12 @@
                     self.sysclk = int(data[5], 16)
                     if (devtype == 4):
                         # pitlane sent something
-                        if (status == 5): self.slot[slot]["status"] = "PITLANE"
-                        if (status == 6): self.slot[slot]["status"] = "IN-RACE"
+                        if (status == 5):
+                            self.slot[slot]["status"] = "PITLANE"
+                            trigger_sound("pitlane_enter")
+                        if (status == 6):
+                            self.slot[slot]["status"] = "IN-RACE"
+                            trigger_sound("pitlane_exit")
 
                     self.render_slots()
 

mercurial