This example requires CircuitPython 7.2.0-alpha.1 or later.

The perfect project to get yourself shown on the jumbotron at the next big game. Cheer on your team while scrolling encouraging messages across the LED glasses matrix. Customize the text and ring light colors to match your team colors.

And for when your team scores a run, goal, touchdown, etc. and you want to celebrate, press the button on the top of the LED glasses driver board which trigger an elaborate celebration. A special message scrolls across the display and the eye lights animate using the Adafruit_LED_Library.

Use the “Download Project Bundle” button below to get this CircuitPython code and all required libraries.

# SPDX-FileCopyrightText: 2022 Mark Komus
# SPDX-License-Identifier: MIT

import random
import time
import board
import busio
import digitalio
import displayio
import framebufferio
import is31fl3741
from adafruit_is31fl3741.is31fl3741_PixelBuf import IS31FL3741_PixelBuf
from adafruit_is31fl3741.led_glasses_map import (
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
from import Chase
from adafruit_debouncer import Debouncer

# List of possible messages to display. Randomly chosen
    "GO TEAM GO",
    "WE ARE NUMBER 1",

# Colors used for the text and ring lights
BLUE_TEXT = (0, 20, 255)
BLUE_RING = (0, 10, 120)
YELLOW_TEXT = (220, 210, 0)
YELLOW_RING = (150, 140, 0)

def ScrollMessage(text, color, repeat):
    """Scroll a message across the eyeglasses a set number of times"""
    text_area.text = text
    text_area.color = color

    # Start the message just off the side of the glasses
    x = display.width
    text_area.x = x

    # Determine the width of the message to scroll
    width = text_area.bounding_box[2]

    for _ in range(repeat):
        while x != -width:
            x = x - 1
            text_area.x = x

            # Update the switch and if it has been pressed abort scrolling this message
            if not switch.value:

            time.sleep(0.025) # adjust to change scrolling speed
        x = display.width

def Score(text, color, ring_color, repeat):
    """Show a scrolling text message and animated effects on the eye rings.
    The messages scrolls left to right, then right to left while the eye rings
    are animated using the adafruit_led_animation library."""

    # Set up a led animation chase sequence for both eyelights
    chase_left = Chase(left_eye, speed=0.11, color=ring_color, size=8, spacing=4)
    chase_right = Chase(right_eye, speed=0.07, color=ring_color, size=8, spacing=4)

    text_area.text = text
    text_area.color = color

    x = display.width
    text_area.x = x

    width = text_area.bounding_box[2]

    for _ in range(repeat):
        # Scroll the text left and animate the eyes
        while x != -width:
            x = x - 1
            text_area.x = x
            time.sleep(0.008) # adjust to change scrolling speed
        # Scroll the text right and animate the eyes
        while x != display.width:
            x = x + 1
            text_area.x = x
            time.sleep(0.008) # adjust to change scrolling speed

# Remove any existing displays

# Set up the top button used to trigger a special message when pressed
switch_pin = digitalio.DigitalInOut(board.SWITCH)
switch_pin.direction = digitalio.Direction.INPUT
switch_pin.pull = digitalio.Pull.UP
switch = Debouncer(switch_pin)

# Initialize the LED Glasses
# In this example scale is set to True. When True the logical display is
# three times the physical display size and scaled down to allow text to
# look more natural for small display sizes. Hence the display is created
# as 54x15 when the physical display is 18x5.
i2c = busio.I2C(board.SCL, board.SDA, frequency=1000000)
is31 = is31fl3741.IS31FL3741(i2c=i2c)
is31_framebuffer = is31fl3741.IS31FL3741_FrameBuffer(
    is31, 54, 15, glassesmatrix_ledmap_no_ring, scale=True, gamma=True
display = framebufferio.FramebufferDisplay(is31_framebuffer, auto_refresh=True)

# Set up the left and right eyelight rings
# init is set to False as the IS31FL3741_FrameBuffer has already initialized the IS31FL3741 driver
left_eye = IS31FL3741_PixelBuf(
    is31, left_ring_map_no_inner, init=False, auto_write=False
right_eye = IS31FL3741_PixelBuf(
    is31, right_ring_map_no_inner, init=False, auto_write=False

# Dim the display. Full brightness is BRIGHT
is31_framebuffer.brightness = 0.2

# Load the font to be used - scrolly only has upper case letters
font = bitmap_font.load_font("/fonts/scrolly.bdf")

# Set up the display elements
text_area = label.Label(font, text="", color=(0, 0, 0))
text_area.y = 8
group = displayio.Group()

while True:
    # Run the debouncer code to get the updated switch value

    # If the switch has been pressed interrupt start a special message
    if not switch.value:
        Score("SCORE!", YELLOW_TEXT, BLUE_RING, 2)

    # If the switch is not pressed pick a random message and scroll it
    ScrollMessage(random.choice(MESSAGES), YELLOW_TEXT, 2)

This guide was first published on Oct 12, 2021. It was last updated on 2022-02-14 16:45:58 -0500.

This page (DisplayIO Sports Scroller) was last updated on May 24, 2022.

Text editor powered by tinymce.