diff --git a/README.rst b/README.rst index 2082a40..96d7a45 100644 --- a/README.rst +++ b/README.rst @@ -19,6 +19,7 @@ This driver supports the following hardware: * `Adafruit 16x9 Charlieplexed PWM LED Matrix Driver - IS31FL3731 `_ * `Adafruit 15x7 CharliePlex LED Matrix Display FeatherWings `_ +* `Adafruit 16x8 CharliePlex LED Matrix Bonnets `_ Dependencies ============= diff --git a/examples/is31fl3731_pillow_animated_gif.py b/examples/is31fl3731_pillow_animated_gif.py new file mode 100644 index 0000000..0a486c8 --- /dev/null +++ b/examples/is31fl3731_pillow_animated_gif.py @@ -0,0 +1,66 @@ +""" +Example to extract the frames and other parameters from an animated gif +and then run the animation on the display. + +Usage: +python3 is31fl3731_pillow_animated_gif.py animated.gif + +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 sys +import board +from PIL import Image +import adafruit_is31fl3731 + +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) +display.fill(0) + +# Open the gif +if len(sys.argv) < 2: + print("No image file specified") + print("Usage: python3 is31fl3731_pillow_animated_gif.py animated.gif") + sys.exit() + +image = Image.open(sys.argv[1]) + +# Make sure it's animated +if not image.is_animated: + print("Specified image is not animated") + sys.exit() + +# Get the autoplay information from the gif +delay = image.info['duration'] +loops = image.info['loop'] + +# Adjust loop count (0 is forever) +if loops > 0: + loops += 1 + +# IS31FL3731 only supports 0-7 +if loops > 7: + loops = 7 + +# Get the frame count (maximum 8 frames) +frame_count = image.n_frames +if frame_count > 8: + frame_count = 8 + +# Load each frame of the gif onto the Matrix +for frame in range(frame_count): + image.seek(frame) + frame_image = Image.new('L', (display.width, display.height)) + frame_image.paste(image.convert("L"), (display.width // 2 - image.width // 2, + display.height // 2 - image.height // 2)) + display.image(frame_image, frame=frame) + +display.autoplay(delay=delay, loops=loops) diff --git a/examples/is31fl3731_pillow_numbers.py b/examples/is31fl3731_pillow_numbers.py index 6656f26..25b7b41 100644 --- a/examples/is31fl3731_pillow_numbers.py +++ b/examples/is31fl3731_pillow_numbers.py @@ -2,6 +2,10 @@ Example to utilize the Python Imaging Library (Pillow) and draw bitmapped text to 8 frames and then run autoplay on those frames. +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 """