Stop using Red parameter for brightness value

This change corrects using Red parameter of RGBA for the Brightness value, to using the Alpha parameter of RGBA.

As the brightness max value for APA102 is `31` the `math.Min` stops the driver from using any value higher than 31.
This commit is contained in:
Mike Zange 2019-05-10 12:49:22 +01:00 committed by Ron Evans
parent 47eaa1cab9
commit 78ec92af7a
1 changed files with 3 additions and 3 deletions

View File

@ -1,9 +1,9 @@
package spi
import (
"image/color"
"gobot.io/x/gobot"
"image/color"
"math"
)
// APA102Driver is a driver for the APA102 programmable RGB LEDs
@ -93,7 +93,7 @@ func (d *APA102Driver) Draw() error {
for i, c := range d.vals {
j := (i + 1) * 4
tx[j] = 0xe0 + byte(c.R)
tx[j] = 0xe0 + byte(math.Min(c.A, 31))
tx[j+1] = byte(c.B)
tx[j+2] = byte(c.G)
tx[j+3] = byte(c.R)