Skip to content

Add support for the charlie bonnet #13

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 9 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 13 additions & 0 deletions adafruit_is31fl3731.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,16 @@ def pixel_addr(x, y):
else:
y = 7 - y
return x * 16 + y


class CharlieBonnet(Matrix):
"""Supports the Charlieplexed bonnet"""
width = 16
height = 8

@staticmethod
def pixel_addr(x, y):
"""Calulate the offset into the device array for x,y pixel"""
if x >= 8:
return (x-6) * 16 - (y + 1)
return (x+1) * 16 + (7 - y)
32 changes: 18 additions & 14 deletions examples/is31fl3731_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
import busio
import adafruit_is31fl3731

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

with busio.I2C(board.SCL, board.SDA) as i2c:
# 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)
# initialize display using Feather CharlieWing LED 15 x 7
display = adafruit_is31fl3731.CharlieWing(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)
# 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)

# 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)
40 changes: 23 additions & 17 deletions examples/wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@
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
with busio.I2C(board.SCL, board.SDA) as i2c:
# 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)

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)
frame = 0 if frame else 1
# 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)

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