Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-is31fl3731

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-is31fl3731

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activate
pip3 install adafruit-circuitpython-is31fl3731

Usage Example

Matrix:

import adafruit_is31fl3731
import board
import busio
with busio.I2C(board.SCL, board.SDA) as i2c:
    display = adafruit_is31fl3731.Matrix(i2c)
    display.fill(127)

Charlie Wing:

import adafruit_is31fl3731
import board
import busio
with busio.I2C(board.SCL, board.SDA) as i2c:
    display = adafruit_is31fl3731.CharlieWing(i2c)
    display.fill(127)

    # Turn off pixel 4,4, change its brightness and turn it back on
    display.pixel(4, 4, 0)   # Turn off.
    display.pixel(4, 4, 50)  # Low brightness (50)
    display.pixel(4, 4, 192) # Higher brightness (192)

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation

For information on building library documentation, please check out this guide.

Table of Contents

Simple test

Ensure your device works with this simple test.

examples/is31fl3731_simpletest.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import board
import busio
import adafruit_is31fl3731

i2c = busio.I2C(board.SCL, board.SDA)

# initialize display using Feather CharlieWing LED 15 x 7
display = adafruit_is31fl3731.CharlieWing(i2c)

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

# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet
# display = adafruit_is31fl3731.CharlieBonnet(i2c)

# initial display using Pimoroni Scroll Phat HD LED 17 x 7
# display = adafruit_is31fl3731.ScrollPhatHD(i2c)

# draw a box on the display
# first draw the top and bottom edges
for x in range(display.width):
    display.pixel(x, 0, 50)
    display.pixel(x, display.height - 1, 50)
# now draw the left and right edges
for y in range(display.height):
    display.pixel(0, y, 50)
    display.pixel(display.width - 1, y, 50)

Other Examples

examples/is31fl3731_blink_example.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import busio
import board
import adafruit_is31fl3731

i2c = busio.I2C(board.SCL, board.SDA)

# array pattern in bits; top row-> bottom row, 8 bits in each row
an_arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00))

# initial display using Feather CharlieWing LED 15 x 7
display = adafruit_is31fl3731.CharlieWing(i2c)
# uncomment next 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)
# initial display using Pimoroni Scroll Phat HD LED 17 x 7
# display = adafruit_is31fl3731.ScrollPhatHD(i2c)

# first load the frame with the arrows; moves the an_arrow to the right in each
# frame
display.sleep(True)  # turn display off while updating blink bits
display.fill(0)
for y in range(display.height):
    row = an_arrow[y]
    for x in range(8):
        bit = 1 << (7 - x) & row
        if bit:
            display.pixel(x + 4, y, 50, blink=True)

display.blink(1000)  # ranges from 270 to 2159; smaller the number to faster blink
display.sleep(False)  # turn display on
examples/is31fl3731_frame_example.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import time
import board
import busio
import adafruit_is31fl3731

i2c = busio.I2C(board.SCL, board.SDA)

# arrow pattern in bits; top row-> bottom row, 8 bits in each row
arrow = bytearray((0x08, 0x0C, 0xFE, 0xFF, 0xFE, 0x0C, 0x08, 0x00, 0x00))

# initial display using Feather CharlieWing LED 15 x 7
display = adafruit_is31fl3731.CharlieWing(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)
# initial display using Pimoroni Scroll Phat HD LED 17 x 7
# display = adafruit_is31fl3731.ScrollPhatHD(i2c)


# first load the frame with the arrows; moves the arrow to the right in each
# frame
display.sleep(True)  # turn display off while frames are updated
for frame in range(8):
    display.frame(frame, show=False)
    display.fill(0)
    for y in range(display.height):
        row = arrow[y]
        for x in range(8):
            bit = 1 << (7 - x) & row
            # display the pixel into selected frame with varying intensity
            if bit:
                display.pixel(x + frame, y, frame ** 2 + 1)
display.sleep(False)
# now tell the display to show the frame one at time
while True:
    for frame in range(8):
        display.frame(frame)
        time.sleep(0.1)
examples/is31fl3731_text_example.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import board
import busio
import adafruit_framebuf
import adafruit_is31fl3731


i2c = busio.I2C(board.SCL, board.SDA)

# initial display using Feather CharlieWing LED 15 x 7
# display = adafruit_is31fl3731.CharlieWing(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)
# initial display using Pimoroni Scroll Phat HD LED 17 x 7
# display = adafruit_is31fl3731.ScrollPhatHD(i2c)

text_to_show = "Adafruit!!"

# Create a framebuffer for our display
buf = bytearray(32)  # 2 bytes tall x 16 wide = 32 bytes (9 bits is 2 bytes)
fb = adafruit_framebuf.FrameBuffer(
    buf, display.width, display.height, adafruit_framebuf.MVLSB
)


frame = 0  # start with frame 0
while True:
    for i in range(len(text_to_show) * 9):
        fb.fill(0)
        fb.text(text_to_show, -i + display.width, 0, color=1)

        # to improve the display flicker we can use two frame
        # fill the next frame with scrolling text, then
        # show it.
        display.frame(frame, show=False)
        # turn all LEDs off
        display.fill(0)
        for x in range(display.width):
            # using the FrameBuffer text result
            bite = buf[x]
            for y in range(display.height):
                bit = 1 << y & bite
                # if bit > 0 then set the pixel brightness
                if bit:
                    display.pixel(x, y, 50)

        # now that the frame is filled, show it.
        display.frame(frame, show=True)
        frame = 0 if frame else 1
