Make the Fake Galil display window support the 8 controllers

This commit is contained in:
Douglas Clowes
2014-06-26 12:38:59 +10:00
parent 03aa895403
commit e2ab77fca7

View File

@@ -26,25 +26,32 @@ def display_iterator():
try: try:
rows, cols = screen.stdscr.getmaxyx() rows, cols = screen.stdscr.getmaxyx()
col = 0 col = 0
column_width = 78 / len(devices.keys())
for idx in sorted(devices.keys()): for idx in sorted(devices.keys()):
line = 0; line = 0;
col += 1 col += 1
screen.stdscr.addstr(line, 13 * (col - 1) + 2, "%8s=%d" % (idx, factories[idx].numProtocols)) header = "%s=%d" % (idx, factories[idx].numProtocols)
screen.stdscr.addstr(line, column_width * (col - 1) + 2, header.rjust(column_width-1))
line = 1 line = 1
for mtr in sorted(devices[idx].motors.keys()): for mtr in sorted(devices[idx].motors.keys()):
screen.stdscr.addstr(line, 0, "%1s:" % mtr) screen.stdscr.addstr(line, 0, "%1s:" % mtr)
try: try:
name = devices[idx].motors[mtr].name name = devices[idx].motors[mtr].name
if len(name) > 12: if len(name) > column_width-1:
name = name[:12] name = name[:column_width-1]
screen.stdscr.addstr(line, 13 * (col - 1) + 2, "%12s" % name.rjust(12), curses.A_DIM)
except:
screen.stdscr.addstr(line, 13 * (col - 1) + 2, "%12s" % "")
value = "%12.3f" % devices[idx].motors[mtr].getPosition()
if (devices[idx].motors[mtr].motorState == "OFF"): if (devices[idx].motors[mtr].motorState == "OFF"):
screen.stdscr.addstr(line + 1, 13 * (col - 1) + 2, "%s " % value, curses.A_BOLD) screen.stdscr.addstr(line, column_width * (col - 1) + 2, "%s" % name.rjust(column_width-1), curses.A_DIM)
else: else:
screen.stdscr.addstr(line + 1, 13 * (col - 1) + 2, "%s*" % value, curses.A_STANDOUT) screen.stdscr.addstr(line, column_width * (col - 1) + 2, "%s" % name.rjust(column_width-1), curses.A_STANDOUT)
except:
screen.stdscr.addstr(line, column_width * (col - 1) + 2, "%s" % "".rjust(column_width-1))
value = "%.3f" % devices[idx].motors[mtr].getPosition()
if len(value) > column_width-1:
value = value[:column_width-1]
if (devices[idx].motors[mtr].motorState == "OFF"):
screen.stdscr.addstr(line + 1, column_width * (col - 1) + 2, "%s" % value.rjust(column_width-1), curses.A_BOLD)
else:
screen.stdscr.addstr(line + 1, column_width * (col - 1) + 2, "%s" % value.rjust(column_width-1), curses.A_STANDOUT)
line += 2 line += 2
except: except:
raise raise