the first time information is somehow displayed again

This commit is contained in:
Florian Streibelt 2011-10-18 23:59:18 +02:00
parent a9d82b9b85
commit 65255fb53a
1 changed files with 3 additions and 78 deletions

View File

@ -56,45 +56,6 @@ SCREENSAVER_OFF = 2* 10*60
lock = allocate_lock() lock = allocate_lock()
#Helper-Function, scrolls text in a specific line.
def display_scroll_text(line,text):
global scroll_line1,scroll_line2
global offset_line1,offset_line2
global lock
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_handle_scroll(line,text,offset):
if (text):
l = len(text)
if (l<21):
if (offset == 0):
send_display("\x1f\x24\x01%c%s" % (chr(line),text[offset:(20+offset)]))
offset=1
else:
send_display("\x1f\x24\x01%c%s" % (chr(line),text[offset:(20+offset)]))
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_cmd_dim(x):
return
def send_display(s): def send_display(s):
global myDisplay global myDisplay
# myDisplay.write(s,False) # myDisplay.write(s,False)
@ -102,46 +63,12 @@ def send_display(s):
#Front-End Funtion to display a Screen #Front-End Funtion to display a Screen
# with heading # with heading
def display_screen(title,message): def display_screen(title,message):
global scroll_line1,scroll_line2 myDisplay.display_screen(title,message)
global offset_line1,offset_line2
global screensaver
offset_line1=0
offset_line2=0
screensaver=0
display_cmd_dim(5)
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)
display_scroll_text(2,message)
#Front-End function to send data to the display. #Front-End function to send data to the display.
def print_display(s): def print_display(s):
global scroll_line1,scroll_line2 myDisplay.write(s,False)
global offset_line1,offset_line2
global screensaver
global myDisplay
global lock
lock.acquire()
screensaver=0
offset_line1=0
offset_line2=0
scroll_line1=None
scroll_line2=None
display_cmd_dim(5)
# myDisplay.write(s,False)
lock.release()
def clear(): def clear():
os.system('clear') os.system('clear')
@ -517,10 +444,8 @@ def main():
myDisplay = Display("/dev/ttyUSB0") myDisplay = Display("/dev/ttyUSB0")
myDisplay.start() myDisplay.start()
myDisplay.cmd_reset() myDisplay.cmd_reset()
myDisplay.display_screen("Nachricht","Hallo Welt! Dies ist eine sehr lange NAchricht!") time.sleep(2)
time.sleep(100)
myDisplay.cmd_cursor_show(False) myDisplay.cmd_cursor_show(False)
start_new_thread(display_thread,(1,))
display_screen("HINWEIS","Herzlich willkommen bei der Freitagsrunde! *** ") display_screen("HINWEIS","Herzlich willkommen bei der Freitagsrunde! *** ")
while True: while True: