boardrevision = 2 stderr("Are you using an old revision 1 board y/n: ") answer = raw_input("") if answer == 'y': boardrevision = 1 print "Use Ctl-C to exit" lcd.init(boardrevision) width = lcd.getWidth() if width is 0: print "Set the lcd_width parameter in /etc/radiod.conf" sys.exit(1) lcd.setWidth(width) lcd.line1("Bob Rathbone") while True: try: lcd.line3("Line 3") lcd.line4("Line 4") lcd.scroll2("Line 2: abcdefghijklmnopqrstuvwxyz 0123456789",interrupt) except KeyboardInterrupt: print "\nExit" GPIO.setwarnings(False) GPIO.cleanup() sys.exit(0) # End of test program
# Register atexit.register(exit_fn) def interrupt(): return False boardrevision = 2 stderr("Are you using an old revision 1 board y/n: ") answer = raw_input("") if answer == 'y': boardrevision = 1 print "Use Ctl-C to exit" lcd.init(boardrevision) lcd.setWidth(16) lcd.line1("Bob Rathbone") while True: try: lcd.scroll2("Line 2: abcdefghijklmnopqrstuvwxyz 0123456789", interrupt) except KeyboardInterrupt: print "\nExit" GPIO.setwarnings(False) GPIO.cleanup() sys.exit(0)
#!/usr/bin/env python # # Imports from lcd_class import Lcd from time import sleep from time import strftime lcd = Lcd() # LCD interrupt scroll routine def interrupt(): return False lcd.init() lcd.setWidth(16) # Display line 1 and 2 lcd.line1("Line 1: Test LCD") lcd.line2("Line 2: defghijk") sleep(3) while True: todaysdate = strftime("%H:%M %d/%m/%Y") lcd.line1(todaysdate) lcd.scroll2("Line 4: abcdefghijklmnopqrstuvwxyz 0123456789",interrupt) # End
boardrevision = 2 stderr("Are you using an old revision 1 board y/n: ") answer = raw_input("") if answer == 'y': boardrevision = 1 print "Use Ctl-C to exit" lcd.init(boardrevision) width = lcd.getWidth() if width is 0: print "Set the lcd_width parameter in /etc/radiod.conf" sys.exit(1) lcd.setWidth(width) if len(sys.argv) > 1: text = translate.escape(sys.argv[1]) else: text = "Bob Rathbone" lcd.line3("Line 3") lcd.line4("Line 4") while True: try: if len(text) > width: lcd.scroll1(text,interrupt) else: lcd.line1(text)