added unlimited fuel for profile (set fuel=0 to enable)

Sat, 21 Dec 2013 13:49:46 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Sat, 21 Dec 2013 13:49:46 +0100
changeset 143
cb514887cf17
parent 142
a933d44a6edc
child 144
8f07a8d15826

added unlimited fuel for profile (set fuel=0 to enable)

blackbox/main.c file | annotate | diff | comparison | revisions
slotUI/freeslot.py file | annotate | diff | comparison | revisions
slotUI/slotCli.py file | annotate | diff | comparison | revisions
--- a/blackbox/main.c	Sat Dec 21 13:08:43 2013 +0100
+++ b/blackbox/main.c	Sat Dec 21 13:49:46 2013 +0100
@@ -15,6 +15,7 @@
 
 const char ok[]               PROGMEM="OK\n";
 const char busy[]             PROGMEM="BUSY\n";
+const char error[]            PROGMEM="ERROR\n";
 
 const char prepare[]          PROGMEM="!PRE\n";
 const char countdownstart[]   PROGMEM="!SET\n";
@@ -253,6 +254,15 @@
                     } else RS232_puts_p(busy);
                     break;
 
+                case 'U': // Set unlimited fuel status for a car (id 4..5 default to unlimited fuel)
+                    tmp = buffer[1]-'0';
+                    if (tmp < 6) {
+                        slot[tmp].unlimitedfuel = 0;
+                        if ((buffer[2]-'0') != 0) slot[tmp].unlimitedfuel = 1;
+                        RS232_puts_p(ok);
+                    } RS232_puts_p(error);
+                    break;
+
                 case 'L': // Limit maximum speed for a car
                     tmp = buffer[2]-'0';
                     if (tmp > 9)
--- a/slotUI/freeslot.py	Sat Dec 21 13:08:43 2013 +0100
+++ b/slotUI/freeslot.py	Sat Dec 21 13:49:46 2013 +0100
@@ -191,6 +191,16 @@
         else:
             return self.com.query( "P40%i" % carid )
 
+    def unlimitedfuel(self, carid, boolval):
+        """
+        Set unlimited fuel on/off for a car
+        """
+        if (carid < 0) or (carid > 5):
+            return "ERR - invalid carid"
+        value = 0
+        if boolval: value = 1
+        return  self.com.query( "U%i%i" % (carid, value) )
+
     def speedlimit(self, carid, value):
         """
         Set the maximum controller speed for a car
--- a/slotUI/slotCli.py	Sat Dec 21 13:08:43 2013 +0100
+++ b/slotUI/slotCli.py	Sat Dec 21 13:49:46 2013 +0100
@@ -227,6 +227,8 @@
         sleep(0.5)
         self.box.speedlimit(slot, self.slot[slot]["limit"])
         sleep(0.5)
+        self.box.unlimitedfuel(slot, (self.slot[slot]["profile"].getint("Settings", "Fuel") == 0) )
+        sleep(0.5)
         self.cleartop()
         self.box.setmode(1)
 
@@ -249,6 +251,7 @@
                 self.slot[slot]["limit"] = self.slot[slot]["profile"].getint("Settings", "Limit")
                 self.flash_car_settings(slot)
             except IOError, err:
+                # load default profile
                 self.slot[slot]["profilename"] = "default"
                 self.slot[slot]["profile"].read("profiles/default")
                 self.slot[slot]["limit"] = self.slot[slot]["profile"].getint("Settings", "Limit")

mercurial