From 78ec92af7afcf1ec4e6d1c6ad5943538387a0a00 Mon Sep 17 00:00:00 2001 From: Mike Zange <5443707+MikeZange@users.noreply.github.com> Date: Fri, 10 May 2019 12:49:22 +0100 Subject: [PATCH] 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. --- drivers/spi/apa102.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/spi/apa102.go b/drivers/spi/apa102.go index f8b9ea069..2dd82e29a 100644 --- a/drivers/spi/apa102.go +++ b/drivers/spi/apa102.go @@ -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)