tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
601 stars 188 forks source link

RGB Leds and Brightness #52

Open directionless opened 5 years ago

directionless commented 5 years ago

Modern RGB leds are amazingly bright. This often leads to wanting to set some global brightness level. I'm not sure if this is more desirable as something using the alpha channel, or as something that could be set for all leds.

I guess it's a bit lossy, since it would result in some floating point approximation. Still though, it seems valuable to me

deadprogram commented 5 years ago

This could be done with a Luma calculation https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color but not sure that this would go in any particular driver. Seems to me like this would be some application specific code.

aykevl commented 5 years ago

Yes, I'm thinking the same. If the hardware has support for dimming we should use that in the driver, but otherwise leave it up to the application. Also see this package that I've started to write, inspired by FastLED: https://godoc.org/github.com/aykevl/ledsgo It would certainly be useful to have some way to dim LEDs, so far I've used (ledsgo.Color).Value which has worked well enough for me so far.