So gehts, falls das mal jemand braucht:
https://luma-led-matrix.readthedocs.io/en/latest/index.html
Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import time
import colorsys
from luma.led_matrix.device import neopixel, UNICORN_HAT
from luma.core.render import canvas
from luma.core.legacy import text, show_message
from luma.core.legacy.font import proportional, TINY_FONT, CP437_FONT, LCD_FONT, SINCLAIR_FONT
uuu_HAT_1x4 = [
7, 6, 5, 4, 3, 2, 1, 0, 71, 70, 69, 68, 67, 66, 65, 64, 135, 134, 133, 132, 131, 130, 129, 128, 199, 198, 197, 196, 195, 194, 193, 192,
8, 9, 10, 11, 12, 13, 14, 15, 72, 73, 74, 75, 76, 77, 78, 79, 136, 137, 138, 139, 140, 141, 142, 143, 200, 201, 202, 203, 204, 205, 206, 207,
23, 22, 21, 20, 19, 18, 17, 16, 87, 86, 85, 84, 83, 82, 81, 80, 151, 150, 149, 148, 147, 146, 145, 144, 215, 214, 213, 212, 211, 210, 209, 208,
24, 25, 26, 27, 28, 29, 30, 31, 88, 89, 90, 91, 92, 93, 94, 95, 152, 153, 154, 155, 156, 157, 158, 159, 216, 217, 218, 219, 220, 221, 222, 223,
39, 38, 37, 36, 35, 34, 33, 32, 103, 102, 101, 100, 99, 98, 97, 96, 167, 166, 165, 164, 163, 162, 161, 160, 231, 230, 229, 228, 227, 226, 225, 224,
40, 41, 42, 43, 44, 45, 46, 47, 104, 105, 106, 107, 108, 109, 110, 111, 168, 169, 170, 171, 172, 173, 174, 175, 232, 233, 234, 235, 236, 237, 238, 239,
55, 54, 53, 52, 51, 50, 49, 48, 119, 118, 117, 116, 115, 114, 113, 112, 183, 182, 181, 180, 179, 178, 177, 176, 247, 246, 245, 244, 243, 242, 241, 240,
56, 57, 58, 59, 60, 61, 62, 63, 120, 121, 122, 123, 124, 125, 126, 127, 184, 185, 186, 187, 188, 189, 190, 191, 248, 249, 250, 251, 252, 253, 254, 255
]
uuu_HAT_2x2 = [
7, 6, 5, 4, 3, 2, 1, 0, 71, 70, 69, 68, 67, 66, 65, 64,
8, 9, 10, 11, 12, 13, 14, 15, 72, 73, 74, 75, 76, 77, 78, 79,
23, 22, 21, 20, 19, 18, 17, 16, 87, 86, 85, 84, 83, 82, 81, 80,
24, 25, 26, 27, 28, 29, 30, 31, 88, 89, 90, 91, 92, 93, 94, 95,
39, 38, 37, 36, 35, 34, 33, 32, 103, 102, 101, 100, 99, 98, 97, 96,
40, 41, 42, 43, 44, 45, 46, 47, 104, 105, 106, 107, 108, 109, 110, 111,
55, 54, 53, 52, 51, 50, 49, 48, 119, 118, 117, 116, 115, 114, 113, 112,
56, 57, 58, 59, 60, 61, 62, 63, 120, 121, 122, 123, 124, 125, 126, 127,
135, 134, 133, 132, 131, 130, 129, 128, 199, 198, 197, 196, 195, 194, 193, 192,
136, 137, 138, 139, 140, 141, 142, 143, 200, 201, 202, 203, 204, 205, 206, 207,
151, 150, 149, 148, 147, 146, 145, 144, 215, 214, 213, 212, 211, 210, 209, 208,
152, 153, 154, 155, 156, 157, 158, 159, 216, 217, 218, 219, 220, 221, 222, 223,
167, 166, 165, 164, 163, 162, 161, 160, 231, 230, 229, 228, 227, 226, 225, 224,
168, 169, 170, 171, 172, 173, 174, 175, 232, 233, 234, 235, 236, 237, 238, 239,
183, 182, 181, 180, 179, 178, 177, 176, 247, 246, 245, 244, 243, 242, 241, 240,
184, 185, 186, 187, 188, 189, 190, 191, 248, 249, 250, 251, 252, 253, 254, 255
]
# create matrix device
#device = neopixel(width=16, height=16, mapping=uuu_HAT_2x2)
device = neopixel(width=32, height=8, mapping=uuu_HAT_1x4)
#msg = "Help me"
#show_message(device, msg, y_offset=1, fill="blue", font=proportional(TINY_FONT), scroll_delay=0.1)
#time.sleep(1)
while 1:
for x in range(99):
with canvas(device) as draw:
if x < 20:
draw.rectangle(device.bounding_box, outline="blue", fill="black")
text(draw, (2, 0), txt=str(x) + " ms", fill="green", font=proportional(SINCLAIR_FONT))
time.sleep(0.3)
elif x < 60:
draw.rectangle(device.bounding_box, outline="indigo", fill="black")
text(draw, (2, 0), txt=str(x) + " ms", fill="yellow", font=proportional(SINCLAIR_FONT))
time.sleep(0.3)
else:
draw.rectangle(device.bounding_box, outline="blue", fill="black")
text(draw, (2, 0), txt=str(x) + " ms", fill="red", font=proportional(SINCLAIR_FONT))
time.sleep(0.3)
Display More