Adafruit_CircuitPython_LED_Animation icon indicating copy to clipboard operation
Adafruit_CircuitPython_LED_Animation copied to clipboard

Add min and max_intensity feature back to Pulse animation

Open rdagger opened this issue 5 years ago • 4 comments

After upgrading to the latest Circuit Python Bundle (circuitpython-bundle-5.x-mpy-20200621), I'm getting the following error with the adafruit_led_animation library on the Feather nRF52840 Express: File "code.py", line 7, in TypeError: 'module' object is not callable Here is a sample program to reproduce the error:

from adafruit_led_animation.animation import Pulse, Solid
import adafruit_led_animation.color as color
from neopixel import NeoPixel
from time import sleep
from board import NEOPIXEL
pixel = NeoPixel(NEOPIXEL, 1)
solid = Solid(pixel, color.GREEN)  # THIS LINE THROWS THE ERROR
solid.animate()  
sleep(4)

The code works with circuitpython-bundle-5.x-mpy-20200516 The code stops working with circuitpython-bundle-5.x-mpy-20200518

I'm running CircuitPython 5.4.0-beta.1-43-g1504d9005 on 2020-06-22; on Feather nRF52840 Express.

rdagger avatar Jun 22 '20 21:06 rdagger

Looks like it was 2.0.0 that was included. The notes are here: https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation/releases/2.0.0

Here is an example change: https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation/commit/cbfa114e7d104a6757d3ab749153d1b284a9c8c2#diff-879798843e31cea6b37d583453edd26f

It looks like you may need to modify the first import for another level of abstraction.

tannewt avatar Jun 22 '20 22:06 tannewt

Thanks that worked! Unfortunately, it looks like the min_intensity and max_intensity parameters have been removed from the Pulse animation. Any chance of getting those back? It really helps to dial in a smooth LED pulse.

class Pulse(Animation):
    """
    Pulse all pixels a single color.
    :param pixel_object: The initialised LED object.
    :param int speed: Animation refresh rate in seconds, e.g. ``0.1``.
    :param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
    :param period: Period to pulse the LEDs over.  Default 5.
    :param max_intensity: The maximum intensity to pulse, between 0 and 1.0.  Default 1.
    :param min_intensity: The minimum intensity to pulse, between 0 and 1.0.  Default 0.
    """


class Pulse(Animation):
    """
    Pulse all pixels a single color.
    :param pixel_object: The initialised LED object.
    :param float speed: Animation refresh rate in seconds, e.g. ``0.1``.
    :param color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
    :param period: Period to pulse the LEDs over.  Default 5.
    """

rdagger avatar Jun 23 '20 01:06 rdagger

Also the min_intensity and max_intensity parameters are still present in the SparklePulse animation but don't appear to be wired up.

rdagger avatar Jun 23 '20 07:06 rdagger

Good catch on SparklePulse.

Restoring min/max intensity shouldn't be difficult.

With regards to the import issue, I'd love to add backward compatibility for imports, but will need to test see how that affects memory use.

rhooper avatar Jun 26 '20 22:06 rhooper

Resolved #116

FoamyGuy avatar Dec 20 '24 23:12 FoamyGuy