From 77cdf4b118fa706634d6879f51f450eebe204c86 Mon Sep 17 00:00:00 2001 From: Fisch Date: Sat, 3 Jul 2021 23:28:47 +0200 Subject: [PATCH] working pop up message --- src/controller.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/controller.py b/src/controller.py index 7eaad98..77b2a16 100644 --- a/src/controller.py +++ b/src/controller.py @@ -99,6 +99,13 @@ class Controller: self.text = msg.ljust(NUMDIGITS) print("changed text to ", self.text) self.mqtt.publish(self.topic + "/" + __TOPIC_TEXT_STATIC__, self.text, 1 ) + + if message.topic.endswith(__TOPIC_TEXT_ONCE__ + "/set"): + self.mode = Mode.ONCE + self.text = msg.ljust(NUMDIGITS) + self.poscount = 0 #use for timing + print("changed text to ", self.text) + self.mqtt.publish(self.topic + "/" + __TOPIC_TEXT_ONCE__, self.text, 1 ) if message.topic.endswith(__TOPIC_TEXT_MARQUEE__ + "/set"): self.mode = Mode.MARQUEE @@ -204,9 +211,17 @@ class Controller: if self.displayL is not None and self.displayR is not None: #displays initialized - if self.mode == Mode.STATIC: + if self.mode == Mode.STATIC or self.mode == Mode.ONCE: if self.text != self.text_last: #time to update animation self.displayTextOffset(self.text, 0) + + if self.mode == Mode.ONCE: + if time.time() > self.last_scrollupdate+self.scroll_interval: + if self.poscount>=NUMDIGITS: #time it stays depends on scrollspeed (how long it would take to pass over the frame) + self.clearAndStop() + + self.poscount += 1 #used for timing + self.last_scrollupdate = time.time() if self.mode == Mode.MARQUEE or self.mode == Mode.SCROLL: if time.time() > self.last_scrollupdate+self.scroll_interval or self.text != self.text_last: #time to update animation @@ -217,8 +232,7 @@ class Controller: self.poscount %= max(1,int(self.seglen(self.text)-NUMDIGITS+1)) elif self.mode == Mode.SCROLL: if self.poscount >= max(1,int(self.seglen(self.text)-NUMDIGITS+1)): #reached end for scroll once - self.mode == Mode.STATIC - self.text=" ".ljust(NUMDIGITS) #empty + self.clearAndStop() self.last_scrollupdate = time.time() @@ -239,4 +253,9 @@ class Controller: self.last_scrollupdate = time.time() self.text_last = self.text - \ No newline at end of file + + + def clearAndStop(self): + self.mode == Mode.STATIC #Stop animation + self.text=" ".ljust(NUMDIGITS) #empty + self.displayTextOffset(self.text, 0) #update immediately \ No newline at end of file