Created
July 23, 2015 13:02
-
-
Save uktechreviews/8c543726e1fd89895dd1 to your computer and use it in GitHub Desktop.
Display-O-Tron 3000 Scoreboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import os | |
import dot3k.lcd as lcd | |
import dot3k.backlight as backlight | |
import sys | |
import colorsys | |
lcd.clear() | |
os.system('clear') | |
backlight.rgb(255,0,255) | |
backlight.set_bar(0,255) | |
lcd.set_cursor_position(0,1) | |
lcd.write("Competition Name") | |
title = raw_input('What is the competition name (16 letters at most): ') | |
os.system('clear') | |
lcd.clear() | |
backlight.set_bar(0,0) | |
backlight.set_bar(1,255) | |
lcd.set_cursor_position(1,1) | |
lcd.write("Points to win") | |
win = raw_input('How many points are needed to win: ') | |
os.system('clear') | |
lcd.clear() | |
backlight.set_bar(1,0) | |
backlight.set_bar(2,255) | |
lcd.set_cursor_position(3,0) | |
lcd.write("Player 1's") | |
lcd.set_cursor_position(4,1) | |
lcd.write('Initials') | |
p1 = raw_input("What are player 1's initials (4 letters at most): ") | |
os.system('clear') | |
lcd.clear() | |
backlight.set_bar(2,0) | |
backlight.set_bar(3,255) | |
lcd.set_cursor_position(3,0) | |
lcd.write("Player 2's") | |
lcd.set_cursor_position(4,1) | |
lcd.write('Initials') | |
p2 = raw_input("What are player 2's initials (4 letters at most): ") | |
os.system('clear') | |
backlight.set_bar(3,0) | |
p1s = 0 | |
p2s = 0 | |
while True: | |
os.system('clear') | |
lcd.clear() | |
backlight.rgb(0,255,0) | |
lcd.set_cursor_position(0,0) | |
lcd.write(title) | |
lcd.set_cursor_position(0,1) | |
lcd.write("----------------") | |
p1ss = str(p1s) | |
p2ss = str(p2s) | |
lcd.set_cursor_position(0,2) | |
lcd.write(p1 + "-" + p1ss + "-" + p2ss + "-" + p2) | |
os.system('clear') | |
backlight.set_bar(0,255) | |
backlight.set_bar(1,255) | |
backlight.set_bar(2,255) | |
backlight.set_bar(3,255) | |
backlight.set_bar(4,255) | |
backlight.set_bar(5,255) | |
backlight.set_bar(6,255) | |
backlight.set_bar(7,255) | |
backlight.set_bar(8,255) | |
if p1ss == win: | |
lcd.clear() | |
backlight.off() | |
hue = 0 | |
lcd.set_cursor_position(0,1) | |
lcd.write(p1 + ' WINS!!!') | |
print(p1 + ' WINS!!!') | |
while True: | |
r,g,b = colorsys.hsv_to_rgb(hue/360.0,1.0,1.0) | |
r,g,b = int(r*255.0), int(g*255.0), int(b*255.0) | |
backlight.rgb(r,b,g) | |
hue += 1 | |
hue %= 360 | |
if p1ss > win: | |
lcd.clear() | |
backlight.off() | |
hue = 0 | |
lcd.set_cursor_position(0,1) | |
lcd.write(p1 + ' WINS!!!') | |
print(p1 + ' WINS!!!') | |
while True: | |
r,g,b = colorsys.hsv_to_rgb(hue/360.0,1.0,1.0) | |
r,g,b = int(r*255.0), int(g*255.0), int(b*255.0) | |
backlight.rgb(r,b,g) | |
hue += 1 | |
hue %= 360 | |
if p2ss == win: | |
lcd.clear() | |
backlight.off() | |
hue = 0 | |
lcd.set_cursor_position(0,1) | |
lcd.write(p2 + ' WINS!!!') | |
print(p2 + ' WINS!!!') | |
while True: | |
r,g,b = colorsys.hsv_to_rgb(hue/360.0,1.0,1.0) | |
r,g,b = int(r*255.0), int(g*255.0), int(b*255.0) | |
backlight.rgb(r,b,g) | |
hue += 1 | |
hue %= 360 | |
if p2ss > win: | |
lcd.clear() | |
backlight.off() | |
hue = 0 | |
lcd.set_cursor_position(0,1) | |
lcd.write(p2 + ' WINS!!!') | |
print(p2 + ' WINS!!!') | |
while True: | |
r,g,b = colorsys.hsv_to_rgb(hue/360.0,1.0,1.0) | |
r,g,b = int(r*255.0), int(g*255.0), int(b*255.0) | |
backlight.rgb(r,b,g) | |
hue += 1 | |
hue %= 360 | |
print("1 = Name of competition") | |
print("2 = Points to win") | |
print("3 = Player 1's name") | |
print("4 = Player 2's name") | |
print("5 = Player 1's score") | |
print("6 = Player 2's score") | |
print("7 = Reset") | |
print("8 = Finish") | |
ans = input('Please type a number: ') | |
backlight.set_bar(0,0) | |
backlight.set_bar(1,0) | |
backlight.set_bar(2,0) | |
backlight.set_bar(3,0) | |
backlight.set_bar(4,0) | |
backlight.set_bar(5,0) | |
backlight.set_bar(6,0) | |
backlight.set_bar(7,0) | |
backlight.set_bar(8,0) | |
if ans == 1: | |
os.system('clear') | |
backlight.rgb(255,0,255) | |
backlight.set_bar(0,255) | |
lcd.clear() | |
lcd.set_cursor_position(0,1) | |
lcd.write('Competition Name') | |
title = raw_input('What is the competition name (16 letters at most): ') | |
elif ans == 3: | |
os.system('clear') | |
backlight.rgb(255,0,255) | |
backlight.set_bar(2,255) | |
lcd.clear() | |
lcd.set_cursor_position(3,0) | |
lcd.write("Player 1's") | |
lcd.set_cursor_position(4,1) | |
lcd.write('Initials') | |
p1 = raw_input("What are player 1's initials (4 letters at most): ") | |
elif ans == 4: | |
os.system('clear') | |
backlight.rgb(255,0,255) | |
backlight.set_bar(3,255) | |
lcd.clear() | |
lcd.set_cursor_position(3,0) | |
lcd.write("Player 2's") | |
lcd.set_cursor_position(4,1) | |
lcd.write('Initials') | |
p2 = raw_input("What are player 2's initials (4 letters at most): ") | |
elif ans == 5: | |
os.system('clear') | |
backlight.rgb(255,0,255) | |
backlight.set_bar(4,255) | |
lcd.clear() | |
lcd.set_cursor_position(0,0) | |
lcd.write('Current Score is') | |
lcd.set_cursor_position(7,1) | |
lcd.write(p1ss) | |
lcd.set_cursor_position(0,2) | |
lcd.write('Points Awarded:') | |
p1s += input("How many points to be added to player 1's score: ") | |
elif ans == 6: | |
os.system('clear') | |
backlight.rgb(255,0,255) | |
backlight.set_bar(5,255) | |
lcd.clear() | |
lcd.set_cursor_position(0,0) | |
lcd.write('Current Score is') | |
lcd.set_cursor_position(7,1) | |
lcd.write(p2ss) | |
lcd.set_cursor_position(1,2) | |
lcd.write('Points Awarded') | |
p2s += input("How many points to be added to player 2's score: ") | |
elif ans == 8: | |
lcd.clear() | |
backlight.off() | |
os.system('clear') | |
backlight.set_bar(0,0) | |
backlight.set_bar(1,0) | |
backlight.set_bar(2,0) | |
backlight.set_bar(3,0) | |
backlight.set_bar(4,0) | |
backlight.set_bar(5,0) | |
backlight.set_bar(6,0) | |
backlight.set_bar(7,0) | |
backlight.set_bar(8,0) | |
sys.exit() | |
elif ans == 7: | |
title = "Blank Title" | |
p1 = "Demo" | |
p2 = "Demo2" | |
p1s = 0 | |
p2s = 0 | |
elif ans == 2: | |
os.system('clear') | |
backlight.rgb(255,0,255) | |
backlight.set_bar(1,255) | |
lcd.clear() | |
lcd.set_cursor_position(1,1) | |
lcd.write("Points to win") | |
win = raw_input('How many points are needed to win: ') | |
else: | |
lcd.clear() | |
lcd.set_cursor_position(1,1) | |
lcd.write('INVALID NUMBER') | |
print('That is not a valid number!') | |
time.sleep(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment