first steps for pulling display functionality out of the client
This commit is contained in:
parent
d3b0a8fa4c
commit
5c9d45b725
|
@ -0,0 +1,25 @@
|
||||||
|
import serial
|
||||||
|
|
||||||
|
class Display:
|
||||||
|
def __init__(self,portname="/dev/ttyUSB0"):
|
||||||
|
#code here
|
||||||
|
self.serialport=None
|
||||||
|
self.open_port(portname)
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
if (not self.serialport == None):
|
||||||
|
self.serialport.close()
|
||||||
|
self.serialport=None
|
||||||
|
|
||||||
|
def open_port(self,portname):
|
||||||
|
self.serialport = serial.Serial(portname,9600,timeout=2,rtscts=True, dsrdtr=True)
|
||||||
|
self.reset_display()
|
||||||
|
self.send("Hello world")
|
||||||
|
|
||||||
|
|
||||||
|
def reset_display(self):
|
||||||
|
print ("Initializing display on port %s\n" % self.serialport )
|
||||||
|
#code here
|
||||||
|
|
||||||
|
def send(self,text):
|
||||||
|
self.serialport.write(text)
|
|
@ -20,9 +20,11 @@ import time
|
||||||
import urllib2
|
import urllib2
|
||||||
import select
|
import select
|
||||||
|
|
||||||
|
from display import Display
|
||||||
from thread import start_new_thread, allocate_lock
|
from thread import start_new_thread, allocate_lock
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
myDisplay=None
|
||||||
|
|
||||||
COLOR_HINT = Fore.YELLOW + Style.BRIGHT
|
COLOR_HINT = Fore.YELLOW + Style.BRIGHT
|
||||||
COLOR_ERROR = Fore.RED
|
COLOR_ERROR = Fore.RED
|
||||||
|
@ -576,6 +578,11 @@ def main():
|
||||||
colorama.init()
|
colorama.init()
|
||||||
status = Status()
|
status = Status()
|
||||||
global scroll_line1,scroll_line2
|
global scroll_line1,scroll_line2
|
||||||
|
global myDisplay
|
||||||
|
|
||||||
|
myDisplay = Display("/dev/ttyUSB0")
|
||||||
|
myDisplay.reset_display()
|
||||||
|
|
||||||
print_display("\x1b\x40\x1f\x43\x00")
|
print_display("\x1b\x40\x1f\x43\x00")
|
||||||
start_new_thread(display_thread,(1,))
|
start_new_thread(display_thread,(1,))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue