This commit is contained in:
19
board.go
19
board.go
@@ -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
|
var incoming incomingMessage
|
||||||
switch {
|
|
||||||
case a.doorbell != (Doorbell{}):
|
|
||||||
a.animateDoorbell()
|
|
||||||
default:
|
|
||||||
a.animateMario()
|
|
||||||
}
|
|
||||||
select {
|
select {
|
||||||
case msg := <-a.mqmsg:
|
case msg := <-a.mqmsg:
|
||||||
json.Unmarshal([]byte(string(msg.Payload())), &incoming)
|
json.Unmarshal([]byte(string(msg.Payload())), &incoming)
|
||||||
@@ -62,5 +57,15 @@ func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
|
|||||||
}
|
}
|
||||||
default:
|
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
|
return a.ctx.Image(), time.After(time.Millisecond * 50), nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user