Exemplo n.º 1
0
def run():
    # Get supplied command line arguments
    commandArgs = args()

    # Check for led configuration arguments
    matrixOptions = led_matrix_options(commandArgs)
    matrixOptions.drop_privileges = False

    # Initialize the matrix
    matrix = Matrix(RGBMatrix(options=matrixOptions))

    # Print some basic info on startup
    debug.info("{} - v{} ({}x{})".format(SCRIPT_NAME, SCRIPT_VERSION,
                                         matrix.width, matrix.height))

    # Read scoreboard options from config.json if it exists
    config = ScoreboardConfig("config", commandArgs, matrix.width,
                              matrix.height)

    debug.set_debug_status(config)

    data = Data(config)

    if data.config.dimmer_enabled:
        dimmer = Dimmer(data, matrix)
        dimmerThread = threading.Thread(target=dimmer.run, args=())
        dimmerThread.daemon = True
        dimmerThread.start()

    MainRenderer(matrix, data).render()
Exemplo n.º 2
0
def run():
    # Get supplied command line arguments
    commandArgs = args()

    # Check for led configuration arguments
    matrixOptions = led_matrix_options(commandArgs)
    matrixOptions.drop_privileges = False

    # Initialize the matrix
    matrix = Matrix(RGBMatrix(options=matrixOptions))

    # Print some basic info on startup
    debug.info("{} - v{} ({}x{})".format(SCRIPT_NAME, SCRIPT_VERSION,
                                         matrix.width, matrix.height))

    # Read scoreboard options from config.json if it exists
    config = ScoreboardConfig("config", commandArgs,
                              (matrix.width, matrix.height))

    debug.set_debug_status(config)

    data = Data(config)

    # Event used to sleep when rendering
    # Allows Web API (coming in V2) and pushbutton to cancel the sleep
    sleepEvent = threading.Event()

    if data.config.dimmer_enabled:
        dimmer = Dimmer(data, matrix)
        dimmerThread = threading.Thread(target=dimmer.run, args=())
        dimmerThread.daemon = True
        dimmerThread.start()

    if data.config.pushbutton_enabled:
        pushbutton = PushButton(data, matrix, sleepEvent)
        pushbuttonThread = threading.Thread(target=pushbutton.run, args=())
        pushbuttonThread.daemon = True
        pushbuttonThread.start()

    MainRenderer(matrix, data, sleepEvent).render()
Exemplo n.º 3
0
def run():
    # Get supplied command line arguments
    commandArgs = args()

    # Check for led configuration arguments
    matrixOptions = led_matrix_options(commandArgs)
    matrixOptions.drop_privileges = False

    # Initialize the matrix
    matrix = RGBMatrix(options=matrixOptions)

    # Print some basic info on startup
    debug.info("{} - v{} ({}x{})".format(SCRIPT_NAME, SCRIPT_VERSION,
                                         matrix.width, matrix.height))

    # Read scoreboard options from config.json if it exists
    config = ScoreboardConfig("config", commandArgs)
    debug.set_debug_status(config)

    data = Data(config)

    # Event used to sleep when rendering
    # Allows API to cancel the sleep
    sleepEvent = threading.Event()

    # Dimmer routine to automatically dim display
    scheduler = BackgroundScheduler()
    dimmer = Dimmer(scheduler, sleepEvent)

    scheduler.start()

    # Initialize API and run on separate thread
    api = ScoreboardApi(data, dimmer, sleepEvent)

    apiThread = threading.Thread(target=api.run, args=())
    apiThread.daemon = True
    apiThread.start()

    MainRenderer(matrix, data, dimmer, sleepEvent).render()
Exemplo n.º 4
0
from renderers.standings import StandingsRenderer
from rgbmatrix import RGBMatrix, RGBMatrixOptions
from utils import args, led_matrix_options
from data.data import Data
import renderers.standings
import mlbgame
import debug

SCRIPT_NAME = "MLB LED Scoreboard"
SCRIPT_VERSION = "2.1.0"

# Get supplied command line arguments
args = args()

# Check for led configuration arguments
matrixOptions = led_matrix_options(args)

