|
| 1 | +import array |
| 2 | + |
| 3 | +from _pixelbuf import wheel |
| 4 | +import board |
| 5 | +import displayio |
| 6 | +import framebufferio |
| 7 | +import rgbmatrix |
| 8 | +import terminalio |
| 9 | +displayio.release_displays() |
| 10 | + |
| 11 | +matrix = rgbmatrix.RGBMatrix( |
| 12 | + width=64, height=32, bit_depth=3, |
| 13 | + rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12], |
| 14 | + addr_pins=[board.A5, board.A4, board.A3, board.A2], |
| 15 | + clock_pin=board.D13, latch_pin=board.D0, output_enable_pin=board.D1) |
| 16 | +display = framebufferio.FramebufferDisplay(matrix, auto_refresh=False) |
| 17 | + |
| 18 | +def tilegrid(palette): |
| 19 | + return displayio.TileGrid( |
| 20 | + bitmap=terminalio.FONT.bitmap, pixel_shader=palette, |
| 21 | + width=1, height=1, tile_width=6, tile_height=14, default_tile=32) |
| 22 | + |
| 23 | +g = displayio.Group(max_size=2) |
| 24 | +linelen = (64//7)+2 |
| 25 | +l1 = displayio.Group(max_size=linelen) |
| 26 | +l2 = displayio.Group(max_size=linelen) |
| 27 | +g.append(l1) |
| 28 | +g.append(l2) |
| 29 | +display.show(g) |
| 30 | + |
| 31 | +l1.y = 1 |
| 32 | +l2.y = 16 |
| 33 | + |
| 34 | +sh = [displayio.Palette(2) for _ in range(linelen)] |
| 35 | +tg1 = [tilegrid(shi) for shi in sh] |
| 36 | +tg2 = [tilegrid(shi) for shi in sh] |
| 37 | + |
| 38 | +charmap = array.array('b', [terminalio.FONT.get_glyph(32).tile_index]) * 256 |
| 39 | +for ch in range(256): |
| 40 | + glyph = terminalio.FONT.get_glyph(ch) |
| 41 | + if glyph is not None: |
| 42 | + charmap[ch] = glyph.tile_index |
| 43 | + |
| 44 | +for idx, gi in enumerate(tg1): |
| 45 | + gi.x = 7 * idx |
| 46 | + l1.append(gi) |
| 47 | + |
| 48 | +for idx, gi in enumerate(tg2): |
| 49 | + gi.x = 7 * idx |
| 50 | + l2.append(gi) |
| 51 | + |
| 52 | +lines = [ |
| 53 | + b"This scroller is brought to you by CircuitPython & PROTOMATTER", |
| 54 | + b" .... . .-.. .-.. --- / .--. .-. --- - --- -- .- - - . .-.", |
| 55 | + b"Greetz to ... @PaintYourDragon @v923z @adafruit ", |
| 56 | + b" @danh @ladyada @kattni @tannewt all showers & tellers", |
| 57 | + b"New York Strong Wash Your Hands ", |
| 58 | + b" Flatten the curve Stronger Together", |
| 59 | +] |
| 60 | + |
| 61 | +even_lines = lines[0::2] |
| 62 | +odd_lines = lines[1::2] |
| 63 | + |
| 64 | +def scroll(t, b): |
| 65 | + sp = b' ' * linelen |
| 66 | + t = sp + t + sp |
| 67 | + b = sp + b + sp |
| 68 | + maxlen = max(len(t), len(b)) |
| 69 | + for i in range(maxlen-linelen): |
| 70 | + for j in range(linelen): |
| 71 | + sh[j][1] = wheel(3 * (2*i+j)) |
| 72 | + tg1[j][0] = charmap[t[i+j]] |
| 73 | + tg2[j][0] = charmap[b[i+j]] |
| 74 | + for j in range(7): |
| 75 | + l1.x = -j |
| 76 | + l2.x = -j |
| 77 | + display.refresh(minimum_frames_per_second=0) |
| 78 | + #display.refresh(minimum_frames_per_second=0) |
| 79 | + |
| 80 | +while True: |
| 81 | + for e, o in zip(even_lines, odd_lines): |
| 82 | + scroll(e, o) |
0 commit comments