Skip to content

Commit 4fdc2b7

Browse files
author
ladyada
committed
update frame demo to no context i2c, add bonnet
1 parent f6eb263 commit 4fdc2b7

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

examples/frame.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,35 @@
33
import busio
44
import adafruit_is31fl3731
55

6+
i2c = busio.I2C(board.SCL, board.SDA)
7+
68
# arrow pattern in bits; top row-> bottom row, 8 bits in each row
79
arrow = bytearray((0x08, 0x0c, 0xfe, 0xff, 0xfe, 0x0c, 0x08, 0x00, 0x00))
810

9-
with busio.I2C(board.SCL, board.SDA) as i2c:
10-
# initial display using Feather CharlieWing LED 15 x 7
11-
display = adafruit_is31fl3731.CharlieWing(i2c)
12-
# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
13-
#display = adafruit_is31fl3731.Matrix(i2c)
11+
# initial display using Feather CharlieWing LED 15 x 7
12+
display = adafruit_is31fl3731.CharlieWing(i2c)
13+
# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
14+
#display = adafruit_is31fl3731.Matrix(i2c)
15+
# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix
16+
#display = adafruit_is31fl3731.CharlieBonnet(i2c)
17+
1418

15-
# first load the frame with the arrows; moves the arrow to the right in each
16-
# frame
17-
display.sleep(True) # turn display off while frames are updated
19+
# first load the frame with the arrows; moves the arrow to the right in each
20+
# frame
21+
display.sleep(True) # turn display off while frames are updated
22+
for frame in range(8):
23+
display.frame(frame, show=False)
24+
display.fill(0)
25+
for y in range(display.height):
26+
row = arrow[y]
27+
for x in range(8):
28+
bit = 1 << (7-x) & row
29+
# display the pixel into selected frame with varying intensity
30+
if bit:
31+
display.pixel(x + frame, y, frame**2 + 1)
32+
display.sleep(False)
33+
# now tell the display to show the frame one at time
34+
while True:
1835
for frame in range(8):
19-
display.frame(frame, show=False)
20-
display.fill(0)
21-
for y in range(display.height):
22-
row = arrow[y]
23-
for x in range(8):
24-
bit = 1 << (7-x) & row
25-
# display the pixel into selected frame with varying intensity
26-
if bit:
27-
display.pixel(x + frame, y, frame**2 + 1)
28-
display.sleep(False)
29-
# now tell the display to show the frame one at time
30-
while True:
31-
for frame in range(8):
32-
display.frame(frame)
33-
time.sleep(.1)
36+
display.frame(frame)
37+
time.sleep(.1)

0 commit comments

Comments
 (0)