Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Feature Request: Create global brightness slider in UI #23

Open
tristndev opened this issue Nov 20, 2019 · 7 comments
Open

Feature Request: Create global brightness slider in UI #23

tristndev opened this issue Nov 20, 2019 · 7 comments
Labels
discussion enhancement New feature or request

Comments

@tristndev
Copy link
Contributor

Hi all,

Since I didn't find another space for feature requests, I'm just posting here. Please feel free to label the "issue" accordingly.

On the webpage there is already a top part that is constantly shown (showing the connection status, fade time, turn on / off button).

I think it would make much sense to integrate a global brightness setting there to control the brightness of the lamp regardless which mode it is in. What do you think?

Just as a future feature for the backlog. ;)

@LarsMichelsen
Copy link
Collaborator

Seems like the most wished feature :-) I also want to have this.

Have a look here for the maintainers thoughts: #9 (comment)

@thebigpotatoe thebigpotatoe added the enhancement New feature or request label Dec 2, 2019
@thebigpotatoe
Copy link
Owner

Haha, oh boy third request for this.I think given the popular request for this feature I will implement it, but it's going to require a few changes.

What will need to happen to make this viable I think is to convert the colour space from RGB to HSV. That way when the lights are set using the HSV space the "value" can be used as a global brightness. What I will also do is make it a function that must be included in new modes so that any mode that does not want to be globally dimmed (ie the visualiser mode) then it will not.

@StefaanVanDooren
Copy link

Changing from RGB to HSV is indeed the way to go. I have this done in my current implementation and it is working great.
I only can't open a pull request, because I went a different way combining your code and some other.

But I'll keep an eye on this, maybe I'll revert back to yours and add a few mode a have running now.

@tristndev
Copy link
Contributor Author

Unsure if HSV is really needed, but wouldn't this maybe be possible with FastLED's setBrightness(b) (see documentation) function?

@thebigpotatoe
Copy link
Owner

The set brightness method is a great feature and I use it everywhere just as nscale8() in the project, but again its not useful to use globally in this project. This is down to the way that FastLED handles colours.

The way FastLED works (and it took me ages to figures this out) is you set your colours first in RGB or HSV structures then apply transforms such as dimming over the top. So for example you set your light to rgb(128, 128, 128) which is a white light at 50% brightness through the colour picker on the web page. FastLED in the sketch would set your channels in a CRGB struct to these values, great.

Then after setting the struct colour values the global brightness function would then be applied. This is done by scaling the current values you have just set, not by scaling them appropriately into a range of 256 like you would think. So in the example where you set rgb(128, 128, 128) your light is already at 50% brightness of white, so by applying the setBrightness() function with a value of say 128 (50% again) you would actually end up with a light at 25% brightness not 50% as you may have intended.

So in all the setBrightness() function in FastLED is misleading and certainly did not produce the results I wanted when I first started using it ages ago which is why I have implemented this project the way I have. If the above explanation does not make sense I will make up a simple example sketch to show how it works.

But since everyone would like a global brightness slider, and I whole heartedly agree, we can move the colour space to HSV. In doing so the V value can be used to globally scale the brightness in a dedicated function rather than using FastLED's misleading setBrightness() function (which will also have the affect on CHSV objects too)

@tristndev
Copy link
Contributor Author

Understood. Thinking about it more, HSV probably is the way to go then as all solutions with setBrightness() would be kind of hacky.

@StefaanVanDooren
Copy link

rgb2hsv_approximate is a handy function in this regard I think

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants