You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/disintegration/imaging"
|
|
"github.com/mcuadros/go-rpi-rgb-led-matrix"
|
|
)
|
|
|
|
var (
|
|
rows = flag.Int("led-rows", 32, "number of rows supported")
|
|
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
|
|
brightness = flag.Int("brightness", 100, "brightness (0-100)")
|
|
image = flag.String("image", "", "image path")
|
|
rotate = flag.Int("rotate", 0, "rotate angle, 90, 180, 270")
|
|
)
|
|
|
|
func main() {
|
|
f, err := os.Open(*image)
|
|
fatal(err)
|
|
|
|
config := &rgbmatrix.DefaultConfig
|
|
config.Rows = *rows
|
|
config.ChainLength = *chain
|
|
config.Brightness = *brightness
|
|
|
|
m, err := rgbmatrix.NewRGBLedMatrix(config)
|
|
fatal(err)
|
|
|
|
tk := rgbmatrix.NewToolKit(m)
|
|
defer tk.Close()
|
|
|
|
switch *rotate {
|
|
case 90:
|
|
tk.Transform = imaging.Rotate90
|
|
case 180:
|
|
tk.Transform = imaging.Rotate180
|
|
case 270:
|
|
tk.Transform = imaging.Rotate270
|
|
}
|
|
|
|
close, err := tk.PlayGIF(f)
|
|
fatal(err)
|
|
|
|
time.Sleep(time.Second * 30)
|
|
close <- true
|
|
}
|
|
|
|
func init() {
|
|
flag.Parse()
|
|
}
|
|
|
|
func fatal(err error) {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|