示例#1
0
    def initialize(self):
        logger.info('Starting LED Matrix server...')

        _stop_shared.value = 0

        self.matrix = rgbmatrix.RGBMatrix(
            LED_MATRIX_CONF['rows'],
            LED_MATRIX_CONF['chain'],
            LED_MATRIX_CONF['parallel'],
        )
        self.matrix.pwmBits = LED_MATRIX_CONF['pwmbits']
        self.matrix.brightness = LED_MATRIX_CONF['brightness']

        if not LED_MATRIX_CONF['luminance_correction']:
            self.matrix.luminanceCorrect = False
import array

from rainbowio import colorwheel
import board
import displayio
import framebufferio
import rgbmatrix
import terminalio
displayio.release_displays()

matrix = rgbmatrix.RGBMatrix(
    width=64,
    height=32,
    bit_depth=3,
    rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12],
    addr_pins=[board.A5, board.A4, board.A3, board.A2],
    clock_pin=board.D13,
    latch_pin=board.D0,
    output_enable_pin=board.D1)
display = framebufferio.FramebufferDisplay(matrix, auto_refresh=False)


# Create a tilegrid with a bunch of common settings
def tilegrid(palette):
    return displayio.TileGrid(bitmap=terminalio.FONT.bitmap,
                              pixel_shader=palette,
                              width=1,
                              height=1,
                              tile_width=6,
                              tile_height=14,
示例#3
0
# a single 128x64 pixel display -- two matrices across, two down, with the
# second row being flipped. width and height args are the combined size of
# all the tiled sub-matrices. tile arg is the number of rows of matrices in
# the chain (horizontal tiling is implicit from the width argument, doesn't
# need to be specified, but vertical tiling must be explicitly stated).
# The serpentine argument indicates whether alternate rows are flipped --
# cabling is easier this way, downside is colors may be slightly different
# when viewed off-angle. bit_depth and pins are same as other examples.
MATRIX = rgbmatrix.RGBMatrix(width=128,
                             height=64,
                             bit_depth=6,
                             tile=2,
                             serpentine=True,
                             rgb_pins=[
                                 board.MTX_R1, board.MTX_G1, board.MTX_B1,
                                 board.MTX_R2, board.MTX_G2, board.MTX_B2
                             ],
                             addr_pins=[
                                 board.MTX_ADDRA, board.MTX_ADDRB,
                                 board.MTX_ADDRC, board.MTX_ADDRD
                             ],
                             clock_pin=board.MTX_CLK,
                             latch_pin=board.MTX_LAT,
                             output_enable_pin=board.MTX_OE)

# Associate matrix with a Display to use displayio features
DISPLAY = framebufferio.FramebufferDisplay(MATRIX,
                                           auto_refresh=False,
                                           rotation=0)

# Load BMP image, create Group and TileGrid to hold it
FILENAME = "wales.bmp"
示例#4
0
    def __init__(self,
                 *,
                 width=64,
                 height=32,
                 bit_depth=2,
                 alt_addr_pins=None,
                 color_order="RGB"):

        if not isinstance(color_order, str):
            raise ValueError("color_index should be a string")
        color_order = color_order.lower()
        red_index = color_order.find("r")
        green_index = color_order.find("g")
        blue_index = color_order.find("b")
        if -1 in (red_index, green_index, blue_index):
            raise ValueError("color_order should contain R, G, and B")

        if "Matrix Portal M4" in os.uname().machine:
            # MatrixPortal M4 Board
            addr_pins = [board.MTX_ADDRA, board.MTX_ADDRB, board.MTX_ADDRC]
            if height > 16:
                addr_pins.append(board.MTX_ADDRD)
            if height > 32:
                addr_pins.append(board.MTX_ADDRE)
            rgb_pins = [
                board.MTX_R1,
                board.MTX_G1,
                board.MTX_B1,
                board.MTX_R2,
                board.MTX_G2,
                board.MTX_B2,
            ]
            clock_pin = board.MTX_CLK
            latch_pin = board.MTX_LAT
            oe_pin = board.MTX_OE
        elif "Feather" in os.uname().machine:
            # Feather Style Board
            if "nrf52" in os.uname().sysname:
                # nrf52840 Style Feather
                addr_pins = [board.D11, board.D5, board.D13]
                if height > 16:
                    addr_pins.append(board.D9)
                rgb_pins = [
                    board.D6, board.A5, board.A1, board.A0, board.A4, board.D11
                ]
                clock_pin = board.D12
            else:
                addr_pins = [board.A5, board.A4, board.A3]
                if height > 16:
                    addr_pins.append(board.A2)
                rgb_pins = [
                    board.D6,
                    board.D5,
                    board.D9,
                    board.D11,
                    board.D10,
                    board.D12,
                ]
                clock_pin = board.D13
            latch_pin = board.D0
            oe_pin = board.D1
        else:
            # Metro/Grand Central Style Board
            if alt_addr_pins is None and height <= 16:
                raise RuntimeError(
                    "Pin A2 unavailable in this mode. Please specify alt_addr_pins."
                )
            addr_pins = [board.A0, board.A1, board.A2, board.A3]
            rgb_pins = [
                board.D2, board.D3, board.D4, board.D5, board.D6, board.D7
            ]
            clock_pin = board.A4
            latch_pin = board.D10
            oe_pin = board.D9

        # Alternate Address Pins
        if alt_addr_pins is not None:
            addr_pins = alt_addr_pins

        try:
            displayio.release_displays()
            matrix = rgbmatrix.RGBMatrix(
                width=width,
                height=height,
                bit_depth=bit_depth,
                rgb_pins=(
                    rgb_pins[red_index],
                    rgb_pins[green_index],
                    rgb_pins[blue_index],
                    rgb_pins[red_index + 3],
                    rgb_pins[green_index + 3],
                    rgb_pins[blue_index + 3],
                ),
                addr_pins=addr_pins,
                clock_pin=clock_pin,
                latch_pin=latch_pin,
                output_enable_pin=oe_pin,
            )
            self.display = framebufferio.FramebufferDisplay(matrix)
        except ValueError:
            raise RuntimeError(
                "Failed to initialize RGB Matrix") from ValueError
示例#5
0
import adafruit_display_text.label
import board
import displayio
import framebufferio
import rgbmatrix
import terminalio

# Delete previous display
displayio.release_displays()
matrix = rgbmatrix.RGBMatrix(width=64,
                             bit_depth=4,
                             rgb_pins=[
                                 board.MTX_R1, board.MTX_G1, board.MTX_B1,
                                 board.MTX_R2, board.MTX_G2, board.MTX_B2
                             ],
                             addr_pins=[
                                 board.MTX_ADDRA, board.MTX_ADDRB,
                                 board.MTX_ADDRC, board.MTX_ADDRD
                             ],
                             clock_pin=board.MTX_CLK,
                             latch_pin=board.MTX_LAT,
                             output_enable_pin=board.MTX_OE)
display = framebufferio.FramebufferDisplay(matrix, auto_refresh=True)


def addLabel(arr, clr, txt):
    arr.append(
        adafruit_display_text.label.Label(terminalio.FONT, color=clr,
                                          text=txt))

示例#6
0
 def __init__(self):
     options = m.RGBMatrixOptions()
     options.chain_length = settings.get("ticker_display_chain_length")
     options.show_refresh_rate = 1
     self.matrix = m.RGBMatrix(options=options)
     self.run()
示例#7
0
import rgbmatrix
from led_matrix import configuration
from led_matrix.views import View, ColorView, TimeView, ApiView, SequenceView
from led_matrix.data_sources import *

matrix = rgbmatrix.RGBMatrix(options=configuration.matrix_options)
canvas = matrix.CreateFrameCanvas()

home = configuration.HomeOptions
user_view: View = None
default_view = ColorView('#000000')

if home.enabled:
    views = []
    if home.show_weather:
        views.append(ApiView(WeatherApi(), font_name='7x13B'))
    if home.show_time:
        views.append(TimeView())
    if home.show_news:
        views.append(
            ApiView(NewsApi(), font_name='helvR12', color_hex='#FF0028'))
    if len(views) > 0:
        default_view = SequenceView(views)


async def start_driver():
    global user_view, default_view, canvas

    try:
        print("Main Loop Started.")
        while True:
import time
from math import sin
import board
import displayio
import rgbmatrix
import framebufferio
import adafruit_imageload
import terminalio
from adafruit_display_text.label import Label

displayio.release_displays()
matrix = rgbmatrix.RGBMatrix(
    width=64,
    bit_depth=6,
    rgb_pins=[board.D6, board.D5, board.D9, board.D11, board.D10, board.D12],
    addr_pins=[board.D25, board.D24, board.A3, board.A2],
    clock_pin=board.D13,
    latch_pin=board.D0,
    output_enable_pin=board.D1,
    doublebuffer=True)
display = framebufferio.FramebufferDisplay(matrix, auto_refresh=False)

g = displayio.Group()
b, p = adafruit_imageload.load("pi-logo32b.bmp")
t = displayio.TileGrid(b, pixel_shader=p)
t.x = 20
g.append(t)

l = Label(text="Feather\nRP2040",
          font=terminalio.FONT,
          color=0xffffff,
                             "f87858", "fca044", "f8b800", "b8f818", "58d854", "58f898",
                             "00e8d8", "787878", "000000", "000000"],
                            ["fcfcfc", "a4e4fc", "b8b8f8", "d8b8f8", "f8b8f8", "f8a4c0",
                             "f0d0b0", "fce0a8", "f8d878", "d8f878", "b8f8b8", "b8f8d8",
                             "00fcfc", "f8d8f8", "000000", "000000"]], dtype='<U6')


