Skip to content

Added scrolling marquee example #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions examples/is31fl3731_pillow_marquee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
Example to scroll some text as a marquee

This example is for use on (Linux) computers that are using CPython with
Adafruit Blinka to support CircuitPython libraries. CircuitPython does
not support PIL/pillow (python imaging library)!

Author(s): Melissa LeBlanc-Williams for Adafruit Industries
"""

import board
from PIL import Image, ImageDraw, ImageFont
import adafruit_is31fl3731

SCROLLING_TEXT = "You can display a personal message here..."
BRIGHTNESS = 64 # Brightness can be between 0-255

i2c = board.I2C()

# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
#display = adafruit_is31fl3731.Matrix(i2c)
# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
display = adafruit_is31fl3731.CharlieBonnet(i2c)

# Load a font
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 8)

# Create an image that contains the text
text_width, text_height = font.getsize(SCROLLING_TEXT)
text_image = Image.new('L', (text_width, text_height))
text_draw = ImageDraw.Draw(text_image)
text_draw.text((0, 0), SCROLLING_TEXT, font=font, fill=BRIGHTNESS)

# Create an image for the display
image = Image.new('L', (display.width, display.height))
draw = ImageDraw.Draw(image)

# Load the text in each frame
while True:
for x in range(text_width + display.width):
draw.rectangle((0, 0, display.width, display.height), outline=0, fill=0)
image.paste(text_image, (display.width - x, display.height // 2 - text_height // 2 - 1))
display.image(image)
4 changes: 3 additions & 1 deletion examples/is31fl3731_pillow_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from PIL import Image, ImageDraw, ImageFont
import adafruit_is31fl3731

BRIGHTNESS = 32 # Brightness can be between 0-255

i2c = board.I2C()

# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
Expand All @@ -32,7 +34,7 @@
# Load the text in each frame
for x in range(8):
draw.rectangle((0, 0, display.width, display.height), outline=0, fill=0)
draw.text((x + 1, -2), str(x + 1), font=font, fill=32)
draw.text((x + 1, -2), str(x + 1), font=font, fill=BRIGHTNESS)
display.image(image, frame=x)

display.autoplay(delay=500)