# Initialize the matrix
matrix = RGBMatrix(options=matrixOptions)

# Print some basic info on startup
debug.info("{} - v{} ({}x{})".format(SCRIPT_NAME, SCRIPT_VERSION, matrix.width,
                                     matrix.height))

# Read scoreboard options from config.json if it exists
config = ScoreboardConfig("config", matrix.width, matrix.height)
debug.set_debug_status(config)

# Create a new data object to manage the MLB data
# This will fetch initial data from MLB
data = Data(config)
Exemplo n.º 5
0
def run():
    # Kill the splash screen if active
    stop_splash_service()

    # Get supplied command line arguments
    commandArgs = args()

    if commandArgs.terminal_mode and sys.stdin.isatty():
        height, width = os.popen('stty size', 'r').read().split()
        termMatrix = TermMatrix()
        termMatrix.width = int(width)
        termMatrix.height = int(height)
        matrix = Matrix(termMatrix)
    else:
        # Check for led configuration arguments
        matrixOptions = led_matrix_options(commandArgs)
        matrixOptions.drop_privileges = False

        # Initialize the matrix
        matrix = Matrix(RGBMatrix(options = matrixOptions))

     #Riff to add loading screen here
    loading = Loading(matrix)
    loading.render()

    # Read scoreboard options from config.json if it exists
    config = ScoreboardConfig("config", commandArgs, (matrix.width, matrix.height))

    data = Data(config)

    #If we pass the logging arguments on command line, override what's in the config.json, else use what's in config.json (color will always be false in config.json)
    if commandArgs.logcolor and commandArgs.loglevel != None:
        debug.set_debug_status(config,logcolor=commandArgs.logcolor,loglevel=commandArgs.loglevel)
    elif not commandArgs.logcolor and commandArgs.loglevel != None:
        debug.set_debug_status(config,loglevel=commandArgs.loglevel)
    elif commandArgs.logcolor and commandArgs.loglevel == None:
        debug.set_debug_status(config,logcolor=commandArgs.logcolor,loglevel=config.loglevel)
    else:
        debug.set_debug_status(config,loglevel=config.loglevel)

    # Print some basic info on startup
    debug.info("{} - v{} ({}x{})".format(SCRIPT_NAME, SCRIPT_VERSION, matrix.width, matrix.height))
    
    if data.latlng is not None:
        debug.info(data.latlng_msg)
    else:
        debug.error("Unable to find your location.")

    # Event used to sleep when rendering
    # Allows Web API (coming in V2) and pushbutton to cancel the sleep
    # Will also allow for weather alert to interrupt display board if you want
    sleepEvent = threading.Event()


    # Start task scheduler, used for UpdateChecker and screensaver, forecast, dimmer and weather
    scheduler = BackgroundScheduler()
    scheduler.start()

    # Any tasks that are scheduled go below this line

    # Make sure we have a valid location for the data.latlng as the geocode can return a None
    # If there is no valid location, skip the weather boards
    
    #Create EC data feed handler
    if data.config.weather_enabled or data.config.wxalert_show_alerts:
        if data.config.weather_data_feed.lower() == "ec" or data.config.wxalert_alert_feed.lower() == "ec":
            try:
                data.ecData = ECData(coordinates=(data.latlng))
            except Exception as e:
                debug.error("Unable to connect to EC, try running again in a few minutes")
                sys.exit(0)

    if data.config.weather_enabled:
        if data.config.weather_data_feed.lower() == "ec":
            ecWxWorker(data,scheduler)
        elif data.config.weather_data_feed.lower() == "owm":
            owmweather = owmWxWorker(data,scheduler)
        else:
            debug.error("No valid weather providers selected, skipping weather feed")
            data.config.weather_enabled = False


    if data.config.wxalert_show_alerts:
        if data.config.wxalert_alert_feed.lower() == "ec":
            ecalert = ecWxAlerts(data,scheduler,sleepEvent)
        elif data.config.wxalert_alert_feed.lower() == "nws":
            nwsalert = nwsWxAlerts(data,scheduler,sleepEvent)
        else:
            debug.error("No valid weather alerts providers selected, skipping alerts feed")
            data.config.weather_show_alerts = False

    if data.config.weather_forecast_enabled and data.config.weather_enabled:
        wxForecast(data,scheduler)
    #
    # Run check for updates against github on a background thread on a scheduler
    #
    if commandArgs.updatecheck:
        data.UpdateRepo = commandArgs.updaterepo
        checkupdate = UpdateChecker(data,scheduler,commandArgs.ghtoken)

    if data.config.dimmer_enabled:
        dimmer = Dimmer(data, matrix,scheduler)

    screensaver = None
    if data.config.screensaver_enabled:
        screensaver = screenSaver(data, matrix, sleepEvent, scheduler)
        if data.config.screensaver_motionsensor:
            motionsensor = Motion(data,matrix,sleepEvent,scheduler,screensaver)
            motionsensorThread = threading.Thread(target=motionsensor.run, args=())
            motionsensorThread.daemon = True
            motionsensorThread.start()

    if data.config.pushbutton_enabled:
        pushbutton = PushButton(data,matrix,sleepEvent)
        pushbuttonThread = threading.Thread(target=pushbutton.run, args=())
        pushbuttonThread.daemon = True
        pushbuttonThread.start()
    

    MainRenderer(matrix, data, sleepEvent).render()
