Blinkstick library for Go (Golang)

I’ve been picking up Go recently and decided to try writing some projects on my BlinkStick Flex and Pro with it. Found out that the API Implementation listed over here does actually work great under Linux, but it only provides the ability to set one LED.

So I’ve scraped together my own API implementation for Go. Main things I needed it to support were SetLEDData and GetLEDCount, and those are really the most tested functions. I added few convenience things like SetAllRGB which sets RGB values on every LED connected to a channel.

First time ever writing something meant for other people to actually use it, I’ve probably made a lot of odd choices that could be improved, so feedback is greatly appreciated!

Documentation is up on godoc.

Small example, to set all LEDs white:

package main

import "github.com/different55/blinkstickgo"

func main() {
    blinkstickgo.Init()
    defer blinkstickgo.Fini()
    
    sticks, err := blinkstickgo.FindAll()
    if err != nil {
        panic(err)
    } else if len(sticks) == 0 {
        panic("No connected BlinkStick devices for testing")
    }
    
    for _, stick := range sticks {
        err := stick.SetAllRGB(0, 255, 255, 255)
        if err != nil {
            panic(err)
        }
    }
}
1 Like