Skip to content

Conversation

PaintYourDragon
Copy link
Contributor

@PaintYourDragon PaintYourDragon commented Sep 21, 2021

This PR adds a buffering capability that can optionally be enabled via constructor. A “buffered” IS31FL3741 has LED PWM state stored in RAM, pushed to the chip only when show() is called. This can provide smoother and faster animation, in exchange for a little over 1/3 K of RAM, and having to periodically call show(). Inspired by similar additions to the Arduino version of this library.

This currently only covers the LED glasses. Support for the QT RGB matrix and the eval board will be added tomorrow, when I’ve had some time to test. (Edit: I think these pick up the change automatically, since there’s no extra constructor as with the glasses…still need to change imports to get those constants though.)

Default behavior is to work as originally written; LEDs are unbuffered. Enabling buffering requires some changes to import statements and arguments to constructors. See the LED glasses rings example.

import adafruit_is31fl3741
glasses = LED_Glasses(board.I2C(), allocate=adafruit_is31fl3741.MUST_BUFFER)
…
glasses.show()

The optional “allocate” argument can have one of three values, declared in adafruit_is31fl3741:

  • NO_BUFFER : LED data is NOT buffered; pixels are written with each drawing request. This is the default behavior if unspecified. show() can still be called but has no effect.
  • PREFER_BUFFER : LED data is buffered if RAM permits. If allocation fails, program continues with the LEDs unbuffered…not as smooth, but at least it’s running.
  • MUST_BUFFER : If the LED data can’t be buffered due to limited RAM, the constructor throws a MemoryError exception. “Go big or go home.”

Additionally, this fixes a small math error that caused the glasses rings example to have occasional speckles.

@github-actions
Copy link

👋 Thanks for this pull request! Unfortunately, it looks like the automated continuous integration (CI) test(s) failed. These can be tricky to fix so we've written a guide on how to fix them locally. It has pages about running pre-commit locally and another about building the docs locally with sphinx. Thanks for contributing to CircuitPython! If you have more questions, feel free to join the Adafruit Discord and post in #circuitpython-dev.

@ladyada
Copy link
Member

ladyada commented Sep 21, 2021

nice!

@PaintYourDragon PaintYourDragon merged commit be8931b into main Sep 21, 2021
@PaintYourDragon PaintYourDragon deleted the philb-buffer branch September 21, 2021 17:45
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Sep 22, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_AS7341 to 1.2.0 from 1.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_AS7341#19 from bjones14/main
  > Moved CI to Python 3.7
  > Added help text and problem matcher
  > Added pull request template

Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SH1107 to 1.4.1 from 1.4.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SH1107#10 from lesamouraipourpre/cpython
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SH1107#9 from lesamouraipourpre/multiplex

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP_ATcontrol to 0.5.7 from 0.5.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP_ATcontrol#41 from PontusO/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741 to 1.1.1 from 1.1.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_IS31FL3741#5 from adafruit/philb-bytes
  > Merge pull request adafruit/Adafruit_CircuitPython_IS31FL3741#3 from rhooper/grid
  > Merge pull request adafruit/Adafruit_CircuitPython_IS31FL3741#4 from adafruit/philb-buffer

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 8.1.0 from 8.0.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#135 from tannewt/connect_to_address

Updating https://github.com/adafruit/Adafruit_CircuitPython_MIDI to 1.4.3 from 1.4.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_MIDI#41 from EMATech/mtc

Updating https://github.com/adafruit/Adafruit_CircuitPython_PortalBase to 1.9.2 from 1.9.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#49 from makermelissa/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_UC8151D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants