Browse Source

display escape codes replaced by api calls

Florian Streibelt 9 years ago
parent
commit
0a26f74872
2 changed files with 23 additions and 11 deletions
  1. 5
    2
      client-barcode/display.py
  2. 18
    9
      client-barcode/freitagskasse.py

+ 5
- 2
client-barcode/display.py View File

@@ -29,7 +29,7 @@ class Display(threading.Thread):
29 29
 
30 30
 	def open_port(self):
31 31
 		try:
32
-			self.serialport = serial.Serial(self.portname,9600,timeout=2,rtscts=True, dsrdtr=True)
32
+			self.serialport = serial.Serial(self.portname,9600,timeout=2,rtscts=False, dsrdtr=False)
33 33
 			#print ("Initializing display on port:\n  %s\n" % self.serialport )
34 34
 			self.mutex_get()
35 35
 			self.cmd_reset()
@@ -172,9 +172,11 @@ class Display(threading.Thread):
172 172
 	def cmd_curmode(self,val=2):
173 173
 		self.cmd("\x1f%c" % chr(val))
174 174
 
175
+	def cmd_home(self):
176
+		self.cmd("\x0b")
177
+
175 178
 	def cmd_clear(self):
176 179
 		self.cmd("\x0c")
177
-
178 180
 	
179 181
 	def cmd_time(self):
180 182
 		# activate timer display in lower right corner.
@@ -274,6 +276,7 @@ class Screensaver (threading.Thread):
274 276
 			self.display.mutex_get()
275 277
 			self.display.cmd_time_set()
276 278
 			self.display.scroll_line1 = self.display.getIdlemessage()
279
+			self.display.scroll_line2 = None
277 280
 			self.display.mutex_release()
278 281
 			return
279 282
 

+ 18
- 9
client-barcode/freitagskasse.py View File

@@ -178,7 +178,8 @@ class Status:
178 178
 		if self.logged_in():
179 179
 			print('Eingeloggt als:  %s%s%s' % (COLOR_SOME, self.login_name, COLOR_RESET))
180 180
 			print()
181
-			myDisplay.write('\x0cHallo %-14s' % (self.login_name[:13]+"!") )
181
+			myDisplay.cmd_clear()
182
+			myDisplay.write('Hallo %-14s' % (self.login_name[:13]+"!") )
182 183
 			if self.transfers:
183 184
 				initial_command, initial_balance = self.transfers[0]
184 185
 
@@ -210,11 +211,15 @@ class Status:
210 211
 						mylabel="Pfand "+command.commodity_label()[:9]
211 212
 					if (mycmd==3):	
212 213
 						mylabel=("%-13s" % (command.commodity_label()[:13]))+"+P"
213
-					myDisplay.write('\x0b%-15s %4.2f' % (asciify(mylabel)[:15],abs(command.difference())));
214
-					myDisplay.write('\x0b\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
214
+					myDisplay.cmd_home()
215
+					myDisplay.write('%-15s %4.2f' % (asciify(mylabel)[:15],abs(command.difference())));
216
+					myDisplay.cmd_home()
217
+					myDisplay.write('\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
215 218
 				else:
216
-					myDisplay.write('\x0b%-15s %4.2f' % (command.label()[:15],abs(command.difference())));
217
-					myDisplay.write('\x0b\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
219
+					myDisplay.cmd_home()
220
+					myDisplay.write('%-15s %4.2f' % (command.label()[:15],abs(command.difference())));
221
+					myDisplay.cmd_home()
222
+					myDisplay.write('\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
218 223
 
219 224
 				if len(self.transfers) > 1:
220 225
 					show_total(self.balance - initial_balance, plus='+')
@@ -223,7 +228,8 @@ class Status:
223 228
 
224 229
 				if self.balance < 0:
225 230
 					warn_balance()
226
-					myDisplay.write('\x0b\nKonto: %5.2f!' % (self.balance) )
231
+					myDisplay.cmd_home()
232
+					myDisplay.write('\nKonto: %5.2f!' % (self.balance) )
227 233
 					print()
228 234
 
229 235
 				print(COLOR_MUCH + 'Committen nicht vergessen.' + COLOR_RESET)
@@ -364,11 +370,13 @@ class Status:
364 370
 				error_page(_PRODUCT_FIRST)
365 371
 				return
366 372
 			if prev.includes_deposit():
367
-				myDisplay.write('\x0cFEHLER: schon Pfand %20s' % prev.item_name()[:20])
373
+				myDisplay.cmd_clear()
374
+				myDisplay.write('FEHLER: schon Pfand %20s' % prev.item_name()[:20])
368 375
 				error_page('FEHLER: Pfand für Produkt "%s" bereits aktiviert' % prev.item_name())
369 376
 				return
370 377
 			if prev.deposit_value() <= 0:
371
-				myDisplay.write('\x0cFEHLER: Pfandfrei!  %20s' % prev.item_name()[:20])
378
+				myDisplay.cmd_clear()
379
+				myDisplay.write('FEHLER: Pfandfrei!  %20s' % prev.item_name()[:20])
372 380
 				error_page('FEHLER: Produkt "%s" hat kein Pfand' % prev.item_name())
373 381
 				return
374 382
 			before = prev.difference()
@@ -492,7 +500,8 @@ def main():
492 500
 		print_prompt()
493 501
 		line = read_line(sys.stdin, timeout=3*60.0, timeout_func=status.logout)
494 502
 		if line:
495
-			myDisplay.write('\x0cRFID/Barcode:\n%20s' % line[:20])
503
+			myDisplay.cmd_clear()
504
+			myDisplay.write('RFID/Barcode:\n%20s' % line[:20])
496 505
 			handle(line, status)
497 506
 
498 507
 

Loading…
Cancel
Save