#!/usr/bin/env python # -*- coding: utf-8 -*- import pcd8544.lcd as lcd import time, os, sys if not os.geteuid() == 0: sys.exit('Script must be run as root') ON, OFF = [1, 0] try: lcd.init() lcd.cls() lcd.backlight(ON) lcd.load_bitmap("raspi.bmp", False) time.sleep(10) except KeyboardInterrupt: pass finally: lcd.cls() lcd.backlight(OFF)
# initialize the LCD screen lcd.init() lcd.cls() lcd.backlight(ON) # display the photo of each employee with his first name # next to it for employee in employees: # get the jpg photo and convert it to a usable bitmap img = urllib.urlretrieve(employee.get('photoUrl'))[0] bmp = Image.open(img) bmp = bmp.resize((48, 84), Image.NEAREST).convert('1') bmp.save('/tmp/employee.bmp') # clear and load the bitmap photo lcd.cls() lcd.load_bitmap('/tmp/employee.bmp') # get the employee first and last name and strip any special character # as they're not supported by the LCD lib first_name = strip_accent(employee.get('firstName', '')) # display the first name, wait a bit and iterate lcd.text(center_and_strip(first_name)) sleep(0.25) except KeyboardInterrupt: pass finally: lcd.cls() lcd.backlight(OFF)
#!/usr/bin/env python # -*- coding: utf-8 -*- import pcd8544.lcd as lcd import time, os,sys if not os.geteuid() == 0: sys.exit('Script must be run as root') ON, OFF = [1, 0] try: lcd.init() lcd.cls() lcd.backlight(ON) lcd.load_bitmap("raspi.bmp", True) time.sleep(10) except KeyboardInterrupt: pass finally: lcd.cls() lcd.backlight(OFF)
#!/usr/bin/env python # -*- coding: utf-8 -*- import pcd8544.lcd as lcd import time, os, sys if not os.geteuid() == 0: sys.exit('Script must be run as root') ON, OFF = [1, 0] try: lcd.init() lcd.cls() lcd.backlight(ON) lcd.load_bitmap("raspi.bmp", True) time.sleep(10) except KeyboardInterrupt: pass finally: lcd.cls() lcd.backlight(OFF)