Go library for Pimoroni Scroll pHat
Go library for controlling Pimoroni's Scroll pHat.
Most of the codes were inspired by scroll-phat and Dave Cheney's i2c.
Install
$ go get -u github.com/meinside/scrollphat-go
Configuration
You need to enable I2C first:
$ sudo raspi-config
Also, your account should be in 'i2c' group:
$ sudo usermod -G i2c USERNAME
Sample
package main
import (
"time"
scroll "github.com/meinside/scrollphat-go"
)
func main() {
if phat := scroll.New(); phat != nil {
phat.SetBrightness(5)
time.Sleep(1 * time.Second)
phat.Fill()
time.Sleep(1 * time.Second)
phat.Clear()
time.Sleep(1 * time.Second)
phat.DrawBytes(scroll.BytesForString(":-)"))
time.Sleep(1 * time.Second)
phat.Scroll(" 0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz `~!@#$%^&*()-=_+[]{};:\"'<>,.?/\\|", 50)
time.Sleep(1 * time.Second)
phat.DrawBytes(scroll.ArraysToBytes([][]uint8{
{0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
}))
time.Sleep(1 * time.Second)
phat.Invert()
time.Sleep(1 * time.Second)
phat.Clear()
phat.Close()
} else {
panic("could not initialize ScrollPHat")
}
}
Compile it and run like this:
$ go build sample.go
$ ./sample
Then you'll see:
License
MIT