NoPaste

lcd.py

von smutbert

SNIPPET_TEXT:
  1. import socket
  2.  
  3. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  4.  
  5. def lcd_open(host, port):
  6.         s.connect((host, port))
  7.         lcdproc_version = lcd_cmd('hello') # is wichtig!
  8.         lcd_cmd('client_set name orpheus')
  9.  
  10.  
  11. def lcd_close():
  12.         lcd_cmd('screen_set ' + 'commando' + ' backlight off')
  13.         s.close()
  14.  
  15. def lcd_cmd(lcdproc_cmd):
  16.         s.send(lcdproc_cmd + '\n')
  17.  
  18. def lcd_text(msg_text):
  19.         lcd_cmd('screen_add ' + 'commando')
  20.         lcd_cmd('screen_set ' + 'commando' + ' -priority alert -heartbeat off')
  21.         lcd_cmd('screen_set ' + 'commando' + ' -timeout 16')
  22.         lcd_cmd('widget_add ' + 'commando' + ' anzeige' + ' string')
  23.         lcd_cmd('widget_set ' + 'commando' + ' anzeige' + ' 1 1 ' + '"' + msg_text + '"')
  24.  
  25. def lcd_scroll(speed, msg_text):
  26.         lcd_cmd('screen_add ' + 'commando')
  27.         lcd_cmd('screen_set ' + 'commando' + ' -priority alert -heartbeat off')
  28.         lcd_cmd('screen_set ' + 'commando' + ' -timeout 32')
  29.         lcd_cmd('widget_add ' + 'commando' + ' anzeige' + ' scroller')
  30.         lcd_cmd('widget_set ' + 'commando' + ' anzeige' + ' 1 1 18 1 ' + 'h ' +str(speed) + ' "' + msg_text + '"')
  31.         lcd_cmd('widget_add ' + 'commando' + ' anzeige2' + ' string')
  32.         lcd_cmd('widget_set ' + 'commando' + ' anzeige2' + ' 20 1 ' + '>')
  33.  
  34.  
  35. def lcd_hbar(length):
  36.         lcd_cmd('screen_add ' + 'commando')
  37.         lcd_cmd('screen_set ' + 'commando' + ' -priority alert -heartbeat off')
  38.         lcd_cmd('screen_set ' + 'commando' + ' -timeout 16')
  39.         lcd_cmd('widget_add ' + 'commando' + ' anzeige' + ' hbar')
  40.         lcd_cmd('widget_set ' + 'commando' + ' anzeige' + ' 1 1 ' + str(length))
  41.        
  42.  
  43. def lcd_icon(icon_name):
  44.         lcd_cmd('screen_add ' + 'commando')
  45.         lcd_cmd('screen_set ' + 'commando' + ' -priority alert -heartbeat off')
  46.         lcd_cmd('screen_set ' + 'commando' + ' -timeout 16')
  47.         lcd_cmd('widget_add ' + 'commando' + ' anzeige' + ' icon')
  48.         lcd_cmd('widget_set ' + 'commando' + ' anzeige' + ' 1 1 ' + '"' + icon_name + '"')

Quellcode

Hier kannst du den Code kopieren und ihn in deinen bevorzugten Editor einfügen. PASTEBIN_DOWNLOAD_SNIPPET_EXPLAIN