code.py
1 # SPDX-FileCopyrightText: Copyright (c) 2022 Jeff Epler for Adafruit Industries 2 # 3 # SPDX-License-Identifier: Unlicense 4 import time 5 import board 6 import neopixel 7 from adafruit_display_text.bitmap_label import Label 8 from adafruit_bitmap_font import bitmap_font 9 from displayio import Bitmap 10 from rainbowio import colorwheel 11 12 font = bitmap_font.load_font("tom-thumb.pcf", Bitmap) 13 label = Label(text="Hello World!! Adafruit QT Py RP2040 + NeoPixel BFF ", font=font) 14 bitmap = label.bitmap 15 16 pixels = neopixel.NeoPixel(board.A3, 5*5, brightness=.07, auto_write=False) 17 pixels.fill(0) 18 pixels.show() 19 colors = [0, 0] 20 hue = 0 21 while True: 22 for i in range(bitmap.width): 23 # Use a rainbow of colors, shifting each column of pixels 24 hue = hue + 7 25 if hue >= 256: 26 hue = hue - 256 27 28 colors[1] = colorwheel(hue) 29 # Scoot the old text left by 1 pixel 30 pixels[0:20] = pixels[5:25] 31 32 # Draw in the next line of text 33 for y in range(5): 34 # Select black or color depending on the bitmap pixel 35 pixels[20+y] = colors[bitmap[i,y]] 36 pixels.show() 37 time.sleep(.1)