split out msg receiver
build rgb-board / build (push) Successful in 8m3s Details

main
Nathan Wagner 9 months ago
parent eab6b0d26f
commit d574df9938

@ -43,14 +43,9 @@ func animate(sz image.Point, mqMessages chan mqtt.Message) *Animation {
},
}
}
func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
func (a *Animation) useMsg() {
var incoming incomingMessage
switch {
case a.doorbell != (Doorbell{}):
a.animateDoorbell()
default:
a.animateMario()
}
select {
case msg := <-a.mqmsg:
json.Unmarshal([]byte(string(msg.Payload())), &incoming)
@ -62,5 +57,15 @@ func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
}
default:
}
}
func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
switch {
case a.doorbell != (Doorbell{}):
a.animateDoorbell()
default:
a.animateMario()
}
a.useMsg()
return a.ctx.Image(), time.After(time.Millisecond * 50), nil
}

Loading…
Cancel
Save