From f954c3c9a4c6080f4ee508c364519c5879eb0909 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 1 May 2018 14:49:11 +0200 Subject: make lint happy --- blinkstick.go | 9 ++++++++- cmd/blinkstick/main.go | 3 +-- hid.go | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/blinkstick.go b/blinkstick.go index 2d7d180..c321683 100644 --- a/blinkstick.go +++ b/blinkstick.go @@ -1,4 +1,6 @@ -package blinkstick +// Package blinckstick implements BlinkStick Stripe HID interface + +package blinkstick // import "dim13.org/blinkstick" import ( "bytes" @@ -18,6 +20,7 @@ import ( 9: LED Frame [Channel, [G, R, B][0..63]] */ +// Frame colors type Frame [8]color.Color func rgb(c color.Color) (uint8, uint8, uint8) { @@ -28,6 +31,7 @@ func rgb(c color.Color) (uint8, uint8, uint8) { return uint8(r >> 8), uint8(g >> 8), uint8(b >> 8) } +// SetIndex sets color by index func SetIndex(w io.Writer, i int, c color.Color) { buf := bytes.NewBuffer([]byte{5, 0, byte(i)}) r, g, b := rgb(c) @@ -35,6 +39,7 @@ func SetIndex(w io.Writer, i int, c color.Color) { io.Copy(w, buf) } +// Set sets color as frame func Set(w io.Writer, frame Frame) { buf := bytes.NewBuffer([]byte{6, 0}) for _, c := range frame { @@ -44,10 +49,12 @@ func Set(w io.Writer, frame Frame) { io.Copy(w, buf) } +// SetAll sets all LEDs to same color func SetAll(w io.Writer, c color.Color) { Set(w, Frame{c, c, c, c, c, c, c, c}) } +// Off all LEDs func Off(w io.Writer) { Set(w, Frame{}) } diff --git a/cmd/blinkstick/main.go b/cmd/blinkstick/main.go index 92f8253..86939e0 100644 --- a/cmd/blinkstick/main.go +++ b/cmd/blinkstick/main.go @@ -39,7 +39,6 @@ func main() { defer blinkstick.Off(dev) - /* XXX pal := []color.Color{ color.YCbCr{0x1f, 0x00, 0xff}, // red color.YCbCr{0x3f, 0x00, 0xbf}, // yellow @@ -54,7 +53,7 @@ func main() { time.Sleep(time.Second / 2) } } - */ + for i := 0; ; i++ { c := palette.Plan9[i%256] f := newTwiddle(i, c) diff --git a/hid.go b/hid.go index 5c598e8..eda942d 100644 --- a/hid.go +++ b/hid.go @@ -11,6 +11,7 @@ const ( productID = 0x41e5 ) +// Errors var ( ErrUnsupported = errors.New("unsupproted platform") ErrNotFound = errors.New("device not found") @@ -27,6 +28,7 @@ var ( Info Block 2: */ +// Open blinkstick device func Open() (*hid.Device, error) { if !hid.Supported() { return nil, ErrUnsupported -- cgit v1.2.3