Exemplo n.º 6
0
        endtime = time.time()
        time_delta = endtime - starttime
        rotate_rate = data.config.rotate_rate_for_status(
            data.current_game.status())

        if time_delta >= rotate_rate and data.scrolling_finished:
            starttime = time.time()
            if rotate:
                data.advance_to_next_game()


def __render_main(matrix, data):
    MainRenderer(matrix, data).render()


if __name__ == "__main__":
    # Check for led configuration arguments
    command_line_args = args()
    matrixOptions = led_matrix_options(command_line_args)

    # Initialize the matrix
    matrix = RGBMatrix(options=matrixOptions)
    try:
        config, _ = os.path.splitext(command_line_args.config)
        main(matrix, config)
    except:
        debug.exception("Untrapped error in main!")
        sys.exit(1)
    finally:
        matrix.Clear()
Exemplo n.º 7
0
def run():
    # Get supplied command line arguments
    commandArgs = args()

    if commandArgs.terminal_mode:
        height, width = os.popen('stty size', 'r').read().split()
        termMatrix = TermMatrix()
        termMatrix.width = int(width)
        termMatrix.height = int(height)
        matrix = Matrix(termMatrix)
    else:
        # Check for led configuration arguments
        matrixOptions = led_matrix_options(commandArgs)
        matrixOptions.drop_privileges = False

        # Initialize the matrix
        matrix = Matrix(RGBMatrix(options = matrixOptions))

    # Print some basic info on startup
    debug.info("{} - v{} ({}x{})".format(SCRIPT_NAME, SCRIPT_VERSION, matrix.width, matrix.height))

    # Read scoreboard options from config.json if it exists
    config = ScoreboardConfig("config", commandArgs, (matrix.width, matrix.height))

    debug.set_debug_status(config)

    data = Data(config)

    # Event used to sleep when rendering
    # Allows Web API (coming in V2) and pushbutton to cancel the sleep
    # Will also allow for weather alert to interrupt display board if you want
    sleepEvent = threading.Event()

    if data.config.dimmer_enabled:
        dimmer = Dimmer(data, matrix)
        dimmerThread = threading.Thread(target=dimmer.run, args=())
        dimmerThread.daemon = True
        dimmerThread.start()

    if data.config.pushbutton_enabled:
        pushbutton = PushButton(data,matrix,sleepEvent)
        pushbuttonThread = threading.Thread(target=pushbutton.run, args=())
        pushbuttonThread.daemon = True
        pushbuttonThread.start()
    
    if data.config.weather_enabled:
        if data.config.weather_data_feed.lower() == "owm":
            owmweather = owmWxWorker(data,sleepEvent)
            owmweatherThread = threading.Thread(target=owmweather.run,args=())
            owmweatherThread.daemon = True
            owmweatherThread.start()
        elif data.config.weather_data_feed.lower() == "ec":
            ecweather = ecWxWorker(data,sleepEvent)
            ecweatherThread = threading.Thread(target=ecweather.run,args=())
            ecweatherThread.daemon = True
            ecweatherThread.start()
        else:
            debug.error("No valid weather providers selected, skipping weather feed")
            data.config.weather_enabled = False

    if data.config.weather_show_alerts and data.config.weather_enabled:
        if data.config.weather_alert_feed.lower() == "ec":
            ecalert = ecWxAlerts(data,sleepEvent)
            ecalertThread = threading.Thread(target=ecalert.run,args=())
            ecalertThread.daemon = True
            ecalertThread.start()
        elif data.config.weather_alert_feed.lower() == "nws":
            nwsalert = nwsWxAlerts(data,sleepEvent)
            nwsalertThread = threading.Thread(target=nwsalert.run,args=())
            nwsalertThread.daemon = True
            nwsalertThread.start()
        else:
            debug.error("No valid weather alerts providers selected, skipping alerts feed")
            data.config.weather_show_alerts = False
    
    #
    # Run check for updates against github on a background thread on a scheduler
    #     
    updateCheck= True
    if updateCheck:
        scheduler = BackgroundScheduler()
        checkupdate = UpdateChecker(data,scheduler)
        scheduler.start()

    MainRenderer(matrix, data, sleepEvent).render()
