Skip to content

Conversation

@kattni
Copy link
Contributor

@kattni kattni commented Feb 8, 2022

Tested on ItsyBitsy M4.

@kattni kattni requested a review from a team February 8, 2022 17:59
@kattni kattni changed the title Dotstar template Add/update DotStar single LED template code Feb 8, 2022
@PaintYourDragon
Copy link
Contributor

With a single LED and with auto_write being the default case, would it be OK to replace:

        for led in range(1):
             dot_index = (led * 256 // 1) + color_value
             dot[led] = colorwheel(dot_index & 255)
         dot.show()

with:

        dot[0] = colorwheel(color_value)

?

Sometimes there’s Learning Value in showing things the verbose way, so no worries if that was the intent.

@kattni
Copy link
Contributor Author

kattni commented Feb 8, 2022

@PaintYourDragon Ooh, this is good. I don't need it to be verbose. I will need to update the copy to match it, but it means less copy. In this case, it's simply meant to give rainbows, not necessarily explain how rainbows work deep down. To be clear, you're saying the function should look like this? Or am I missing part of your suggestion?

def rainbow(delay):
    for color_value in range(255):
        dot[0] = colorwheel(color_value)
        dot.show()
        time.sleep(delay)

This does work, but you might have meant something slightly different that could be better.

@PaintYourDragon
Copy link
Contributor

Yep. All the math just distills down to nothing in that case and color_value can be passed straight to colorwheel. And the show() call might be redundant.

@kattni
Copy link
Contributor Author

kattni commented Feb 8, 2022

Wait - I just figured out what I was missing. I never set auto_write=False. Removing the show()!

@TheKitty TheKitty merged commit 87d0714 into adafruit:main Feb 8, 2022
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.

3 participants