go-piglow is a small lib for controlling the Piglow from Go on your Raspberry Pi.
See the Piglow github page for details on how to set up your Raspberry Pi for this to work.
package main
import (
"github.com/wjessop/go-piglow"
"log"
)
func main() {
var p *piglow.Piglow
var err error
// Create a new Piglow
p, err = piglow.NewPiglow(); if err != nil {
log.Fatal("Couldn't create a Piglow: ", err)
}
p.SetLED(0, 255) // Set LED 0 to 255 (max brightness)
p.SetLED(1, 128) // Set LED 1 to half brightness
err = p.Apply(); if err != nil { // Apply the changes
log.Fatal("Couldn't apply changes: ", err)
}
}
Cross compile for the Raspberry pi with:
GOOS=linux GOARM=6 GOARCH=arm go build
See examples/example.go for a list of functions you can use. The other files in examples/* are more complex/fun examples of how to use the lib.
- The LEDs aren't in order, experiment to find out which is which
- Setting all LEDs to 255 will probably hurt your eyes, I don't recommend it
- The lib isn't thread-safe (It could be, but I don't see the point) , so only create one instance of Piglow
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- Will Jessop, @will_j, [email protected]