|
|
@ -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))
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|