Moar functions for the display

This commit is contained in:
Florian Streibelt 2011-10-15 04:15:50 +02:00
parent 665ba7cc5e
commit 5684b46001
1 changed files with 27 additions and 7 deletions

View File

@ -55,6 +55,9 @@ def display_handle_scroll(line,text,offset):
def display_scroll_text(line,text): def display_scroll_text(line,text):
global scroll_line1,scroll_line2 global scroll_line1,scroll_line2
global offset_line1,offset_line2
offset_line1=0
offset_line2=0
lock.acquire() lock.acquire()
if (line==1): #clear the line on invocation: if (line==1): #clear the line on invocation:
send_display("\x1f\x24\x01%c\x18" % chr(line) ) send_display("\x1f\x24\x01%c\x18" % chr(line) )
@ -65,7 +68,12 @@ def display_scroll_text(line,text):
lock.release() lock.release()
def display_screen(title,message): def display_screen(title,message):
global scroll_line1,scroll_line2
global offset_line1,offset_line2
offset_line1=0
offset_line2=0
if (len(title)<21): if (len(title)<21):
scroll_line1=None
send_display("\x1f\x24\x01%c\x18%s" % (chr(1),'\xdb'*20) ) send_display("\x1f\x24\x01%c\x18%s" % (chr(1),'\xdb'*20) )
if (len(title)<20): if (len(title)<20):
pos=1+(20-len(title))/2 pos=1+(20-len(title))/2
@ -74,12 +82,18 @@ def display_screen(title,message):
send_display("\x1f\x24%c%c%s" % (chr(pos),chr(1),title) ) send_display("\x1f\x24%c%c%s" % (chr(pos),chr(1),title) )
else: else:
display_scroll_text(1,title) display_scroll_text(1,title)
display_scroll_text(2,message)
if (len(message)<21):
scroll_line2=None
send_display("\x1f\x24%c%c\x18%s" % (chr(1),chr(2),message) )
else:
display_scroll_text(2,message)
def display_thread(x): def display_thread(x):
global scroll_line1,scroll_line2 global scroll_line1,scroll_line2
global offset_line1,offset_line2
offset_line1=0 offset_line1=0
offset_line2=0 offset_line2=0
while(True): while(True):
@ -113,10 +127,14 @@ def send_display(s):
return return
def print_display(s): def print_display(s):
global scroll_line1,scroll_line2
global offset_line1,offset_line2
lock.acquire() lock.acquire()
# scroll_line1=None offset_line1=0
# scroll_line2=None offset_line2=0
# send_display(s) scroll_line1=None
scroll_line2=None
send_display(s)
lock.release() lock.release()
def clear(): def clear():
@ -258,7 +276,7 @@ class Status:
print(COLOR_SOME + 'Committen nicht vergessen.' + COLOR_RESET) print(COLOR_SOME + 'Committen nicht vergessen.' + COLOR_RESET)
else: else:
print('Kontostand beträgt: %s%.2f Euro%s' % (COLOR_MUCH, self.balance, COLOR_RESET)) print('Kontostand beträgt: %s%.2f Euro%s' % (COLOR_MUCH, self.balance, COLOR_RESET))
print_display('Kontostand: %8.2f' % self.balance) display_screen("KONTOSTAND","%s: %.2f Euro" % (self.login_name,self.balance))
if self.balance < 0: if self.balance < 0:
print() print()
warn_balance() warn_balance()
@ -266,7 +284,7 @@ class Status:
print(COLOR_MUCH + 'Bitte einloggen.' + COLOR_RESET) print(COLOR_MUCH + 'Bitte einloggen.' + COLOR_RESET)
print() print()
print('Scanne dazu deine ID-Karte mit dem Barcode-Leser.') print('Scanne dazu deine ID-Karte mit dem Barcode-Leser.')
print_display("\x0cAnmeldung: Bitte ID-Karte scannen\x0b") display_screen("LOGIN","Bitte scanne Deinen login-Token! *** ")
print() print()
def logged_in(self): def logged_in(self):
@ -422,6 +440,7 @@ def print_prompt():
def handle(line, status): def handle(line, status):
if line == 'exit': if line == 'exit':
clear() clear()
print_display("\x1b\x40exit...")
sys.exit(0) sys.exit(0)
if status.logged_in(): if status.logged_in():
@ -447,7 +466,8 @@ def handle(line, status):
status.login(line) status.login(line)
except urllib2.HTTPError as e: except urllib2.HTTPError as e:
if e.code == 404: # URL not found == user unknown if e.code == 404: # URL not found == user unknown
print_display('\x0cFEHLER: Nutzer ist unbekannt: "%7s"' % line[:7]) display_screen("FEHLER","Nutzer ist unbekannt: '%s' *** " % line)
error_page('FEHLER: Benutzer "%s" nicht bekannt' % line, error_page('FEHLER: Benutzer "%s" nicht bekannt' % line,
hint_message='Ist in der WebApp unter "Einstellungen" ' \ hint_message='Ist in der WebApp unter "Einstellungen" ' \
'für Ihren Account Plugin "BarcodePlugin" ' \ 'für Ihren Account Plugin "BarcodePlugin" ' \