Giter Site home page Giter Site logo

adafruit_circuitpython_is31fl3741's Introduction

Introduction

Documentation Status Discord Build Status Code Style: Black

CircuitPython driver for the IS31FL3741 RGB Matrix IC.

This driver supports the following hardware:

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-is31fl3741

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-is31fl3741

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-is31fl3741

Usage Example

Matrix:

from adafruit_is31fl3741.matrix import Matrix
import board
import busio
with busio.I2C(board.SCL, board.SDA) as i2c:
    display = Matrix(i2c)
    display.fill(127)

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

adafruit_circuitpython_is31fl3741's People

Contributors

dhalbert avatar djdevon3 avatar evaherrada avatar foamyguy avatar gamblor21 avatar jepler avatar jsymons avatar kattni avatar ladyada avatar paintyourdragon avatar prcutler avatar rhooper avatar tannewt avatar tekktrik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_circuitpython_is31fl3741's Issues

Two is31fl3741 boards in serial STEMMA crash on example code

I encouraged Discord user RichSad to write this up:

Two is31fl3741 boards in serial STEMMA crash on example code
https://forums.adafruit.com/viewtopic.php?f=60&t=184028

Quoted below:

First of all: The little is31fl3741 RGB LED 13x9 matrix is GORGEOUS! I am so happy I was able to grab two before they sold out for now.

I experienced a reproducible crash attempting to run two is31fl3741 with the two RGB Matrix boards in serial over STEMMA QT connector. I was using unmodified CircuitPython demo code from the learn guide with the slow rainbow color sweep. Devices are listed below. Problem is reproducible 100% of all listed devices. Note: using just one RGB Matrix the code appears to run fine on the same dev boards. Used two short 50mm STEMMA QT male to STEMMA QT male connectors. Tried demo with power over USB C and also with only power from a charged lipo battery.