examples/is31fl3731_wave_example.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

import board
import busio
import adafruit_is31fl3731

i2c = busio.I2C(board.SCL, board.SDA)

sweep = [
    1,
    2,
    3,
    4,
    6,
    8,
    10,
    15,
    20,
    30,
    40,
    60,
    60,
    40,
    30,
    20,
    15,
    10,
    8,
    6,
    4,
    3,
    2,
    1,
]

frame = 0

# initialize display using Feather CharlieWing LED 15 x 7
display = adafruit_is31fl3731.CharlieWing(i2c)
# uncomment next line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
# display = adafruit_is31fl3731.Matrix(i2c)
# uncomment next line if you are using Adafruit 16x8 Charlieplexed Bonnet
# display = adafruit_is31fl3731.CharlieBonnet(i2c)
# initial display using Pimoroni Scroll Phat HD LED 17 x 7
# display = adafruit_is31fl3731.ScrollPhatHD(i2c)

while True:
    for incr in range(24):
        # to reduce update flicker, use two frames
        # make a frame active, don't show it yet
        display.frame(frame, show=False)
        # fill the display with the next frame
        for x in range(display.width):
            for y in range(display.height):
                display.pixel(x, y, sweep[(x + y + incr) % 24])
        # show the next frame
        display.frame(frame, show=True)
        if frame:
            frame = 0
        else:
            frame = 1

adafruit_is31fl3731

CircuitPython driver for the IS31FL3731 charlieplex IC.

  • Author(s): Tony DiCola, Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_is31fl3731.CharlieBonnet(i2c, address=116)[source]

Supports the Charlieplexed bonnet

static pixel_addr(x, y)[source]

Calulate the offset into the device array for x,y pixel

class adafruit_is31fl3731.CharlieWing(i2c, address=116)[source]

Supports the Charlieplexed feather wing

static pixel_addr(x, y)[source]

Calulate the offset into the device array for x,y pixel

class adafruit_is31fl3731.Keybow2040(i2c, address=116)[source]

Supports the Pimoroni Keybow 2040 with 4x4 matrix of RGB LEDs

static pixel_addr(x, y)[source]

Calulate the offset into the device array for x,y pixel

pixelrgb(x, y, r, g, b, blink=None, frame=None)[source]

Blink or brightness for x, y-pixel

Parameters:
  • x – horizontal pixel position
  • y – vertical pixel position
  • r – red brightness value 0->255
  • g – green brightness value 0->255
  • b – blue brightness value 0->255
  • blink – True to blink
  • frame – the frame to set the pixel
class adafruit_is31fl3731.LedShim(i2c, address=117)[source]

Supports the LED SHIM by Pimoroni

static pixel_addr(x, y)[source]

Translate an x,y coordinate to a pixel index.

pixelrgb(x, r, g, b, blink=None, frame=None)[source]

Blink or brightness for x-pixel

Parameters:
  • x – horizontal pixel position
  • r – red brightness value 0->255
  • g – green brightness value 0->255
  • b – blue brightness value 0->255
  • blink – True to blink
  • frame – the frame to set the pixel
class adafruit_is31fl3731.Matrix(i2c, address=116)[source]

The Matrix class support the main function for driving the 16x9 matrix Display

Parameters:
  • i2c_device (i2c_device) – the connected i2c bus i2c_device
  • address – the device address; defaults to 0x74
audio_play(sample_rate, audio_gain=0, agc_enable=False, agc_fast=False)[source]

Controls the audio play feature

audio_sync(value=None)[source]

Set the audio sync feature register

autoplay(delay=0, loops=0, frames=0)[source]

Start autoplay

Parameters:
  • delay – in ms
  • loops – number of loops - 0->7
  • frames – number of frames: 0->7

Updates the blink register

fade(fade_in=None, fade_out=None, pause=0)[source]

Start and stop the fade feature. If both fade_in and fade_out are None (the default), the breath feature is used for fading. if fade_in is None, then fade_in = fade_out. If fade_out is None, then fade_out = fade_in

Parameters:
  • fade_in – positive number; 0->100
  • fade-out – positive number; 0->100
  • pause – breath register 2 pause value
fill(color=None, blink=None, frame=None)[source]

Fill the display with a brightness level

Parameters:
  • color – brightness 0->255
  • blink – True if blinking is required
  • frame – which frame to fill 0->7
frame(frame=None, show=True)[source]

Set the current frame

Parameters:
  • frame – frame number; 0-7 or None. If None function returns current frame
  • show – True to show the frame; False to not show.
image(img, blink=None, frame=None)[source]

Set buffer to value of Python Imaging Library image. The image should be in 8-bit mode (L) and a size equal to the display size.

Parameters:
  • img – Python Imaging Library image
  • blink – True to blink
  • frame – the frame to set the image
pixel(x, y, color=None, blink=None, frame=None)[source]

Blink or brightness for x-, y-pixel

Parameters:
  • x – horizontal pixel position
  • y – vertical pixel position
  • color – brightness value 0->255
  • blink – True to blink
  • frame – the frame to set the pixel
static pixel_addr(x, y)[source]

Calulate the offset into the device array for x,y pixel

reset()[source]

Kill the display for 10MS

sleep(value)[source]

Set the Software Shutdown Register bit

Parameters:value – True to set software shutdown bit; False unset
class adafruit_is31fl3731.ScrollPhatHD(i2c, address=116)[source]

Supports the Scroll pHAT HD by Pimoroni

static pixel_addr(x, y)[source]

Translate an x,y coordinate to a pixel index.

Indices and tables