ws2812: add brightness control

This commit is contained in:
Carlos Henrique Guardão Gandarez
2026-04-01 14:35:53 -03:00
committed by Ron Evans
parent e232a4f136
commit 21a7d0a96a
2 changed files with 33 additions and 13 deletions
+5 -3
View File
@@ -22,10 +22,12 @@ func newWS2812Device(pin machine.Pin) Device {
return Device{Pin: pin, writeColorFunc: writeColorsRGB}
}
return Device{
Pin: pin,
writeColorFunc: func(_ Device, buf []color.RGBA) error {
Pin: pin,
brightness: 255,
writeColorFunc: func(_ Device, buf []color.RGBA, brightness uint8) error {
for _, c := range buf {
ws.PutRGB(c.R, c.G, c.B)
r, g, b := applyBrightness(c, brightness)
ws.PutRGB(r, g, b)
}
return nil
},