Example #1
0
def checkForShutDown():
    if (humble.switch(2)):
        humble.data.setLine(0, "")
        humble.data.setLine(1, "")
        if BIGDISPLAY:
            humble.data.setLine(2, "")
            humble.data.setLine(3, "")
        off()
        return True
    return False
Example #2
0
def checkForShutDown():
    if (humble.switch(2)):
        humble.data.setLine(0, "")
        humble.data.setLine(1, "")
        if BIGDISPLAY:
            humble.data.setLine(2, "")
            humble.data.setLine(3, "")
        off()
        return True
    return False
Example #3
0
  def __init__(self):
    self.dt = DisplayThread(self)
    self.dt.start()

    ## MPD object instance
    self.client = MPDClient()
    if mpdConnect(self.client, CON_ID):
        print 'Got connected!'
    else:
        print 'fail to connect MPD server.'
        sys.exit(1)
    try:
        f = open('/media/usb/playlist.txt','r')
        playlist = f.readline().rstrip()
        print "Loading " + playlist
        self.client.clear()
        self.client.load(playlist)
    except IOError:
        print "Problem reading playlist"
    self.client.stop()
    self.client.play()

    carryOn = True
    while (carryOn):
        if (humble.switch(0)):
            time.sleep(PAUSE)
            self.toggle()
        if (humble.switch(1)):
            time.sleep(PAUSE)
            self.skip()
        if (humble.switch(2)):
            time.sleep(PAUSE)
            self.stop()
            carryOn = False
            time.sleep(PAUSE)
    # Stop the display thread
    self.dt.done()
Example #4
0
    def __init__(self):
        self.dt = DisplayThread(self)
        self.dt.start()

        ## MPD object instance
        self.client = MPDClient()
        if mpdConnect(self.client, CON_ID):
            print 'Got connected!'
        else:
            print 'fail to connect MPD server.'
            sys.exit(1)
        try:
            f = open('/media/usb/playlist.txt', 'r')
            playlist = f.readline().rstrip()
            print "Loading " + playlist
            self.client.clear()
            self.client.load(playlist)
        except IOError:
            print "Problem reading playlist"
        self.client.stop()
        self.client.play()

        carryOn = True
        while (carryOn):
            if (humble.switch(0)):
                time.sleep(PAUSE)
                self.toggle()
            if (humble.switch(1)):
                time.sleep(PAUSE)
                self.skip()
            if (humble.switch(2)):
                time.sleep(PAUSE)
                self.stop()
                carryOn = False
                time.sleep(PAUSE)
        # Stop the display thread
        self.dt.done()
Example #5
0
def main():
    humble.init()
    hdt = humble.HumbleDisplayThread(humble.data)
    hdt.start()
    humble.data.setLine(0,"Select Function")
    humble.data.setLine(1,"1:Music;2:Trains")
    while (True):
        if humble.switch(0):
            time.sleep(0.2)
            carryOn = True
            while (carryOn):
                humble.data.setLine(0,"Select Function")
                humble.data.setLine(1,"1:Radio;2:Jukebox")
                time.sleep(0.2)
                if humble.switch(0):
                    piplayer.doStuff()
                    humble.data.setLine(0,"Select Function")
                    humble.data.setLine(1,"1:Music;2:Trains")
                if humble.switch(1):
                    jukebox.doStuff()
                    humble.data.setLine(0,"Select Function")
                    humble.data.setLine(1,"1:Radio;2:Jukebox")
                if humble.switch(2):
                    carryOn = False
                    time.sleep(0.2)
                time.sleep(0.2)
            humble.data.setLine(0,"Select Function")
            humble.data.setLine(1,"1:Music;2:Trains")
            time.sleep(0.2)
        if humble.switch(1):
            time.sleep(0.1)
            trains.doStuff()
            humble.data.setLine(0,"Select Function")
            humble.data.setLine(1,"1:Music;2:Trains")
            time.sleep(0.2)
        if humble.switch(2):
            time.sleep(BIGBUTTON)
            if (humble.switch(2)):
                humble.data.setLine(1, "")
                humble.scroll(0, "Shutting Down...")
                humble.data.setLine(0, "Shutting Down...")
                humble.data.setLine(0, "")
                os.system("sudo halt")
        time.sleep(0.1)
    hdt.done()
