Skip to content

Commit 1408942

Browse files
committed
MVP 1
1 parent c19480b commit 1408942

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

bbapp/bb_app_runner.py

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,17 @@ def get_news_from_file():
8787
return news
8888

8989
def clear_story_area():
90-
d.fill_rectangle(1, 55, 318, 140, d.drk_grn)
90+
d.fill_rectangle(1, 41, 318, 159, d.drk_grn)
9191

92-
def cycle_stories(func):
93-
count=0 ; ssleep =7
92+
def cycle_stories(func, sleep=30):
93+
count=1 ; ssleep=7
9494
while count < 475: #On Average ~ 23.5 hours
95+
9596
for story in news:
9697
print(f"=={count}")
97-
if count % 7 == 0:
98+
if count > 0 and count % 7 == 0:
9899
func()
99-
time.sleep(ssleep)
100+
time.sleep(sleep)
100101
clear_story_area()
101102
else:
102103
d.draw_text(5, start + (0 * delta), f"MLB News: {mt}-{dy}-{short_yr}" , d.date_font, d.white , d.drk_grn)
@@ -112,12 +113,12 @@ def cycle_stories(func):
112113
clear_story_area()
113114
count+=1
114115

115-
def show_filler_news(func):
116+
def show_filler_news(func, sleep=30):
116117
get_latest_news()
117118
say_fetching("Fetching News")
118119
news=get_news_from_file()
119120
fresh_box()
120-
cycle_stories(func)
121+
cycle_stories(func, sleep=30)
121122

122123
def fresh_box():
123124
d.clear_fill()
@@ -126,12 +127,12 @@ def fresh_box():
126127
def run_factory_test():
127128
#If no game that day games will be empty, not undefined
128129
global games
129-
games = []
130-
check_if_game()
131130
from .test_games import games
132131
for x in games:
133132
games = [x]
134133
check_if_game()
134+
games = []
135+
check_if_game()
135136

136137
def get_x_p(pname):
137138
""" Given 'John Smith (Jr.)' """
@@ -237,28 +238,32 @@ def get_score():
237238
d.draw_text(10, start + (4 * delta) + 5, f"B: {balls} S: {strks} O: {outs }" , d.sm_font, d.white , d.drk_grn)
238239
d.draw_outline_box()
239240

240-
if factory_test == "True":
241+
if factory_test:
241242
return 5
242-
return 60 * 1# check back every x minutes
243+
return 60 * 2# check back every x minutes
243244

244245
elif game_status == "Game Over" or game_status == "Final":
245246

246247
""" Stretch the Game Status to minimize ghost pixelation """
247248
""" here and with ZZZ in Warm up below """
249+
fsleep=30
250+
def show_final():
251+
game_status = "Final Score"
252+
lp = get_x_p(games[0]['losing_pitcher'])
253+
wp = get_x_p(games[0]['winning_pitcher'])
254+
255+
d.clear_fill()
256+
d.draw_text(5, start + (0 * delta), f"{mt}-{dy}-{short_yr} {game_status}" , d.date_font, d.white , d.drk_grn)
257+
d.draw_text(5, start + (1 * delta), f"{team1}:{team1_score} H {home_rec}" , d.score_font, d.white , d.drk_grn)
258+
d.draw_text(5, start + (2 * delta), f"{team2}:{team2_score} A {away_rec}" , d.score_font, d.white , d.drk_grn)
259+
d.draw_text(5, start + (3 * delta), f"WP: {wp}" , d.sm_font, d.white , d.drk_grn)
260+
d.draw_text(5, 0 + (4 * delta), f"LP: {lp}" , d.sm_font, d.white , d.drk_grn)
261+
d.draw_outline_box()
262+
show_final()
263+
time.sleep(fsleep)
264+
show_filler_news(show_final, sleep=fsleep)
248265

249-
game_status = "Final Score"
250-
lp = get_x_p(games[0]['losing_pitcher'])
251-
wp = get_x_p(games[0]['winning_pitcher'])
252-
253-
d.clear_fill()
254-
d.draw_text(5, start + (0 * delta), f"{mt}-{dy}-{short_yr} {game_status}" , d.date_font, d.white , d.drk_grn)
255-
d.draw_text(5, start + (1 * delta), f"{team1}:{team1_score} H {home_rec}" , d.score_font, d.white , d.drk_grn)
256-
d.draw_text(5, start + (2 * delta), f"{team2}:{team2_score} A {away_rec}" , d.score_font, d.white , d.drk_grn)
257-
d.draw_text(5, start + (3 * delta), f"WP: {wp}" , d.sm_font, d.white , d.drk_grn)
258-
d.draw_text(5, start + (4 * delta), f"LP: {lp}" , d.sm_font, d.white , d.drk_grn)
259-
d.draw_outline_box()
260-
261-
if factory_test == "True":
266+
if factory_test:
262267
return 5
263268
return 60 * 60 *4 # check back 4 hours from now
264269

@@ -275,7 +280,7 @@ def get_score():
275280
d.draw_text(5, start + (4 * delta), f"ZZZZZZZZZZZZZZZZZZZZZ" , d.sm_font, d.drk_grn, d.drk_grn)
276281
d.draw_outline_box()
277282

278-
if factory_test == "True":
283+
if factory_test:
279284
return 5
280285
return 60 * 20 # check back every 20 minutes
281286

@@ -285,7 +290,7 @@ def get_score():
285290
global games
286291
import gc
287292
gc.collect()
288-
factory_test = True
293+
factory_test = False
289294
force_offseason = False
290295
print(f"Version: {version}")
291296
yr, mt, dy, hr, mn, s1, s2, s3 = [ f"{x:02d}" for x in time.localtime() ]
@@ -322,4 +327,4 @@ def get_score():
322327
import machine
323328
machine.reset()
324329
else:
325-
check_if_game()
330+
check_if_game()

bbapp/games.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""" NON PROD LOCAL TEST FILE """
22

3-
# statuses = [ 'In Progress', 'Pre Game', 'Game Over', 'Final' ]
3+
# statuses = [ 'In Progress', 'Final', 'Pre Game', 'Game Over', ]
44
# for x in statuses:
55

66
games = [ {'game_id': 663188, 'away_pitcher_note': '',

0 commit comments

Comments
 (0)