nerves-project / nerves_leds

Functions to drive LEDs on embedded systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support LEDs that support a max_brightness > 1

fhunleth opened this issue · comments

While they're not technically unsupported, there's an assumption that LEDs can only be set on or off. Some LEDs can have their brightness set from 0-255 or other ranges if the Linux driver supports it. Currently, setting those LEDs to true sets them to 1 which is really dim.

The Lego Mindstorms EV3 is one platform that has LEDs like this. I've seen this on other platforms as well.

Finally made a pass on nerves_leds to solve a bunch of configuration stuff.

You can now definitely do this...

Leds.set :backlight, brightness: 200

And I added an example as such, But you could also redefine true to have a different value written, as follows...

# in config.exs
...
config nerves_leds, states: [ 
    true:  [brightness: 255],  # or whatever
    false: [brightness: 0],
    slowblink: [trigger: "timer", delay_off: 250, delay_on: 250],
    fastblink: [trigger: "timer", delay_off: 80, delay_on: 50],
    slowwink:  [trigger: "timer", delay_on: 1000, delay_off: 100],
    heartbeat: [trigger: "heartbeat"]
]

Do you think this is enough to address this issue?

If not, one other idea would be to do implement the ability to do something like...

# in config.exs
config nerves_leds, max_brightness: 255, min_brightness: 0

And then have true mean write the "maximum" value for brightness, but I'm not sure that's enough better than just redefining the meaning of true and false.

Thoughts?

I'm glad that you can set the brightness to an integer. I don't think that I knew that when I entered this issue. My guess is that people who actually have an LED that supports a variable brightness probably won't use true and false and maybe this is a non-problem. However, I do like the first suggestion of defining the brightness of true and false.

Looks like current behavior is good enough to close this. Thanks.