improved live display with colors

Sat, 17 Dec 2011 15:38:17 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Sat, 17 Dec 2011 15:38:17 +0100
changeset 94
c7ff8cde6b1e
parent 93
ee4f9b8a36e9
child 95
85c4a4da2ffd

improved live display with colors

slotUI/SlotCli.py file | annotate | diff | comparison | revisions
--- a/slotUI/SlotCli.py	Sat Dec 17 15:12:19 2011 +0100
+++ b/slotUI/SlotCli.py	Sat Dec 17 15:38:17 2011 +0100
@@ -75,6 +75,8 @@
         self.sysclk = 0.00
         self.bestlap = 9999999.00
         self.test = test
+        self.laplimit = 999;
+        self.timelimit = 0;
 
     def reset_slots(self):
         idx = 0
@@ -162,6 +164,30 @@
         curses.noecho()
         self.scr.nodelay(1) # disable delay on readkey
 
+    def readInt(self, msg, default):
+        self.scr.nodelay(0) # enable delay on readkey
+        curses.echo()
+        self.scr.addstr(0,0, "%s [%i]:" % (
+            msg,
+            default,
+            curses.color_pair(1))
+            )
+        self.scr.refresh()
+        inp = self.scr.getstr(1,0, 4)
+        if inp != "":
+            try:
+                inp = int(inp)
+            except Exception:
+                inp = None
+        else:
+            inp = None
+        self.cleartop()
+        self.scr.refresh()
+        curses.noecho()
+        self.scr.nodelay(1) # disable delay on readkey
+        return inp
+
+
     def monitor_init(self):
         """
         Send initializing commands for live monitoring
@@ -221,6 +247,12 @@
             elif key == ord('x'):
                 if self.slot[5]["drive"] < 16: self.slot[5]["drive"] += 1
                 cli.box.speedminimum(5, self.slot[4]["drive"])
+            elif key == ord('t'):
+                tmp = self.readInt("Set new Race TIME limit", self.timelimit)
+                if tmp: self.timelimit = tmp
+            elif key == ord('l'):
+                tmp = self.readInt("Set new Race LAP limit", self.laplimit)
+                if tmp: self.laplimit = tmp
 
 
             # is there something in the rx buffer?

mercurial