Skip to content

LED animation fix duration None - #665

Closed
mvolfik wants to merge 5 commits into
ev3dev:ev3dev-stretchfrom
mvolfik:ev3dev-stretch
Closed

mvolfik wants to merge 5 commits into
ev3dev:ev3dev-stretchfrom
mvolfik:ev3dev-stretch

Conversation

@mvolfik

@mvolfik mvolfik commented Aug 23, 2019

Copy link
Copy Markdown
Contributor
  • allow passing duration=None to animate_police_lights to animate forever, as stated in docs
  • add animations reset to all_off, as without it the leds light up on the next animation cycle

According to docs, if you pass None to animate_police_lights, it should animate forever.

@WasabiFan WasabiFan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catches! One minor comment and then I'll merge. Thanks!

Comment thread ev3dev2/led.py Resolved
Comment thread ev3dev2/led.py Resolved
@WasabiFan

Copy link
Copy Markdown
Member

Two things, now that I look closer.

Most importantly, shouldn't this change be made to all the animations, not just police lights?

Second, can't we move the duration calculation to be within the if condition so we can eliminate the need for propagating None?

@mvolfik

mvolfik commented Aug 25, 2019 •

Copy link
Copy Markdown
Contributor Author

Most importantly, shouldn't this change be made to all the animations, not just police lights?

Oh, of course, I didn't notice this issue is in other functions too, I just came across this. when I used it. Will do it

Second, can't we move the duration calculation to be within the if condition so we can eliminate the need for propagating None?

Yeah, it will simplify the code, however we would calculate the same thing in every cycle. Not a big deal, but my IT teacher would bite me :). Just tell me what you prefer and I will do it the same way in every animation function...

@mvolfik

mvolfik commented Aug 25, 2019

Copy link
Copy Markdown
Contributor Author

Also shouldn't we issue warning/imply block=False/something when user tries to animate forever in main thread? Or that's responsibility we keep on the user?

@WasabiFan

Copy link
Copy Markdown
Member

Just tell me what you prefer and I will do it the same way in every animation function...

I figure this is probably a common use case for the Stopwatch anyway (checking if a time has elapsed) so I opened #667 to add such a method directly to the StopWatch. Once that is reviewed and merged you can use the new methods here. Sorry for making this take so long, we appreciate the contribution!

Also shouldn't we issue warning/imply block=False/something when user tries to animate forever in main thread? Or that's responsibility we keep on the user?

If it were clear-cut I might want to add such a warning, but consider this: in my main thread I spawn a new thread which runs my robot then my main thread just blocks running LEDs indefinetely. I'd say that's still valid (if a bit weird), so I'd prefer to just keep it simple here. If someone blocks their main thread unintentionally they'll either figure it out for themselves or ask for help and we can tell them.

@dwalton76 dwalton76 changed the title Leds fixes LED animation fix duration None Dec 26, 2019
@dwalton76 dwalton76 closed this Dec 29, 2019
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