reordering of functions
This commit is contained in:
parent
5684b46001
commit
f5f55eff84
|
@ -41,6 +41,22 @@ scroll_line2 = None
|
||||||
|
|
||||||
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
|
||||||
|
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):
|
def display_handle_scroll(line,text,offset):
|
||||||
if (text):
|
if (text):
|
||||||
send_display("\x1f\x24\x01%c%s" % (chr(line),text[offset:(20+offset)]))
|
send_display("\x1f\x24\x01%c%s" % (chr(line),text[offset:(20+offset)]))
|
||||||
|
@ -53,44 +69,6 @@ def display_handle_scroll(line,text,offset):
|
||||||
offset=0 #reset offset
|
offset=0 #reset offset
|
||||||
return offset
|
return offset
|
||||||
|
|
||||||
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
|
|
||||||
if (line==2): #clear the line on invocation:
|
|
||||||
send_display("\x1f\x24\x01%c\x18" % chr(line) )
|
|
||||||
scroll_line2 = text
|
|
||||||
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_thread(x):
|
def display_thread(x):
|
||||||
global scroll_line1,scroll_line2
|
global scroll_line1,scroll_line2
|
||||||
global offset_line1,offset_line2
|
global offset_line1,offset_line2
|
||||||
|
@ -126,6 +104,33 @@ def send_display(s):
|
||||||
pass
|
pass
|
||||||
return
|
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):
|
def print_display(s):
|
||||||
global scroll_line1,scroll_line2
|
global scroll_line1,scroll_line2
|
||||||
global offset_line1,offset_line2
|
global offset_line1,offset_line2
|
||||||
|
|
Loading…
Reference in New Issue