Giter VIP home page Giter VIP logo

Comments (2)

StevenLooman avatar StevenLooman commented on May 22, 2024 2

It appears from this article that the bulb actually has two sets of LEDs: one set for colors, one set for warm light. (As seen on this image.) I think that you cannot use both sets of LEDs at the same time (at least via Bluetooth), possibly due to prevention of overheating or drawing too much current.

The name 'brightness' is perhaps misleading since RGB and warm light are actually two different (physical) things for this bulb. The brightness of RGB is controlled by setting a darker RGB color. The brightness of warm light is controlled by setting a lower intensity for warm light.

Maybe the API should avoid the word brightness and instead use warm_light_intensity in method turn_on(). The method can also be extended by adding an additional parameter for RGB. Or, the API can be simplified by not accepting any further paramters, forcing the user to call it turn_on() and set_warm_light()/set_color() directly. (The last has my preference.)

By looking at turn_on(), actually, I see that it calls set_color() with a RGB color. Maybe the firmware is smart enough to use the warm light LEDS if all parts of the RGB color are the same.

from magicblue.

Betree avatar Betree commented on May 22, 2024

Such a feature would be nice indeed. Ideally we would have to read the current color from the bulb but that part is still tricky (see #17).

But we could be able to do that right now by storing the current color in MagicBlueLib.

  • Downside : set_brightness would have a strange behaviour before the first call to turn_on, set_warm_light or set_color as the first color would be unknown
  • Upside : easy to implement, as setting the brightness basically consists in applying it to each component of the colour. Example (admitting current_color contains the colors list as [red, green, blue]) :
def set_brightness(self, brightness):
    """
    Changes current brightness
    :param brightness: between 0.0 and 1.0 : brightness ratio
    """
    self.set_color([
        int(self.current_color[0] * brightness),
        int(self.current_color[1] * brightness),
        int(self.current_color[2] * brightness)
    ])

from magicblue.

Related Issues (20)

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.