add scroll once mode
This commit is contained in:
parent
b9b9f8a5ee
commit
80d5105abc
|
@ -118,6 +118,15 @@ class Controller:
|
|||
print("changed text to ", self.text)
|
||||
self.mqtt.publish(self.topic + "/" + __TOPIC_TEXT_PAN__, self.text, 1 )
|
||||
|
||||
if message.topic.endswith(__TOPIC_TEXT_SCROLL__ + "/set"):
|
||||
self.mode = Mode.SCROLL
|
||||
self.poscount = 0 #start at beginning of new text
|
||||
self.text = msg
|
||||
for i in range(NUMDIGITS):
|
||||
self.text = " "+self.text+" " #add spaces left and right for marquee to enter and leave the full frame
|
||||
print("changed text to ", self.text)
|
||||
self.mqtt.publish(self.topic + "/" + __TOPIC_TEXT_SCROLL__, self.text, 1 )
|
||||
|
||||
|
||||
def on_connect(self, client, userdata, flags, rc):
|
||||
print("Connected to MQTT Broker")
|
||||
|
@ -199,14 +208,21 @@ class Controller:
|
|||
if self.text != self.text_last: #time to update animation
|
||||
self.displayTextOffset(self.text, 0)
|
||||
|
||||
if self.mode == Mode.MARQUEE:
|
||||
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)
|
||||
|
||||
self.poscount += 1
|
||||
self.poscount %= max(1,int(self.seglen(self.text)-NUMDIGITS+1))
|
||||
if self.mode == Mode.MARQUEE:
|
||||
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.last_scrollupdate = time.time()
|
||||
|
||||
|
||||
if self.mode == Mode.PAN:
|
||||
if time.time() > self.last_scrollupdate+self.scroll_interval or self.text != self.text_last: #time to update animation
|
||||
print("pos=", self.poscount)
|
||||
|
|
Loading…
Reference in New Issue