working pop up message
This commit is contained in:
parent
80d5105abc
commit
77cdf4b118
|
@ -100,6 +100,13 @@ class Controller:
|
|||
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
|
||||
self.poscount = 0 #start at beginning of new text
|
||||
|
@ -204,10 +211,18 @@ 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
|
||||
self.displayTextOffset(self.text, self.poscount)
|
||||
|
@ -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()
|
||||
|
||||
|
@ -240,3 +254,8 @@ class Controller:
|
|||
|
||||
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