Skip to content

Commit

Permalink
Merge pull request #444 from MLB-LED-Scoreboard/dev
Browse files Browse the repository at this point in the history
Release 6.2.0
  • Loading branch information
ty-porter authored Apr 7, 2023
2 parents 0d47756 + 20e25f4 commit 9d82878
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 99 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ A default `config.json.example` file is included for reference. Copy this file t
"only_preferred" Bool Only rotate through games in your preferred teams.
"only_live" Bool Only rotate through games which are currently playing. Can be composed with `only_preferred`.
"rates" Dict Dictionary of Floats. Each type of screen can use a different rotation rate. Valid types: "live", "pregame", "final".
Float (DEPRECATED) A Float can be used to set all screen types to the same rotate rate.
Float (DEPRECATED) A Float can be used to set all screen types to the same rotate rate.
"while_preferred_team_live": Options for rotating between screens while one of your preferred teams is live
"enabled" Bool Enable rotation while a preferred team is live.
Expand All @@ -243,10 +243,18 @@ A default `config.json.example` file is included for reference. Copy this file t
"full_team_names" Bool If enabled on a board width >= 64, displays the full team name on the scoreboard instead of their abbreviation. This config option is ignored on 32-wide boards.
"short_team_names_for_runs_hits" Bool If full_team_names is enabled, will use abreviated team names when runs or hits > 9 to prevent overflow of long names into RHE.
"scrolling_speed" Integer Sets how fast the scrolling text scrolls. Supports an integer between 0 and 6.
"preferred_game_update_delay_in_10s_of_seconds" Integer Sets how long to wait before updating the preferred game. Must be positive.
"pregame_weather" Bool If enabled, will display the weather for the game's location on the pregame screen.
"debug" Bool Game and other debug data is written to your console.
"demo_date" String A date in the format YYYY-MM-DD from which to pull data to demonstrate the scoreboard. A value of `false` will disable demo mode.
```

### Delaying Board Update
* The "preferred_game_update_delay_in_10s_of_seconds" will delay the update of your LED board to allow you to synchronize with the boroadcast feed.
* You can only delay the board in 10 second increments, so a value of 3 coresponds to 30 seconds, 5 to 50 seconds etc.
* There appears to be a lot of variability in broadcast delays across networks/teams/CDN's.
* Please note, that if restarting the service with a delay, it will take the value of cycles set for the board to be in sync. If you set the value to 3, it will take 30-40 seconds for the buffer to fill and the board to delay.

### Additional Features
* Runs/Hits/Errors - Runs are always shown on the games screen, but you can enable or adjust spacing of a "runs, hits, errors" display. Take a look at the [coordinates readme file](/coordinates/README.md) for details.

Expand Down
1 change: 1 addition & 0 deletions config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"end_of_day": "00:00",
"full_team_names": true,
"short_team_names_for_runs_hits": true,
"preferred_game_update_delay_in_10s_of_seconds": 0,
"pregame_weather": true,
"scrolling_speed": 2,
"debug": false,
Expand Down
2 changes: 2 additions & 0 deletions coordinates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ The software develops and releases features with full support for the default la
A couple of things are not completely implemented or have some implementation details you should understand.

* `bases` currently requires an even `size` value to be rendered correctly
* Not all options are enabled on all board sizes by default. For example pitch count and pitch type are not enabled by default on boards smaller than 64x64. Options are "disabled" by forcing them to render outside the board, by setting X and Y coordinates less than 0 or greater than the height or width of the board.

6 changes: 4 additions & 2 deletions data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import time

import data.config.layout as layout

import debug
from data import status
from data.game import Game
Expand Down Expand Up @@ -132,6 +132,7 @@ def get_screen_type(self):
return "games"

def __update_layout_state(self):
import data.config.layout as layout
self.config.layout.set_state()
if self.current_game.status() == status.WARMUP:
self.config.layout.set_state(layout.LAYOUT_STATE_WARMUP)
Expand All @@ -143,7 +144,8 @@ def __update_layout_state(self):
self.config.layout.set_state(layout.LAYOUT_STATE_PERFECT)

def print_game_data_debug(self):
debug.log("Game Data Refreshed: %s", self.current_game._data["gameData"]["game"]["id"])
debug.log("Game Data Refreshed: %s", self.current_game._current_data["gameData"]["game"]["id"])
debug.log("Current game is %d seconds behind", self.current_game.current_delay())
debug.log("Pre: %s", Pregame(self.current_game, self.config.time_format))
debug.log("Live: %s", Scoreboard(self.current_game))
debug.log("Final: %s", Postgame(self.current_game))
20 changes: 17 additions & 3 deletions data/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def __init__(self, filename_base, width, height):
self.full_team_names = json["full_team_names"]
self.short_team_names_for_runs_hits = json["short_team_names_for_runs_hits"]
self.pregame_weather = json["pregame_weather"]
self.delay_in_10s_of_seconds = json["preferred_game_update_delay_in_10s_of_seconds"]

self.debug = json["debug"]
self.demo_date = json["demo_date"]
# Make sure the scrolling speed setting is in range so we don't crash
Expand Down Expand Up @@ -94,6 +96,7 @@ def __init__(self, filename_base, width, height):

# Check the rotation_rates to make sure it's valid and not silly
self.check_rotate_rates()
self.check_delay()

def check_preferred_teams(self):
if not isinstance(self.preferred_teams, str) and not isinstance(self.preferred_teams, list):
Expand All @@ -106,6 +109,19 @@ def check_preferred_teams(self):
team = self.preferred_teams
self.preferred_teams = [team]

def check_delay(self):
if self.delay_in_10s_of_seconds < 0:
debug.warning(
"preferred_game_update_delay_in_10s_of_seconds should be a positive integer. Using default value of 0"
)
self.delay_in_10s_of_seconds = 0
if self.delay_in_10s_of_seconds != int(self.delay_in_10s_of_seconds):
debug.warning(
"preferred_game_update_delay_in_10s_of_seconds should be an integer."
f" Truncating to {int(self.delay_in_10s_of_seconds)}"
)
self.delay_in_10s_of_seconds = int(self.delay_in_10s_of_seconds)

def check_preferred_divisions(self):
if not isinstance(self.preferred_divisions, str) and not isinstance(self.preferred_divisions, list):
debug.warning(
Expand Down Expand Up @@ -133,9 +149,7 @@ def check_rotate_rates(self):
debug.warning(" Re-run the install/update script to convert to the new format")
debug.warning(" Example: sudo sh ./install.sh")
except:
debug.warning(
"rotation_rates should be a Dict. Using default value. {}".format(DEFAULT_ROTATE_RATES)
)
debug.warning("rotation_rates should be a Dict. Using default value. {}".format(DEFAULT_ROTATE_RATES))
self.rotation_rates = DEFAULT_ROTATE_RATES

for key, value in list(self.rotation_rates.items()):
Expand Down
27 changes: 27 additions & 0 deletions data/delay_buffer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from collections import deque


class CircularQueue:
"""
A circular queue that stores a fixed number of items.
Unlike a traditional ring buffer, reading from the queue does not
remove the item from the queue. This allows the queue to be used
to buffer incoming live game data in such a way that the first update is
"instant", and the subsequent updates are delayed until the buffer is full.
"""

def __init__(self, size):
self.size = size
self.queue = deque(maxlen=size)

def push(self, data):
self.queue.append(data)

def peek(self):
top = self.queue.popleft()
self.queue.appendleft(top)
return top

def __len__(self):
return len(self.queue)
Loading

0 comments on commit 9d82878

Please sign in to comment.