Coder Social home page Coder Social logo

Comments (7)

LarsMichelsen avatar LarsMichelsen commented on July 23, 2024 1

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

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

from super-simple-rgb-wifi-lamp.

thebigpotatoe avatar thebigpotatoe commented on July 23, 2024

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.

from super-simple-rgb-wifi-lamp.

StefaanVanDooren avatar StefaanVanDooren commented on July 23, 2024

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.

from super-simple-rgb-wifi-lamp.

tristndev avatar tristndev commented on July 23, 2024

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

from super-simple-rgb-wifi-lamp.

thebigpotatoe avatar thebigpotatoe commented on July 23, 2024

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)

from super-simple-rgb-wifi-lamp.

tristndev avatar tristndev commented on July 23, 2024

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

from super-simple-rgb-wifi-lamp.

StefaanVanDooren avatar StefaanVanDooren commented on July 23, 2024

rgb2hsv_approximate is a handy function in this regard I think

from super-simple-rgb-wifi-lamp.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.