Compare commits

...

2 Commits

Author SHA1 Message Date
Nathan
5f320f8ca7 Merge branch 'master' of gitea.local:publicWagsHome/rgb-go-test
All checks were successful
rgb/pipeline/head This commit looks good
2023-01-15 03:53:11 +00:00
Nathan
acbd559436 big time risk 2023-01-15 03:52:59 +00:00

View File

@@ -69,10 +69,13 @@ func main() {
m, err := rgbmatrix.NewRGBLedMatrix(config) m, err := rgbmatrix.NewRGBLedMatrix(config)
fatal(err) fatal(err)
mqMessages := make(chan mqtt.Message) mqMessages := make(chan mqtt.Message)
log.Println("making listener")
go listener(mqMessages) go listener(mqMessages)
tk := rgbmatrix.NewToolKit(m) tk := rgbmatrix.NewToolKit(m)
defer tk.Close() defer tk.Close()
log.Println("making animator")
go animator(tk, mqMessages) go animator(tk, mqMessages)
log.Println("I guess I'm at the end")
} }
func listener(mqMessages chan mqtt.Message) { func listener(mqMessages chan mqtt.Message) {
@@ -83,6 +86,7 @@ func listener(mqMessages chan mqtt.Message) {
log.Println(fmt.Sprintf("failed to connect to mq: %s", token.Error().Error())) log.Println(fmt.Sprintf("failed to connect to mq: %s", token.Error().Error()))
panic(token.Error()) panic(token.Error())
} }
log.Println("connected")
client.Subscribe(topic, 0, func(client mqtt.Client, msg mqtt.Message) { client.Subscribe(topic, 0, func(client mqtt.Client, msg mqtt.Message) {
log.Println("Receiving ", string(msg.Payload()), " on topic: ", msg.Topic()) log.Println("Receiving ", string(msg.Payload()), " on topic: ", msg.Topic())
mqMessages <- msg mqMessages <- msg
@@ -90,7 +94,6 @@ func listener(mqMessages chan mqtt.Message) {
} }
func animator(tk *rgbmatrix.ToolKit, mqMessages chan mqtt.Message) { func animator(tk *rgbmatrix.ToolKit, mqMessages chan mqtt.Message) {
tk.PlayAnimation(NewAnimation(image.Point{64, 32}, mqMessages)) tk.PlayAnimation(NewAnimation(image.Point{64, 32}, mqMessages))
} }