# lcd.scroll(line, speed, "Scrolling Message"); # from urllib2 import urlopen # api_key = 2e714d06ee6612e6e746d6abd9f3b7a9 # weather = urlopen('http://api.openweathermap.org/data/2.5/weather?lat=') # import required functions from AndyPi_LCD import AndyPi_LCD from processing import Process import time import feedparser if __name__ == '__main__': # initial check for latest rss feed msg=feedparser.parse('http://feeds.bbci.co.uk/news/rss.xml?edition=uk').entries[0].title lcd=AndyPi_LCD() # set name of imported class lcd.lcd_init() # initialise LCD lcd.led(512) # turn backlight fully on while True: # setup a new thread process, in which to run the lcd.scroll_clock function, with the correct arguments p = Process(target=lcd.scroll_clock, args=(1, "c", 0.3, msg)) # start the process p.start() # wait for 30 seconds (or however long you wish to wait between checking updates) time.sleep(30.0) # while the python is scrolling the LCD message in the 'p' process # check for new rss feed, and put in variable "msg" msg=feedparser.parse('http://feeds.bbci.co.uk/news/rss.xml?edition=uk').entries[0].title # stop the scroller process p.terminate()
#!/usr/bin/python # # IP address script for AndyPi 16x2 HD44780 LCD # Developed by: AndyPi (http://andypi.co.uk/) # Date : 19/10/2013 # Version 1.1 # # lcd.lcd_init(); required to initialised LCD # lcd.led(value); turn on backlight 0:512 # lcd.static_text(line, "justification", "Static Message") # lcd.cls(); clears LCD & turns off backlight from subprocess import * from AndyPi_LCD import AndyPi_LCD def run_cmd(cmd): # runs whatever is in the cmd variable in the terminal p = Popen(cmd, shell=True, stdout=PIPE) output = p.communicate()[0] return output cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1" # get ip address of eth0 connection (use wlan0 for wireless) ipaddr = run_cmd(cmd)[:-1] # set output of command into ipaddr variable lcd=AndyPi_LCD() # set name of class lcd.lcd_init() # initialise lcd.led(512) # turn backlight fully on lcd.static_text(2,"c",ipaddr) # center static text IP address on line 2 lcd.static_text(1,"c", "My IP address:")