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.
To use with CircuitPython, you need to first install a few libraries, into the lib folder on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, open the directory IS31FL3741_DisplayIO/sports_glasses/ and then click on the directory that matches the version of CircuitPython you're using and copy the contents of that directory to your CIRCUITPY drive.
Your CIRCUITPY
# 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 (
glassesmatrix_ledmap_no_ring,
left_ring_map_no_inner,
right_ring_map_no_inner,
)
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
from adafruit_led_animation.animation.chase import Chase
from adafruit_debouncer import Debouncer
# List of possible messages to display. Randomly chosen
MESSAGES = (
"GO TEAM GO",
"WE ARE NUMBER 1",
"I LIKE THE HALFTIME SHOW",
)
# 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
switch.update()
if not switch.value:
return
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
chase_left.animate()
chase_right.animate()
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
chase_left.animate()
chase_right.animate()
time.sleep(0.008) # adjust to change scrolling speed
# Remove any existing displays
displayio.release_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()
group.append(text_area)
display.root_group = group
while True:
# Run the debouncer code to get the updated switch value
switch.update()
# 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
left_eye.fill(BLUE_RING)
right_eye.fill(BLUE_RING)
left_eye.show()
right_eye.show()
ScrollMessage(random.choice(MESSAGES), YELLOW_TEXT, 2)
Page last edited January 20, 2025
Text editor powered by tinymce.