示例#1
0
def display_array(data):
    """
	Display a 10-element array of 0-255 values on the speakerphat display
	"""

    for n in range(0, 10):
        set_led(n, data[n])
    show()
示例#2
0
def test_vumeter():
    speed = 20

    for i in range(1000):
        offset = int((math.sin(time.time() * speed) * 5) + 5)

        speakerphat.clear()
        speakerphat.set_led(offset, 255)
        speakerphat.show()
示例#3
0
def retune():
    config.station += 1
    # Assumes there are 7 stations
    if config.station > 7:
        config.station = 1
    os.system("mpc play " + str(config.station))
    # updates the Speaker pHat LEDs to show the station
    clear()
    for x in range(config.station):
        set_led(x, 180)
    show()
    # stops the clock subprocess and shows the station on the 7 seg
    config.proc_Popen.kill()
    config.segment.clear()
    config.segment.write_display()
    config.segment.set_digit(3, config.station)
    config.segment.write_display()
    time.sleep(4.0)
    config.segment.clear()
    config.segment.write_display()
    config.proc_Popen  # This is the bit that's got me baffled.
 def flash(self):
     for i in range(10):
         speakerphat.set_led(i, self.status[i])
     speakerphat.show()
示例#5
0
#!/usr/bin/env python

import math
import time
import sys

sys.path.append('../python/')

import speakerphat

speed = 4

for i in range(1000):
    offset = int((math.sin(time.time() * speed) * 5) + 5)

    speakerphat.clear()
    speakerphat.set_led(offset, 255)
    speakerphat.show()
示例#6
0
文件: sound.py 项目: kghite/mahri
 def pause_mp3(self):
     os.system('dbuscontrol.sh pause')
     for x in range(10):
         speakerphat.set_led(x, 0)
     speakerphat.show()
示例#7
0
文件: sound.py 项目: kghite/mahri
 def start_mp3(self, filepath):
     os.system('omxplayer -o local %s &', filepath)
     speakerphat.clear()
     for x in range(10):
         speakerphat.set_led(x, 255 / (x + 1))
     speakerphat.show()
示例#8
0
        set_led(x, 180)
    show()
    # stops the clock subprocess and shows the station on the 7 seg
    config.proc_Popen.kill()
    config.segment.clear()
    config.segment.write_display()
    config.segment.set_digit(3, config.station)
    config.segment.write_display()
    time.sleep(4.0)
    config.segment.clear()
    config.segment.write_display()
    config.proc_Popen  # This is the bit that's got me baffled.


shutdown_btn = Button(17, hold_time=3)
shutdown_btn.when_held = shutdown

retune_btn = Button(23)
retune_btn.when_pressed = retune

# starts clock.py
config.proc_Popen

# sets the Speaker pHat LEDS to indicate the station
clear()
for x in range(config.station):
    set_led(x, 128)
show()
os.system("mpc play " + str(config.station))
pause()