def __init__(self, controller, gpio=None): threading.Thread.__init__(self) self.lock = threading.Lock() # Controller resource self.controller = controller # Display resource self.disp = Display(gpio) self.mp3Title = "" # Create text buffers but don't scroll or blink just yet self.sTextLine1 = ScrollingText.Worker("", 16, True, False, 0.8, False, 0.5) self.sTextLine2 = ScrollingText.Worker("", 16, True, False, 0.8, False, 0.5) self.sTextLine1.start() self.sTextLine2.start() self.daemon = True # Clock Setup self.clockOn = False self.clockShowSeconds = True ################################# # DISPLAY STATES # # Welcome State (with 2 second timeout) # Media State (with clock) # MP3 State (with scrolling text) # Radio State (with scrolling station description) # # Volume change state # --> Volume Lingering state # --> Back to current state self.states = enum(STATE_WELCOME=0, STATE_MEDIA=1, STATE_MP3=2, STATE_RADIO=3, STATE_AUX=4, STATE_MUTED=5, STATE_VOLUME=6, STATE_TONE=7, STATE_SHUTDOWN=8) # Timers # self.volumeTimer = Timer(1, False) self.toneTimer = Timer(1, False) self.selectLedTimer = Timer(0.25, False) self.welcomeTimer = Timer(3, False) self.MAIN_THREAD_DELAY = 0.01 self.state = self.states.STATE_WELCOME self.prevState = self.states.STATE_WELCOME self.lastMenu = self.states.STATE_MEDIA self.powerOn()
def __init__(self, text="This is a test scrolling text class.", width=16, direction=True, scrolling=True, speed=0.2, blinking=False, blinkSpeed=0.25): threading.Thread.__init__(self) self.lock = threading.Lock() self.sText = ScrollingText(text, width, direction) #print self.sText self.daemon = True # Timers self.scrollTimer = Timer(speed, scrolling) self.blinkTimer = Timer(blinkSpeed, blinking) self.blinkState = False