Exemplo n.º 8
0
from renderers.standings import StandingsRenderer
from rgbmatrix import RGBMatrix, RGBMatrixOptions
from utils import args, led_matrix_options
from data.data import Data
import renderers.standings
import mlbgame
import debug

SCRIPT_NAME = "MLB LED Scoreboard"
SCRIPT_VERSION = "3.1.4"

# Get supplied command line arguments
args = args()

# Check for led configuration arguments
matrixOptions = led_matrix_options(args)

# Initialize the matrix
matrix = RGBMatrix(options = matrixOptions)

# Print some basic info on startup
debug.info("{} - v{} ({}x{})".format(SCRIPT_NAME, SCRIPT_VERSION, matrix.width, matrix.height))

# Read scoreboard options from config.json if it exists
config = ScoreboardConfig("config", matrix.width, matrix.height)
debug.set_debug_status(config)

# Create a new data object to manage the MLB data
# This will fetch initial data from MLB
data = Data(config)
def run():
  # Get supplied command line arguments
  command_args = args()

  # Check for led configuration arguments
  matrixOptions = led_matrix_options(command_args)
  matrixOptions.drop_privileges = False

  # Initialize the matrix
  matrix = RGBMatrix(options = matrixOptions)

  # Initialize the offscreen canvas
  offscreen_canvas = matrix.CreateFrameCanvas()

  # Initialize ZMQ server
  socket_address = command_args.socket_addr
  context = zmq.Context()
  socket = context.socket(zmq.REP)
  socket.bind(socket_address)

  print('Server started at ' + socket_address)

  print('Starting subprocesses...')

  # Declare list to contain each subprocess
  processes = list()
  num_processes = command_args.led_chain
  print('number of subprocesses = ' + str(num_processes))

  for i in range(num_processes):
    p = subprocess.Popen(['python3', './src/main.py', '--panel-offset={0}'.format(i)])
    processes.append(p)
    print('started subprocess ' + str(i))


  print('Waiting for input...')

  offscreen_canvas.Fill(255,255,255)
  matrix.SwapOnVSync(offscreen_canvas)

  # create empty image
  empty_image = Image.new('RGB', (64,32))

  continue_loop = True

  while (continue_loop):
    message = socket.recv_pyobj()
    # print('received request')
    
    if (isinstance(message, ZMQMessage)):
      x_image_location = 64 * message.panel_offset
      offscreen_canvas.SetImage(empty_image, x_image_location, 0)
      offscreen_canvas.SetImage(message.image, x_image_location, 0)
      matrix.SwapOnVSync(offscreen_canvas)
    else:
      print('type mismatch')


    
    

    socket.send(b'done')
  
  socket.close()