|
1 | 1 | import board
|
2 | 2 | import busio
|
3 |
| -import framebuf |
| 3 | +import adafruit_framebuf |
4 | 4 | import adafruit_is31fl3731
|
5 | 5 |
|
6 |
| -buf = bytearray(32) |
7 |
| - |
8 |
| -with busio.I2C(board.SCL, board.SDA) as i2c: |
9 |
| - # initial display using Feather CharlieWing LED 15 x 7 |
10 |
| - display = adafruit_is31fl3731.CharlieWing(i2c) |
11 |
| - # uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix |
12 |
| - #display = adafruit_is31fl3731.Matrix(i2c) |
13 |
| - |
14 |
| - fb = framebuf.FrameBuffer(buf, display.width, display.height, framebuf.MONO_VLSB) |
15 |
| - text_to_show = "Adafruit!!" |
16 |
| - frame = 0 # start with frame 0 |
17 |
| - while True: |
18 |
| - for i in range(len(text_to_show) * 9): |
19 |
| - fb.fill(0) |
20 |
| - fb.text(text_to_show, -i + display.width, 0) |
21 |
| - |
22 |
| - # to improve the display flicker we can use two frame |
23 |
| - # fill the next frame with scrolling text, then |
24 |
| - # show it. |
25 |
| - display.frame(frame, show=False) |
26 |
| - # turn all LEDs off |
27 |
| - display.fill(0) |
28 |
| - for x in range(display.width): |
29 |
| - # using the FrameBuffer text result |
30 |
| - bite = buf[x] |
31 |
| - for y in range(display.height): |
32 |
| - bit = 1 << y & bite |
33 |
| - # if bit > 0 then set the pixel brightness |
34 |
| - if bit: |
35 |
| - display.pixel(x, y, 50) |
36 |
| - |
37 |
| - # now that the frame is filled, show it. |
38 |
| - display.frame(frame, show=True) |
39 |
| - frame = 0 if frame else 1 |
| 6 | + |
| 7 | +i2c = busio.I2C(board.SCL, board.SDA) |
| 8 | + |
| 9 | +# initial display using Feather CharlieWing LED 15 x 7 |
| 10 | +#display = adafruit_is31fl3731.CharlieWing(i2c) |
| 11 | +# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix |
| 12 | +#display = adafruit_is31fl3731.Matrix(i2c) |
| 13 | +# uncomment line if you are using Adafruit 16x9 Charlieplexed PWM LED Matrix |
| 14 | +display = adafruit_is31fl3731.CharlieBonnet(i2c) |
| 15 | + |
| 16 | +text_to_show = "Adafruit!!" |
| 17 | + |
| 18 | +# Create a framebuffer for our display |
| 19 | +buf = bytearray(32) # 2 bytes tall x 16 wide = 32 bytes (9 bits is 2 bytes) |
| 20 | +fb = adafruit_framebuf.FrameBuffer(buf, display.width, display.height, adafruit_framebuf.MVLSB) |
| 21 | + |
| 22 | + |
| 23 | +frame = 0 # start with frame 0 |
| 24 | +while True: |
| 25 | + for i in range(len(text_to_show) * 9): |
| 26 | + fb.fill(0) |
| 27 | + fb.text(text_to_show, -i + display.width, 0, color=1) |
| 28 | + |
| 29 | + # to improve the display flicker we can use two frame |
| 30 | + # fill the next frame with scrolling text, then |
| 31 | + # show it. |
| 32 | + display.frame(frame, show=False) |
| 33 | + # turn all LEDs off |
| 34 | + display.fill(0) |
| 35 | + for x in range(display.width): |
| 36 | + # using the FrameBuffer text result |
| 37 | + bite = buf[x] |
| 38 | + for y in range(display.height): |
| 39 | + bit = 1 << y & bite |
| 40 | + # if bit > 0 then set the pixel brightness |
| 41 | + if bit: |
| 42 | + display.pixel(x, y, 50) |
| 43 | + |
| 44 | + # now that the frame is filled, show it. |
| 45 | + display.frame(frame, show=True) |
| 46 | + frame = 0 if frame else 1 |
0 commit comments