adjusting some function names
build rgb-board / build (push) Successful in 1m34s Details

deleting doorbell image after countdown
main
Nathan Wagner 10 months ago
parent 970f840140
commit 89ad771eab

@ -80,10 +80,10 @@ func NewAnimation(sz image.Point, mqMessages chan mqtt.Message) *Animation {
}
}
func appendImage(img string, a *Animation) {
func loadImage(imgType string, img string, a *Animation) {
baseImage, _ := b64.StdEncoding.DecodeString(img)
bigImage, _, _ := image.Decode(bytes.NewReader(baseImage))
a.images["doorbell"] = imaging.Resize(bigImage, 64, 64, imaging.Lanczos)
a.images[imgType] = imaging.Resize(bigImage, 64, 64, imaging.Lanczos)
}
// what happens each frame, at an interval of 50 milliseconds
@ -99,7 +99,7 @@ func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
a.countDown -= 50
} else {
//a.image = a.image[:len(a.image)-1]
//delete(a.images, "doorbell")
delete(a.images, "doorbell")
a.countDown = 5000
}
}
@ -109,7 +109,7 @@ func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
json.Unmarshal([]byte(string(msg.Payload())), &incoming)
fmt.Println(incoming.Type)
if incoming.Type == "doorbell" {
go appendImage(incoming.Image, a)
go loadImage(incoming.Type, incoming.Image, a)
} else {
a.ctx.DrawString(a.msg, 5, 9)
}

Loading…
Cancel
Save