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.
rgb-led-board/main.go

80 lines
2.3 KiB
Go

2 years ago
package main
import (
"flag"
2 years ago
"fmt"
_ "image/jpeg"
"log"
"os"
"os/signal"
"syscall"
2 years ago
rgbmatrix "gitea.wagshome.duckdns.org/publicWagsHome/go-rpi-rgb-led-matrix"
mqtt "github.com/eclipse/paho.mqtt.golang"
2 years ago
)
// flags from cmd line
2 years ago
var (
rows = flag.Int("led-rows", 64, "number of rows supported")
cols = flag.Int("led-cols", 64, "number of columns supported")
2 years ago
parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels")
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
2 years ago
brightness = flag.Int("brightness", 100, "brightness (0-100)")
hardware_mapping = flag.String("led-gpio-mapping", "regular", "Name of GPIO mapping used.")
show_refresh = flag.Bool("led-show-refresh", false, "Show refresh rate.")
inverse_colors = flag.Bool("led-inverse", false, "Switch if your matrix has inverse colors on.")
disable_hardware_pulsing = flag.Bool("led-no-hardware-pulse", false, "Don't use hardware pin-pulse generation.")
1 year ago
led_slowdown_gpio = flag.Int("led-slowdown-gpio", 1, "GPIO pin slowdown")
2 years ago
)
// runs before main, parses flags
2 years ago
func init() {
flag.Parse()
}
// small function for handling fatal errors
2 years ago
func fatal(err error) {
if err != nil {
panic(err)
}
}
func main() {
config := &rgbmatrix.DefaultConfig
config.Rows = *rows
config.Cols = *cols
config.Parallel = *parallel
config.ChainLength = *chain
config.Brightness = *brightness
config.HardwareMapping = *hardware_mapping
config.ShowRefreshRate = *show_refresh
config.InverseColors = *inverse_colors
config.DisableHardwarePulsing = *disable_hardware_pulsing
1 year ago
var rt rgbmatrix.RunTimeConfig
rt.Gpio_slowdown = *led_slowdown_gpio
setupMQTT()
m, err := rgbmatrix.NewRGBLedMatrix(config, &rt)
fatal(err)
mqMessages := make(chan mqtt.Message)
log.Println("making listener")
go listener(mqMessages)
tk := rgbmatrix.NewToolKit(m)
defer tk.Close()
log.Println("making animator")
9 months ago
go orchestrator(tk, mqMessages)
log.Println("I guess I'm at the end")
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
done := make(chan bool, 1)
go func() {
sig := <-sigs
fmt.Println()
fmt.Println(sig)
done <- true
}()
fmt.Println("awaiting signal")
<-done
fmt.Println("exiting")
}