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

Update output_devices.py #1003

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Conversation

tinitaet
Copy link

Add a "fade_to()" function to the PWMOutputDevice class as well as a mod RGBLED. It uses the same blink thread as the blink function to not interfere with existing scripts.
This function takes a fade_time in seconds and fades the value/color from a start value (default: the given value at the moment) to an end value.

Added a "fade_to()" function to the PWMOutputDevice class as well as a mod RGBLED. It uses the same blink thread as the blink function to not interfere with existing scripts.
This function takes a fade_time in seconds and fades the value/color from a start value (default: the given value at the moment) to an end value.
@tinitaet tinitaet marked this pull request as ready for review October 17, 2021 12:08
gpiozero/output_devices.py Outdated Show resolved Hide resolved
Add missing colon
fix arithmetic error and typing error
Add a cycle_color() function to RGBLED to rotate the Hue. Can accept clockwise as well as anticlockwise rotation, different speeds and number of rotations. Can start on current value or can be given starting color.
Add RGBLED.cycle_color()
gpiozero/output_devices.py Outdated Show resolved Hide resolved
gpiozero/output_devices.py Outdated Show resolved Hide resolved
gpiozero/output_devices.py Outdated Show resolved Hide resolved
gpiozero/output_devices.py Outdated Show resolved Hide resolved
docs/api_output.rst Outdated Show resolved Hide resolved
@tinitaet
Copy link
Author

tinitaet commented Oct 20, 2021

So far:
Add fade_to(self, fade_time=1, start_value=None, end_value=1, background=True) to PWMOutputDevice
Add fade_to(self, fade_time=1, start_color=None, end_color=(1,1,1), background=True) to RGBLED
Add cycle_color(self, cycle_time=10, start_color=None, clockwise=True, n=None, background=True) to RGBLED
Everything uses the _blink_thread to be consistent with working threading.
Code is operational and tested for usual parameters and foreseeable misuse.

@lurch
Copy link
Contributor

lurch commented Oct 21, 2021

I think if the RGBLED is currently off (i.e. current colour is black), and you call rgbled.cycle_color() then the LED won't appear to actually do anything? I can imagine that might confuse some people, so perhaps it's worth warning about that in the docstring? 🤷
(And I assume you meant "Add cycle_color ... to RGBLED" in your last comment?)

@tinitaet
Copy link
Author

tinitaet commented Oct 21, 2021

Good Point!
How about something in the means of "Caution: Only the hue parameter will change. This means, that the luminescence will stay the same, so white will stay white and black will stay black. For best (i.e. most colorful) results, use a pure color as a starting value."

Yes, I meant RGBLED and changed it… thanks for the reply 😅

gpiozero/output_devices.py Outdated Show resolved Hide resolved
@lurch
Copy link
Contributor

lurch commented Oct 21, 2021

I was going to ask "Will most people know what 'luminescence' even means?", but if you're linking to a wikipedia article that hopefully sufficiently explains things.
Just a minor point, but perhaps it's worth clarifying what you wrote slightly to "so full-white will stay white and black (i.e. off) will stay black" ?

@lurch
Copy link
Contributor

lurch commented Oct 21, 2021

Yes, I meant RGBLED and changed it…

Cool... slightly ironic that you mentioned "better description of pwmled.cycle_color()" in your commit-message 🤣

@tinitaet
Copy link
Author

tinitaet commented Oct 21, 2021

Yes, I meant RGBLED and changed it…

Cool... slightly ironic that you mentioned "better description of pwmled.cycle_color()" in your commit-message rofl

True… ^^ I start to get the impression that the documentation to explain, what this function does, is more trouble than the function itself.

@lurch
Copy link
Contributor

lurch commented Oct 21, 2021

Sorry, please forgive my pickiness!

Comment on lines 1187 to 1188
the same, so full white (1,1,1) will stay white and black (i.e. off) will stay black.
For best (i.e. most colorful) results, use a pure color (e.g. (1,0,0) ) as a starting value.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Although perhaps the tuple-values here should be in backticks? 🤔

@tinitaet
Copy link
Author

Sorry, please forgive my pickiness!

No worry, I am not offended, but rather glad for the response. Otherwise some stuff might slip through and I want do do the best I can.

gpiozero/output_devices.py Outdated Show resolved Hide resolved
gpiozero/output_devices.py Outdated Show resolved Hide resolved
@NBoumakis
Copy link

Hello! It's been a while, but is this getting merged at some point? I too would like the provided functionality, hopefully without reinventing the wheel.

Thanks

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.

None yet

3 participants