1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-29 13:49:14 +08:00
hybridgroup.gobot/drivers/spi/apa102_test.go
Erwan Morvan d73466a5f9 Apa102 use default brightness (#671)
* spi/apa102: use uint8 type with a max of 31 for brightness

Signed-off-by: Erwan Morvan <air1bzz@gmail.com>
2019-05-31 11:34:00 +02:00

40 lines
743 B
Go

package spi
import (
"image/color"
"testing"
"gobot.io/x/gobot"
"gobot.io/x/gobot/gobottest"
)
var _ gobot.Driver = (*APA102Driver)(nil)
func initTestDriver() *APA102Driver {
d := NewAPA102Driver(&TestConnector{}, 10, 31)
return d
}
func TestDriverStart(t *testing.T) {
d := initTestDriver()
gobottest.Assert(t, d.Start(), nil)
}
func TestDriverHalt(t *testing.T) {
d := initTestDriver()
d.Start()
gobottest.Assert(t, d.Halt(), nil)
}
func TestDriverLEDs(t *testing.T) {
d := initTestDriver()
d.Start()
d.SetRGBA(0, color.RGBA{255, 255, 255, 15})
d.SetRGBA(1, color.RGBA{255, 255, 255, 15})
d.SetRGBA(2, color.RGBA{255, 255, 255, 15})
d.SetRGBA(3, color.RGBA{255, 255, 255, 15})
gobottest.Assert(t, d.Draw(), nil)
}