diff --git a/client-barcode/freitagskasse.py b/client-barcode/freitagskasse.py index 3c97246..a8ec903 100644 --- a/client-barcode/freitagskasse.py +++ b/client-barcode/freitagskasse.py @@ -41,55 +41,33 @@ scroll_line2 = None lock = allocate_lock() -def display_handle_scroll(line,text,offset): - if (text): - send_display("\x1f\x24\x01%c%s" % (chr(line),text[offset:(20+offset)])) - l = len(text) - missing_chars=20+offset-l - if (missing_chars>0): - send_display(text[:missing_chars]) - offset=((offset+1)%l) - else: - offset=0 #reset offset - return offset - +#Helper-Function, scrolls text in a specific line. def display_scroll_text(line,text): global scroll_line1,scroll_line2 global offset_line1,offset_line2 - offset_line1=0 - offset_line2=0 lock.acquire() if (line==1): #clear the line on invocation: send_display("\x1f\x24\x01%c\x18" % chr(line) ) scroll_line1 = text + offset_line1=0 if (line==2): #clear the line on invocation: send_display("\x1f\x24\x01%c\x18" % chr(line) ) scroll_line2 = text + offset_line2=0 lock.release() - -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): - scroll_line1=None - send_display("\x1f\x24\x01%c\x18%s" % (chr(1),'\xdb'*20) ) - if (len(title)<20): - pos=1+(20-len(title))/2 - else: - pos=1 - send_display("\x1f\x24%c%c%s" % (chr(pos),chr(1),title) ) - else: - display_scroll_text(1,title) - - 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_handle_scroll(line,text,offset): + if (text): + send_display("\x1f\x24\x01%c%s" % (chr(line),text[offset:(20+offset)])) + l = len(text) + missing_chars=20+offset-l + if (missing_chars>0): + send_display(text[:missing_chars]) + offset=((offset+1)%l) + else: + offset=0 #reset offset + return offset def display_thread(x): global scroll_line1,scroll_line2 @@ -126,6 +104,33 @@ def send_display(s): pass return + +#Front-End Funtion to display a Screen +# with heading +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): + scroll_line1=None + send_display("\x1f\x24\x01%c\x18%s" % (chr(1),'\xdb'*20) ) + if (len(title)<20): + pos=1+(20-len(title))/2 + else: + pos=1 + send_display("\x1f\x24%c%c%s" % (chr(pos),chr(1),title) ) + else: + display_scroll_text(1,title) + + 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) + + +#Front-End function to send data to the display. def print_display(s): global scroll_line1,scroll_line2 global offset_line1,offset_line2