-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ticker.py
41 lines (30 loc) · 858 Bytes
/
Ticker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import random
import urllib
import threading
import Adafruit_CharLCD as LCD
# URL for the commit messages
link = "http://whatthecommit.com/index.txt"
# Initialize the LCD using the pins
lcd = LCD.Adafruit_CharLCDPlate()
lcdLineLimit = 16
# Print out the Message To LCD
def display():
threading.Timer(10.0, display).start()
# Get information from URL
f = urllib.urlopen(link)
message = f.read()
if len(message) > lcdLineLimit:
message = message[:lcdLineLimit] + os.linesep + message[lcdLineLimit:]
# Setup the LCD for Display
red = random.randint(0, 1)
green = random.randint(0, 1)
blue = random.randint(0, 1)
if red == 0 and green == 0 and blue == 0:
red = 1
green = 1
blue = 1
lcd.set_color(red, green, blue)
lcd.clear()
lcd.message(message)
display()