+class MessageKeeper:
+ def __init__(self, vendie):
+ self.scrolling_message = []
+ self.v = vendie
+ self.next_update = None
+
+ def set_message(self, string):
+ self.scrolling_message = [(string, False, None)]
+ self.update_display(True)
+
+ def set_messages(self, strings):
+ self.scrolling_message = strings
+ self.update_display(True)
+
+ def update_display(self, forced = False):
+ if not forced and self.next_update != None and time() < self.next_update:
+ return
+ if len(self.scrolling_message) > 0:
+ newmsg = self.scrolling_message[0]
+ if newmsg[2] != None:
+ self.next_update = time() + newmsg[2]
+ else:
+ self.next_update = None
+ self.v.display(self.scrolling_message[0][0])
+ if self.scrolling_message[0][1]:
+ self.scrolling_message.append(self.scrolling_message[0])
+ del self.scrolling_message[0]
+