Skip to content

Commit

Permalink
Stop using Red parameter for brightness value
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mikezange authored and deadprogram committed May 22, 2019
1 parent 47eaa1c commit 78ec92a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/spi/apa102.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 78ec92a

Please sign in to comment.