Example #6
0
def main():
    humble.init()
    hdt = humble.HumbleDisplayThread(humble.data)
    hdt.start()
    humble.data.setLine(0, "Select Function")
    humble.data.setLine(1, "1:Music;2:Trains")
    while (True):
        if humble.switch(0):
            time.sleep(0.2)
            carryOn = True
            while (carryOn):
                humble.data.setLine(0, "Select Function")
                humble.data.setLine(1, "1:Radio;2:Jukebox")
                time.sleep(0.2)
                if humble.switch(0):
                    piplayer.doStuff()
                    humble.data.setLine(0, "Select Function")
                    humble.data.setLine(1, "1:Music;2:Trains")
                if humble.switch(1):
                    jukebox.doStuff()
                    humble.data.setLine(0, "Select Function")
                    humble.data.setLine(1, "1:Radio;2:Jukebox")
                if humble.switch(2):
                    carryOn = False
                    time.sleep(0.2)
                time.sleep(0.2)
            humble.data.setLine(0, "Select Function")
            humble.data.setLine(1, "1:Music;2:Trains")
            time.sleep(0.2)
        if humble.switch(1):
            time.sleep(0.1)
            trains.doStuff()
            humble.data.setLine(0, "Select Function")
            humble.data.setLine(1, "1:Music;2:Trains")
            time.sleep(0.2)
        if humble.switch(2):
            time.sleep(BIGBUTTON)
            if (humble.switch(2)):
                humble.data.setLine(1, "")
                humble.scroll(0, "Shutting Down...")
                humble.data.setLine(0, "Shutting Down...")
                humble.data.setLine(0, "")
                os.system("sudo halt")
        time.sleep(0.1)
    hdt.done()
Example #7
0
def doStuff():
    global currentstation
    global stations
    #    humble.init()
    showPaused()

    print "piPlayer"

    currentstation = 0
    humble.data.setLine(1, stations[currentstation][0])
    humble.data.setScroll(1, False)

    playing = False

    # main loop, looking for button presses
    carryOn = True
    loops = 0
    while (carryOn):
        loops = loops + 1
        if loops > 50000:
            if playing:
                nowPlaying()
            loops = 0
        if (humble.switch(0)):
            if (not playing):
                print "Now Playing: " + stations[currentstation][0]
                showPlaying()
                humble.data.setLine(1, stations[currentstation][0])
                humble.data.setScroll(1, False)
                proc = subprocess.Popen(
                    "mplayer -quiet " + stations[currentstation][1],
                    #                                stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE,
                    shell=True,
                    preexec_fn=os.setsid)
                playing = True
                sleep(0.5)
            else:
                showPaused()
                #humble.data.setLine(1, "")
                os.killpg(proc.pid, signal.SIGTERM)
                playing = False
                sleep(0.5)
        if (playing and humble.switch(1)):
            os.killpg(proc.pid, signal.SIGTERM)
            currentstation = (currentstation + 1) % len(stations)
            print "Now Playing: " + stations[currentstation][0]
            humble.data.setLine(1, stations[currentstation][0])
            humble.data.setScroll(1, False)
            proc = subprocess.Popen(
                "mplayer -quiet " + stations[currentstation][1],
                #                            stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
                shell=True,
                preexec_fn=os.setsid)
            sleep(0.5)
        if (humble.switch(2)):
            if (playing):
                os.killpg(proc.pid, signal.SIGTERM)
            humble.data.setLine(0, "")
            humble.data.setLine(1, "")
            humble.data.setScroll(1, False)
            carryOn = False
Example #8
0
def doStuff():    
    global currentstation
    global stations
#    humble.init()
    showPaused()
    
    print "piPlayer"
    
    currentstation = 0
    humble.data.setLine(1, stations[currentstation][0])
    humble.data.setScroll(1,False)

    playing = False

    # main loop, looking for button presses
    carryOn = True
    loops = 0
    while(carryOn):
        loops = loops + 1
        if loops > 50000:
            if playing:
                nowPlaying()
            loops = 0
        if (humble.switch(0)):
            if (not playing):
                print "Now Playing: " + stations[currentstation][0]
                showPlaying()
                humble.data.setLine(1, stations[currentstation][0])
                humble.data.setScroll(1,False)
                proc = subprocess.Popen("mplayer -quiet " + stations[currentstation][1], 
                                        #                                stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE,
                                        shell=True,
                                        preexec_fn=os.setsid)
                playing = True
                sleep(0.5)
            else:
                showPaused()
            #humble.data.setLine(1, "")
                os.killpg(proc.pid, signal.SIGTERM)
                playing = False
                sleep(0.5)
        if (playing and humble.switch(1)):
            os.killpg(proc.pid, signal.SIGTERM)
            currentstation = (currentstation + 1) % len(stations) 
            print "Now Playing: " + stations[currentstation][0]
            humble.data.setLine(1, stations[currentstation][0])
            humble.data.setScroll(1,False)
            proc = subprocess.Popen("mplayer -quiet " + stations[currentstation][1], 
                                    #                            stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE,
                                    shell=True,
                                    preexec_fn=os.setsid)
            sleep(0.5)
        if (humble.switch(2)):
            if (playing):
                os.killpg(proc.pid, signal.SIGTERM)
            humble.data.setLine(0, "")
            humble.data.setLine(1, "")
            humble.data.setScroll(1,False)
            carryOn = False