Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tween() without start parameter non-linear fade #22

Closed
rowlap opened this issue Nov 2, 2019 · 2 comments
Closed

tween() without start parameter non-linear fade #22

rowlap opened this issue Nov 2, 2019 · 2 comments

Comments

@rowlap
Copy link
Contributor

rowlap commented Nov 2, 2019

start is an optional parameter to tween(), with the documented default of "the current state".

The problem is the implementation literally assigns a reference to the _values list, without taking a copy. As such, when _values changes during the loop, so does start as they refer to the same list.

Link to code at time of writing.

Steps to reproduce:

from piglow import tween

for _ in range(3):
    tween(2.0, [255] * 18)
    tween(2.0, [0] * 18)

for _ in range(3):
    tween(2.0, start=[0]*18, end=[255]*18)
    tween(2.0, start=[255]*18, end=[0]*18)

What happened:
In the first loop, LEDs fade in/out much faster than the second loop.

What's expected:
Both loops give the same result.

@rowlap rowlap mentioned this issue Nov 3, 2019
@Gadgetoid
Copy link
Member

I wish every issue was this detailed and descriptive. Thank you for reporting and subsequently fixing this.

@Gadgetoid
Copy link
Member

Published in release v1.2.5 - https://github.com/pimoroni/piglow/releases/tag/v1.2.5

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

No branches or pull requests

2 participants