slotUI/slotCli.py

changeset 116
c2fc650cc48f
parent 115
bb150048d329
child 117
534e5c4b82c3
--- 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