working pop up message
This commit is contained in:
parent
80d5105abc
commit
77cdf4b118
|
@ -99,6 +99,13 @@ class Controller:
|
||||||
self.text = msg.ljust(NUMDIGITS)
|
self.text = msg.ljust(NUMDIGITS)
|
||||||
print("changed text to ", self.text)
|
print("changed text to ", self.text)
|
||||||
self.mqtt.publish(self.topic + "/" + __TOPIC_TEXT_STATIC__, self.text, 1 )
|
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"):
|
if message.topic.endswith(__TOPIC_TEXT_MARQUEE__ + "/set"):
|
||||||
self.mode = Mode.MARQUEE
|
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.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
|
if self.text != self.text_last: #time to update animation
|
||||||
self.displayTextOffset(self.text, 0)
|
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 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
|
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))
|
self.poscount %= max(1,int(self.seglen(self.text)-NUMDIGITS+1))
|
||||||
elif self.mode == Mode.SCROLL:
|
elif self.mode == Mode.SCROLL:
|
||||||
if self.poscount >= max(1,int(self.seglen(self.text)-NUMDIGITS+1)): #reached end for scroll once
|
if self.poscount >= max(1,int(self.seglen(self.text)-NUMDIGITS+1)): #reached end for scroll once
|
||||||
self.mode == Mode.STATIC
|
self.clearAndStop()
|
||||||
self.text=" ".ljust(NUMDIGITS) #empty
|
|
||||||
|
|
||||||
self.last_scrollupdate = time.time()
|
self.last_scrollupdate = time.time()
|
||||||
|
|
||||||
|
@ -239,4 +253,9 @@ class Controller:
|
||||||
self.last_scrollupdate = time.time()
|
self.last_scrollupdate = time.time()
|
||||||
|
|
||||||
self.text_last = self.text
|
self.text_last = self.text
|
||||||
|
|
||||||
|
|
||||||
|
def clearAndStop(self):
|
||||||
|
self.mode == Mode.STATIC #Stop animation
|
||||||
|
self.text=" ".ljust(NUMDIGITS) #empty
|
||||||
|
self.displayTextOffset(self.text, 0) #update immediately
|
Loading…
Reference in New Issue