display escape codes replaced by api calls

This commit is contained in:
Florian Streibelt 2011-10-21 20:52:34 +02:00
parent fd46332e65
commit 0a26f74872
2 changed files with 23 additions and 11 deletions

View File

@ -29,7 +29,7 @@ class Display(threading.Thread):
def open_port(self): def open_port(self):
try: try:
self.serialport = serial.Serial(self.portname,9600,timeout=2,rtscts=True, dsrdtr=True) self.serialport = serial.Serial(self.portname,9600,timeout=2,rtscts=False, dsrdtr=False)
#print ("Initializing display on port:\n %s\n" % self.serialport ) #print ("Initializing display on port:\n %s\n" % self.serialport )
self.mutex_get() self.mutex_get()
self.cmd_reset() self.cmd_reset()
@ -172,10 +172,12 @@ class Display(threading.Thread):
def cmd_curmode(self,val=2): def cmd_curmode(self,val=2):
self.cmd("\x1f%c" % chr(val)) self.cmd("\x1f%c" % chr(val))
def cmd_home(self):
self.cmd("\x0b")
def cmd_clear(self): def cmd_clear(self):
self.cmd("\x0c") self.cmd("\x0c")
def cmd_time(self): def cmd_time(self):
# activate timer display in lower right corner. # activate timer display in lower right corner.
# actual time has to be set via display_set_timer. # actual time has to be set via display_set_timer.
@ -274,6 +276,7 @@ class Screensaver (threading.Thread):
self.display.mutex_get() self.display.mutex_get()
self.display.cmd_time_set() self.display.cmd_time_set()
self.display.scroll_line1 = self.display.getIdlemessage() self.display.scroll_line1 = self.display.getIdlemessage()
self.display.scroll_line2 = None
self.display.mutex_release() self.display.mutex_release()
return return

View File

@ -178,7 +178,8 @@ class Status:
if self.logged_in(): if self.logged_in():
print('Eingeloggt als: %s%s%s' % (COLOR_SOME, self.login_name, COLOR_RESET)) print('Eingeloggt als: %s%s%s' % (COLOR_SOME, self.login_name, COLOR_RESET))
print() print()
myDisplay.write('\x0cHallo %-14s' % (self.login_name[:13]+"!") ) myDisplay.cmd_clear()
myDisplay.write('Hallo %-14s' % (self.login_name[:13]+"!") )
if self.transfers: if self.transfers:
initial_command, initial_balance = self.transfers[0] initial_command, initial_balance = self.transfers[0]
@ -210,11 +211,15 @@ class Status:
mylabel="Pfand "+command.commodity_label()[:9] mylabel="Pfand "+command.commodity_label()[:9]
if (mycmd==3): if (mycmd==3):
mylabel=("%-13s" % (command.commodity_label()[:13]))+"+P" mylabel=("%-13s" % (command.commodity_label()[:13]))+"+P"
myDisplay.write('\x0b%-15s %4.2f' % (asciify(mylabel)[:15],abs(command.difference()))); myDisplay.cmd_home()
myDisplay.write('\x0b\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance)); myDisplay.write('%-15s %4.2f' % (asciify(mylabel)[:15],abs(command.difference())));
myDisplay.cmd_home()
myDisplay.write('\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
else: else:
myDisplay.write('\x0b%-15s %4.2f' % (command.label()[:15],abs(command.difference()))); myDisplay.cmd_home()
myDisplay.write('\x0b\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance)); myDisplay.write('%-15s %4.2f' % (command.label()[:15],abs(command.difference())));
myDisplay.cmd_home()
myDisplay.write('\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
if len(self.transfers) > 1: if len(self.transfers) > 1:
show_total(self.balance - initial_balance, plus='+') show_total(self.balance - initial_balance, plus='+')
@ -223,7 +228,8 @@ class Status:
if self.balance < 0: if self.balance < 0:
warn_balance() warn_balance()
myDisplay.write('\x0b\nKonto: %5.2f!' % (self.balance) ) myDisplay.cmd_home()
myDisplay.write('\nKonto: %5.2f!' % (self.balance) )
print() print()
print(COLOR_MUCH + 'Committen nicht vergessen.' + COLOR_RESET) print(COLOR_MUCH + 'Committen nicht vergessen.' + COLOR_RESET)
@ -364,11 +370,13 @@ class Status:
error_page(_PRODUCT_FIRST) error_page(_PRODUCT_FIRST)
return return
if prev.includes_deposit(): if prev.includes_deposit():
myDisplay.write('\x0cFEHLER: schon Pfand %20s' % prev.item_name()[:20]) myDisplay.cmd_clear()
myDisplay.write('FEHLER: schon Pfand %20s' % prev.item_name()[:20])
error_page('FEHLER: Pfand für Produkt "%s" bereits aktiviert' % prev.item_name()) error_page('FEHLER: Pfand für Produkt "%s" bereits aktiviert' % prev.item_name())
return return
if prev.deposit_value() <= 0: if prev.deposit_value() <= 0:
myDisplay.write('\x0cFEHLER: Pfandfrei! %20s' % prev.item_name()[:20]) myDisplay.cmd_clear()
myDisplay.write('FEHLER: Pfandfrei! %20s' % prev.item_name()[:20])
error_page('FEHLER: Produkt "%s" hat kein Pfand' % prev.item_name()) error_page('FEHLER: Produkt "%s" hat kein Pfand' % prev.item_name())
return return
before = prev.difference() before = prev.difference()
@ -492,7 +500,8 @@ def main():
print_prompt() print_prompt()
line = read_line(sys.stdin, timeout=3*60.0, timeout_func=status.logout) line = read_line(sys.stdin, timeout=3*60.0, timeout_func=status.logout)
if line: if line:
myDisplay.write('\x0cRFID/Barcode:\n%20s' % line[:20]) myDisplay.cmd_clear()
myDisplay.write('RFID/Barcode:\n%20s' % line[:20])
handle(line, status) handle(line, status)