Skip to content

Commit a069740

Browse files
committed
Soccer implemention + control
1 parent d0f8044 commit a069740

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
MLB_FAVS = ['TEX', 'PIT']
1212
NBA_FAVS = ['UTA', 'CHI', 'POR']
1313
NHL_FAVS = ['MTL', 'EDM', 'CBJ']
14-
LALIGA_FAVS = ['BAR','HUE']
14+
LALIGA_FAVS = ['ATB']
1515

soccer/__init__.py renamed to laliga/__init__.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
55
from PIL import Image, ImageOps
66

7+
from gpiozero import Button
8+
79
from .game import Scores
810
from config import COLS, ROWS, INTERVAL, BRIGHTNESS
911

@@ -68,23 +70,23 @@ def draw_board():
6870
# Print score final or live
6971
score_len = len(games[it]['score'])*4
7072

71-
if game['stage'] == 'Scheduled':
73+
if games[it]['stage'] == 'Scheduled':
7274
# If planned game, print @ and time
7375
period_len = len(games[it]['period'])*4
7476
graphics.DrawText(canvas, font,
7577
int((COLS - 4) / 2),
7678
height_first_row, textColor, "@")
7779
graphics.DrawText(canvas, font,
7880
int((COLS - period_len) / 2),
79-
height_second_row, textColor, game['period'])
81+
height_second_row, textColor, games[it]['period'])
8082
graphics.DrawText(canvas, font,
81-
int((COLS - 16) / 2),
83+
int((COLS - 12) / 2),
8284
height_third_row, textColor, 'GMT')
83-
elif game['stage'] == 'Full Time':
85+
elif games[it]['stage'] == 'Full Time':
8486
# Else print 'fin' to indicate final score
8587
graphics.DrawText(canvas, font,
8688
int((COLS - 12) / 2),
87-
height_first_row, textColor, "fin")
89+
height_first_row, textColor, "FIN")
8890
graphics.DrawText(canvas, font,
8991
int((COLS - score_len) / 2),
9092
height_second_row, textColor, games[it]['score'])
@@ -137,6 +139,23 @@ def draw_board():
137139
if games[it]['away'] != games[it]['away'] and \
138140
tmp[it]['home'] != tmp[it]['home']:
139141
it = 0
142+
elif games[it]['status'] and games[it]['score'] != tmp[it]['score']:
143+
# check for score update
144+
pos = ROWS
145+
rounds = 0
146+
while True:
147+
canvas.Clear()
148+
l = graphics.DrawText(canvas, font, pos, height_second_row, textColor, 'GOAL!!!')
149+
pos -= 1
150+
if (pos + l < 0):
151+
pos = ROWS
152+
rounds += 1
153+
if rounds > 3:
154+
break
155+
156+
time.sleep(0.05)
157+
canvas = matrix.SwapOnVSync(canvas)
158+
140159
games = tmp
141160

142161
canvas = matrix.SwapOnVSync(canvas)
File renamed without changes.
File renamed without changes.

main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import sys
2-
import nhl, mlb, nba
2+
# import nhl, mlb, nba
3+
import laliga
34

45
try:
56
print("Press CTRL-C to stop.")
67
while True:
7-
nhl.draw_board()
8-
mlb.draw_board()
9-
nba.draw_board()
8+
laliga.draw_board()
9+
# nhl.draw_board()
10+
# mlb.draw_board()
11+
# nba.draw_board()
1012
except KeyboardInterrupt:
1113
sys.exit(0)

0 commit comments

Comments
 (0)