|
4 | 4 | from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics
|
5 | 5 | from PIL import Image, ImageOps
|
6 | 6 |
|
| 7 | +from gpiozero import Button |
| 8 | + |
7 | 9 | from .game import Scores
|
8 | 10 | from config import COLS, ROWS, INTERVAL, BRIGHTNESS
|
9 | 11 |
|
@@ -68,23 +70,23 @@ def draw_board():
|
68 | 70 | # Print score final or live
|
69 | 71 | score_len = len(games[it]['score'])*4
|
70 | 72 |
|
71 |
| - if game['stage'] == 'Scheduled': |
| 73 | + if games[it]['stage'] == 'Scheduled': |
72 | 74 | # If planned game, print @ and time
|
73 | 75 | period_len = len(games[it]['period'])*4
|
74 | 76 | graphics.DrawText(canvas, font,
|
75 | 77 | int((COLS - 4) / 2),
|
76 | 78 | height_first_row, textColor, "@")
|
77 | 79 | graphics.DrawText(canvas, font,
|
78 | 80 | int((COLS - period_len) / 2),
|
79 |
| - height_second_row, textColor, game['period']) |
| 81 | + height_second_row, textColor, games[it]['period']) |
80 | 82 | graphics.DrawText(canvas, font,
|
81 |
| - int((COLS - 16) / 2), |
| 83 | + int((COLS - 12) / 2), |
82 | 84 | height_third_row, textColor, 'GMT')
|
83 |
| - elif game['stage'] == 'Full Time': |
| 85 | + elif games[it]['stage'] == 'Full Time': |
84 | 86 | # Else print 'fin' to indicate final score
|
85 | 87 | graphics.DrawText(canvas, font,
|
86 | 88 | int((COLS - 12) / 2),
|
87 |
| - height_first_row, textColor, "fin") |
| 89 | + height_first_row, textColor, "FIN") |
88 | 90 | graphics.DrawText(canvas, font,
|
89 | 91 | int((COLS - score_len) / 2),
|
90 | 92 | height_second_row, textColor, games[it]['score'])
|
@@ -137,6 +139,23 @@ def draw_board():
|
137 | 139 | if games[it]['away'] != games[it]['away'] and \
|
138 | 140 | tmp[it]['home'] != tmp[it]['home']:
|
139 | 141 | 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 | + |
140 | 159 | games = tmp
|
141 | 160 |
|
142 | 161 | canvas = matrix.SwapOnVSync(canvas)
|
0 commit comments