From 89ad771eabc0933cfc46f166aef48d06f1f4dfdc Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Mon, 5 Feb 2024 20:55:57 +0000 Subject: [PATCH] adjusting some function names deleting doorbell image after countdown --- animation.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/animation.go b/animation.go index 7567fef..ef014ff 100644 --- a/animation.go +++ b/animation.go @@ -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) }