# Configure the rgbmatrix library for the 32 x 32 LED display
options = rgb.RGBMatrixOptions()
options.rows = 32
options.cols = 32
options.brightness = 50
options.chain_length = 1
options.parallel = 1
options.hardware_mapping = "adafruit-hat"
options.disable_hardware_pulsing = False

dispmatrix = rgb.RGBMatrix(options=options)

# Define animation settings tuple
animation_settings = namedtuple("animation_settings", ("sprite_list "  
                                                       "bg_sprites "
                                                       "xoffs "
                                                       "yoffs "
                                                       "frame_time "
                                                       "spbg_ratio "
                                                       "center "
                                                       "bg_scroll_speed "
                                                       "cycles_per_char "
                                                       "reversible"))
示例#10
0
#!/usr/bin/env python3

from PIL import Image, ImageFont, ImageDraw

import time
# from https://stackoverflow.com/a/6209894/5728815
import inspect
import os
filename = inspect.getframeinfo(inspect.currentframe()).filename
#path = os.path.dirname(os.path.abspath(filename))
path = "/tmp"
import rgbmatrix
options = rgbmatrix.RGBMatrixOptions()
options.rows = 64
options.cols = 64
options.hardware_mapping = "adafruit-hat-pwm"
matrix = rgbmatrix.RGBMatrix(options=options)


def show():
    #print("show()")
    img = Image.open(path + "/image.png")
    img = img.convert('RGB')
    matrix.SetImage(img)


while True:
    show()
    time.sleep(1)