From 5c9d45b7255b88502ebca813e3e546b06da68570 Mon Sep 17 00:00:00 2001 From: Florian Streibelt Date: Tue, 18 Oct 2011 18:59:14 +0200 Subject: [PATCH] first steps for pulling display functionality out of the client --- client-barcode/display.py | 25 +++++++++++++++++++++++++ client-barcode/freitagskasse.py | 7 +++++++ 2 files changed, 32 insertions(+) create mode 100644 client-barcode/display.py 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,))