aboutsummaryrefslogtreecommitdiff
path: root/blinkstick.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-05-01 14:49:11 +0200
committerDimitri Sokolyuk <demon@dim13.org>2018-05-01 14:49:11 +0200
commitf954c3c9a4c6080f4ee508c364519c5879eb0909 (patch)
treeb45e50c82334d4d2e6ec7929d30c9c24fdfd30b3 /blinkstick.go
parente0bf1f716b298ca495ce3d8a47f1b85e33311e6a (diff)
make lint happy
Diffstat (limited to 'blinkstick.go')
-rw-r--r--blinkstick.go9
1 files changed, 8 insertions, 1 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{})
}