In all cases with two matrixes in serial, the demo runs for 10 seconds or so (don't quote me on the exact time) and appears to work mirroring the actions on both matrix boards. Then it crashes and cause the mcu to restart (much like a soft reboot when a file is saved). Reproducible every time, with any combo mcu board and power option.

The example code runs fine with a single RGB Matrix board. When a second RGB Matrix is added in serial, the code appears to work at first mirroring the two the RGB Matrix boards. But after some number of seconds it crashes and the board reboots.

I tested this rainbow color sweep sample code from the learn guide on all the STEMMA QT-equipped dev boards I had handy: Adafruit Trinkey RP2040, Feather RP2040, SparkFun Thing Plus Lipo 2040, Pimoroni Pico Lipo 2040. All were running freshly flashed CircuitPython Version '7.0.0 on 2021-09-20'

This is not a critical issue for me. I was trying to wire two RGB Matrix boards in serial over STEMMA QT to see what happened. Code is below. Besides added import os and printing out os.uname() this is the demo from the Learn Guide at https://learn.adafruit.com/adafruit-is31fl3741/python-circuitpython

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import time
import busio
import board
import adafruit_is31fl3741
from random import randint
from rainbowio import colorwheel
from adafruit_is31fl3741.adafruit_rgbmatrixqt import Adafruit_RGBMatrixQT
import os

print(os.uname())

is31 = Adafruit_RGBMatrixQT(busio.I2C(board.SCL, board.SDA), allocate=adafruit_is31fl3741.PREFER_BUFFER)
is31.set_led_scaling(0xFF)
is31.global_current = 0xFF
is31.enable = True
wheeloffset = 0
while True:
    for y in range(9):
        for x in range(13):
            is31.pixel(x, y, colorwheel((y * 13 + x) * 2 + wheeloffset))
    wheeloffset += 1
    is31.show()

PIL typing annotation

Because pillow should be an optional import, it should be changed in the code to be optionally imported if possible.

native example has no attribute IS31FL3741_FrameBuffer'

Adafruit CircuitPython 8.0.5 on 2023-03-31; Adafruit Feather ESP32S2 with ESP32S2
Board ID:adafruit_feather_esp32s2

is31_fb = is31fl3741.IS31FL3741_FrameBuffer(

Was this supposed to be changed to pixelbuf? I see no mention in the library or examples of a reference to IS31FL3741_FrameBuffer.

is31_fb = adafruit_is31fl3741.IS31FL3741_FrameBuffer(
    width=54,
    height=15,
    is31=is31,
    scale=True,
    gamma=True,
    mapping=glassesmatrix_ledmap_no_ring,
)

AttributeError: 'module' object has no attribute 'IS31FL3741_FrameBuffer'

Missing Type Annotations

There are missing type annotations for some functions in this library.

The typing module does not exist on CircuitPython devices so the import needs to be wrapped in try/except to catch the error for missing import. There is an example of how that is done here:

try:
    from typing import List, Tuple
except ImportError:
    pass

Once imported the typing annotations for the argument type(s), and return type(s) can be added to the function signature. Here is an example of a function that has had this done already:

def wrap_text_to_pixels(
    string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
) -> List[str]:

If you are new to Git or Github we have a guide about contributing to our projects here: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github

There is also a guide that covers our CI utilities and how to run them locally to ensure they will pass in Github Actions here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code In particular the pages: Sharing docs on ReadTheDocs and Check your code with pre-commit contain the tools to install and commands to run locally to run the checks.

If you are attempting to resolve this issue and need help, you can post a comment on this issue and tag both @FoamyGuy and @kattni or reach out to us on Discord: https://adafru.it/discord in the #circuitpython-dev channel.

The following locations are reported by mypy to be missing type annotations:

  • adafruit_is31fl3741/__init__.py:79
  • adafruit_is31fl3741/__init__.py:106
  • adafruit_is31fl3741/__init__.py:127
  • adafruit_is31fl3741/__init__.py:138
  • adafruit_is31fl3741/__init__.py:148
  • adafruit_is31fl3741/__init__.py:157
  • adafruit_is31fl3741/__init__.py:175
  • adafruit_is31fl3741/__init__.py:196
  • adafruit_is31fl3741/__init__.py:201
  • adafruit_is31fl3741/__init__.py:223
  • adafruit_is31fl3741/issi_evb.py:40
  • adafruit_is31fl3741/adafruit_rgbmatrixqt.py:37
  • adafruit_is31fl3741/adafruit_ledglasses.py:86
  • adafruit_is31fl3741/adafruit_ledglasses.py:89
  • adafruit_is31fl3741/adafruit_ledglasses.py:98
  • adafruit_is31fl3741/adafruit_ledglasses.py:163
  • adafruit_is31fl3741/adafruit_ledglasses.py:166
  • adafruit_is31fl3741/adafruit_ledglasses.py:175
  • adafruit_is31fl3741/adafruit_ledglasses.py:377
  • adafruit_is31fl3741/adafruit_ledglasses.py:389

cannot use Adafruit_RGBMatrixQT with adafruit_led_animation

I wanted to use Adafruit_RGBMatrixQT to display some animations
adafruit_led_animation various animations expect a pixels object.
I wanted to use IS31FL3741_PixelBuf but it was missing the "write" method.
Please find below an adapter I wrote that allows to create a pixels object.
I would like to know:

  • is being able to create an adafruit_pixelbuf.PixelBuf from Adafruit_RGBMatrixQT is a valid need?
  • is an adapter such as the one below a relevant way to address this issue?

Thank you in advance for your feedback.

WIDTH = 13
HEIGHT = 9
LEDS_MAP = tuple(
    (
        address
        for x in range(WIDTH)
        for y in range(HEIGHT)
        for address in Adafruit_RGBMatrixQT.pixel_addrs(x, y)
    )
)


class RGBMatrixQTToPixelBufAdapter(Adafruit_RGBMatrixQT):
    """Additional properties so that Adafruit_RGBMatrixQT can be used with IS31FL3741_PixelBuf."""

    def __init__(
        self,
        i2c,
        allocate,
    ):
        super().__init__(i2c, allocate=allocate)

    def write(self, mapping, buffer):
        temp_buffer = FrameBuffer(
            buffer,
            WIDTH,
            HEIGHT,
            adafruit_framebuf.RGB888,
        )
        self.image(temp_buffer)
        self.show()


i2c = board.STEMMA_I2C()
is31 = RGBMatrixQTToPixelBufAdapter(i2c, allocate=adafruit_is31fl3741.PREFER_BUFFER)
# is31.set_led_scaling(0xFF)
is31.set_led_scaling(1)
is31.global_current = 0xFF
is31.enable = True
pixels = IS31FL3741_PixelBuf(is31, LEDS_MAP, init=False, auto_write=False)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.