# HG changeset patch # User Malte Bayer # Date 1324132697 -3600 # Node ID c7ff8cde6b1e6ed079127eb6f435dabe5cc0cc0c # Parent ee4f9b8a36e9f8c97e5a20dd69a034e7088f4b21 improved live display with colors diff -r ee4f9b8a36e9 -r c7ff8cde6b1e slotUI/SlotCli.py --- 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?