Пример #1
0
    def test2Array(self):
        try:
            if self.config.has_key("2array_mic_hat"):
                sys.path.append(self.config["2array_mic_hat"])
                from pixels import Pixels
                pixels = Pixels()
                pixels.wakeup()
                time.sleep(3)
                pixels.off()
                time.sleep(2)
                pixels.think()
                time.sleep(3)
                for i in range(0, 5):
                    pixels.speak()
                    time.sleep(1)

                pixels.off()
                time.sleep(1)
        except Exception as e:
            print e.message
#Thread for running music in the background
def musicThread():
    global stop_threads
    global player
    global Instance
    while True:
        playMusic(Instance, player)
        if stop_threads:
            break
    print("Music thread stopped")


#Indicate program startup
pixels.wakeup()
pixels.speak()

_thread.start_new_thread(musicThread, ())  #Start music playlist
print("Initializing music player")
while (player.get_state() != vlc.State.Playing):
    None  #Wait for player to be initialized
time.sleep(2)
player.pause()
print("Music paused")
pixels.off()

previous_time = time.perf_counter()  #Initialize music timer
while True:
    #Power off button pressed
    if GPIO.input(BUTTON_PIN) == 0:
        pixels.wakeup()