|
|
@ -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)
|
|
|
|
baseImage, _ := b64.StdEncoding.DecodeString(img)
|
|
|
|
bigImage, _, _ := image.Decode(bytes.NewReader(baseImage))
|
|
|
|
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
|
|
|
|
// 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
|
|
|
|
a.countDown -= 50
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
//a.image = a.image[:len(a.image)-1]
|
|
|
|
//a.image = a.image[:len(a.image)-1]
|
|
|
|
//delete(a.images, "doorbell")
|
|
|
|
delete(a.images, "doorbell")
|
|
|
|
a.countDown = 5000
|
|
|
|
a.countDown = 5000
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -109,7 +109,7 @@ func (a *Animation) Next() (image.Image, <-chan time.Time, error) {
|
|
|
|
json.Unmarshal([]byte(string(msg.Payload())), &incoming)
|
|
|
|
json.Unmarshal([]byte(string(msg.Payload())), &incoming)
|
|
|
|
fmt.Println(incoming.Type)
|
|
|
|
fmt.Println(incoming.Type)
|
|
|
|
if incoming.Type == "doorbell" {
|
|
|
|
if incoming.Type == "doorbell" {
|
|
|
|
go appendImage(incoming.Image, a)
|
|
|
|
go loadImage(incoming.Type, incoming.Image, a)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
a.ctx.DrawString(a.msg, 5, 9)
|
|
|
|
a.ctx.DrawString(a.msg, 5, 9)
|
|
|
|
}
|
|
|
|
}
|
|
|
|