added option to disable freeslot fuel logic

Sun, 02 Dec 2012 19:54:14 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Sun, 02 Dec 2012 19:54:14 +0100
changeset 116
c2fc650cc48f
parent 115
bb150048d329
child 117
534e5c4b82c3

added option to disable freeslot fuel logic

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	Sun Dec 02 19:19:23 2012 +0100
+++ b/blackbox/main.c	Sun Dec 02 19:54:14 2012 +0100
@@ -410,7 +410,7 @@
     if ( ((PIN(SW_FUEL_PORT) & _BV(SW_FUEL)) != 0) | (slot[controller].fuel == 0)) tmp |= 1;
     if (insert_queue(tmp, 9)) {
         if ((fuel_enabled) && (slot[controller].unlimitedfuel == 0)) {
-            if (speed != 0) {
+            if ((speed != 0) && (fuel_divisor > 0)) {
                 // do the fuel calculation, regardless if fuel logic active or not
                 tmp = (uint8_t)(((slot[controller].accel * speed) + 1) / fuel_divisor);
                 if (tmp == 0) tmp = 1;
--- a/slotUI/freeslot.py	Sun Dec 02 19:19:23 2012 +0100
+++ b/slotUI/freeslot.py	Sun Dec 02 19:54:14 2012 +0100
@@ -161,6 +161,14 @@
             value = chr(ord("A") + (value-10))
         return self.com.query( "S%i%s" % (carid, value) )
 
+    def fueldivisor(self, value):
+        """
+        Set the minimzm controller speed for a car
+        """
+        if (value<0) or (value>255):
+            return "ERR - invalid value"
+        return self.com.query( "F:%s" % (value) )
+
 
     def setmode(self, mode):
         """
--- a/slotUI/slotCli.py	Sun Dec 02 19:19:23 2012 +0100
+++ b/slotUI/slotCli.py	Sun Dec 02 19:54:14 2012 +0100
@@ -77,6 +77,7 @@
 class SlotCli():
     def __init__(self, test = None, dev=""):
         self.box = Blackbox()
+        self.nofuel = False
         if (not test):
             self.box.connect(dev)
             self.rpcserver = SlotServer(self.box)
@@ -198,14 +199,14 @@
     def flash_car_settings(self, slot):
         # write current settings to car firmware
         self.box.setmode(0)
-        self.cleartop()
-        self.scr.addstr(0,0, "Writing settings for %s to car %i..." % (
+        self.scr.addstr(1,0, "%70s" % "Writing settings for %s to car %i, PLEASE WAIT...          " % (
             self.slot[slot]["name"],
             slot + 1),
-            curses.color_pair(1))
+            curses.color_pair(9))
         self.scr.refresh()
-        self.box.progcar(slot, "fuel", 0)
-        sleep(0.5)
+        if not self.nofuel:
+            self.box.progcar(slot, "fuel", 0)
+            sleep(0.5)
         self.box.progcar(slot, "accel", self.slot[slot]["profile"].getint("Settings", "Accel"))
         sleep(0.5)
         self.box.progcar(slot, "brake", self.slot[slot]["profile"].getint("Settings", "Brake"))
@@ -283,7 +284,12 @@
         """
         Send initializing commands for live monitoring
         """
-        self.box.query("F1\n") # set fuel logic enabled
+        if self.nofuel:
+            #print cli.box.fueldivisor(0)
+            self.box.query("F0\n") # set fuel logic disabled
+        else:
+            #print cli.box.fueldivisor(25)
+            self.box.query("F1\n") # set fuel logic enabled
         self.box.query("*%i\n" % live) # set live fuel info
 
     def monitor_learn(self, slot):
@@ -391,6 +397,7 @@
         curses.start_color()
         curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) # standard text
         curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLUE) # label
+        curses.init_pair(9, curses.COLOR_WHITE, curses.COLOR_RED) # ATTENTION
         curses.init_pair(11, curses.COLOR_BLACK, curses.COLOR_YELLOW) # player 1 slot
         curses.init_pair(12, curses.COLOR_BLACK, curses.COLOR_GREEN) # player 2 slot
         curses.init_pair(13, curses.COLOR_BLACK, curses.COLOR_RED) # player 3 slot
@@ -409,9 +416,10 @@
 
         while 1:
             key = self.scr.getch()
-            if key == ord('c'): break
+            if key == ord('q'): break
             elif key == ord(' '): self.box.query("+") # panic / resume
             elif key == 10: self.box.query("#") # remote start button press
+
             elif key == ord('1'): self.readName(0)
             elif key == ord('2'): self.readName(1)
             elif key == ord('3'): self.readName(2)
@@ -614,6 +622,8 @@
     parser = OptionParser(version="%prog " + VERSION)
     parser.add_option("--live", dest="live", action="store_true", default=False,
         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("--learn", dest="learn", action="store_true", default=False,
         help="Run Learning mode for [slot]", metavar="[0-5]")
     parser.add_option("--teach", dest="playback", 
@@ -650,6 +660,7 @@
 
     if options.live:
         # start the live monitor
+        cli.nofuel = options.nofuel
         cli.monitor()
         sys.exit(0)
 

mercurial