Пример #1
0
# 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()