Beispiel #1
0
def main():

    # Create objects
    mopidy = Mopidy()
    screen = ScrollpHatHD()
    switches = Switches()
    light = Light()
    monitor = PeakMonitor()

    while True:
        # Refresh screen
        screen.show()

        # Read buttons input and trigger actions
        btn = switches.check_input()
        if btn in ["play", "next", "previous"]:
            mopidy.ctl(btn)
        elif btn == "volume_up":
            screen.index = 0
            screen.gauge_value = mopidy.volume_up()
            screen.mode = "clock_vol"
        elif btn == "volume_down":
            screen.index = 0
            screen.gauge_value = mopidy.volume_down()
            screen.mode = "clock_vol"
        elif btn == "brightness":
            screen.set_brightness()
        elif btn == "switch":
            light.switchBulb()
        elif btn == "scan":
            screen.mode = "clock_butterfly"

        if screen.mode == "clock_vu" or screen.mode == "clock_butterfly":
            screen.gauge_value = (monitor.last_sample * 12 / mopidy.current_vol
                                  ) - (screen.gauge_value * -0.3)

        time.sleep(0.05)

    return
Beispiel #2
0
from mopidy import Mopidy
from logger import Logger

# sys.stdout = Logger()
# Ten Minutes
OFF_COUNTER = 60

not_home_counter = 0
home_counter = 0

startup = True

update_playlist = True

print "Downloading Playlists"
player = Mopidy()

network = Networking()
# Once above is done lets make it check every like... 5 seconds?
# We will need a better way to scan the network.
# Something quick that looks for the mac address of the phone

print '-wwwwwwwuuuuuttttt'
print network.check_macs()

while True:
    print 'Scanning...'
    found = False

    mac = network.check_macs()
    
Beispiel #3
0
from mopidy import Mopidy

PLAY_PIN = 25
LIGHT_PIN = 22
NEXT_PIN = 24
NEXT_TRACK_PIN = 17

GPIO.setmode(GPIO.BCM)
GPIO.setup(PLAY_PIN, GPIO.IN)
GPIO.setup(LIGHT_PIN, GPIO.OUT)
GPIO.setup(NEXT_PIN, GPIO.IN)
GPIO.setup(NEXT_TRACK_PIN, GPIO.IN)

print('Started...')
print('Getting Playlists...')
player = Mopidy()
print('Started')

# player.play_new_playlist()
# print player.set_volume(100)

play_input_prev = 1
next_input_prev = 1
timer = 0
shuffle = False  # Todo - We can prob get this from mopidy

while True:
    #####################
    ## PLAY
    #####################
    play_input = GPIO.input(PLAY_PIN)
Beispiel #4
0
    def setup_app(self):
        """ Initiate the mopidy device"""
        self.connection.add_handler(self.message_handler)
        self.internalid = None

        self.players = {}
        playerlist = self.get_config_option("Players", "[none]")

        if ',' not in playerlist:
            playerlist += ','

        # print "playerlist=" + playerlist

        for pl in playerlist.split(","):
            # TODO: remove spaces from p?
            if len(pl) > 0:
                self.log.debug('Player ' + pl + ' found')
                host = self.get_config_option("host",
                                              "127.0.0.1",
                                              section=pl,
                                              app='mopidy')
                port = self.get_config_option("port",
                                              "6680",
                                              section=pl,
                                              app='mopidy')
                self.connection.add_device(pl, "mopidy")
                self.log.info("Mopidy player %s added. host=%s, port=%s", pl,
                              host, port)

                q1 = Queue.Queue()

                mop = Mopidy(host, port, q1)
                if mop.connected:
                    self.log.info("Mopidy player %s connected.", pl)
                else:
                    self.log.info("Mopidy player %s NOT connected.", pl)

                player = {
                    "name": pl,
                    "host": host,
                    "port": port,
                    "mopidy": mop,
                    "queue": q1
                }
                self.players[pl] = player
                self.emit_media_info(pl)
                self.log.info(
                    "Now playing: %s - %s - %s ",
                    self.players[pl]["mopidy"].TrackInfo["artist"],
                    self.players[pl]["mopidy"].TrackInfo["album"],
                    self.players[pl]
                    ["mopidy"].TrackInfo["title"])  # TODO: change to debug

                if mop.runningstate == RunningStates.On:
                    self.connection.emit_event(pl, "event.device.statechanged",
                                               STATE_ON, "")
                else:
                    self.connection.emit_event(pl, "event.device.statechanged",
                                               STATE_OFF, "")

                background_thread = MediaInfoCollector(self, pl, q1)
                background_thread.setDaemon(True)
                background_thread.start()
Beispiel #5
0
PLAY_PIN = 25
LIGHT_PIN = 22
NEXT_PIN = 24
NEXT_TRACK_PIN = 17


GPIO.setmode(GPIO.BCM)
GPIO.setup(PLAY_PIN, GPIO.IN)
GPIO.setup(LIGHT_PIN, GPIO.OUT)
GPIO.setup(NEXT_PIN, GPIO.IN)
GPIO.setup(NEXT_TRACK_PIN, GPIO.IN)

print('Started...')
print('Getting Playlists...')
player = Mopidy()
print('Started')

# player.play_new_playlist()
# print player.set_volume(100)

play_input_prev = 1
next_input_prev = 1
timer = 0
shuffle = False # Todo - We can prob get this from mopidy

while True:
    #####################
    ## PLAY 
    #####################
    play_input = GPIO.input(PLAY_PIN)
Beispiel #6
0
from mopidy import Mopidy
from logger import Logger

# sys.stdout = Logger()
# Ten Minutes
OFF_COUNTER = 60

not_home_counter = 0
home_counter = 0

startup = True

update_playlist = True

print "Downloading Playlists"
player = Mopidy()

network = Networking()
# Once above is done lets make it check every like... 5 seconds?
# We will need a better way to scan the network.
# Something quick that looks for the mac address of the phone

print '-wwwwwwwuuuuuttttt'
print network.check_macs()

while True:
    print 'Scanning...'
    found = False

    mac = network.check_macs()