diff --git a/client-barcode/display.py b/client-barcode/display.py new file mode 100644 index 0000000..6e2702e --- /dev/null +++ b/client-barcode/display.py @@ -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) diff --git a/client-barcode/freitagskasse.py b/client-barcode/freitagskasse.py index eff1bb5..681cba0 100644 --- a/client-barcode/freitagskasse.py +++ b/client-barcode/freitagskasse.py @@ -20,9 +20,11 @@ import time import urllib2 import select +from display import Display from thread import start_new_thread, allocate_lock import time +myDisplay=None COLOR_HINT = Fore.YELLOW + Style.BRIGHT COLOR_ERROR = Fore.RED @@ -576,6 +578,11 @@ def main(): colorama.init() status = Status() global scroll_line1,scroll_line2 + global myDisplay + + myDisplay = Display("/dev/ttyUSB0") + myDisplay.reset_display() + print_display("\x1b\x40\x1f\x43\x00") start_new_thread(display_thread,(1,))