I’ve just had a go, but no luck, are you sure that the speakerphat.py you linked to was the file you were thinking of? It doesn’t seem to start the socket server. I noticed that blinkt_server.py was more fleshed out and referred to both the socket_server and speakerphat, so I’ve had a tinker with it and seem to have it working.
I renamed blinkt_server.py to speakerphat_server and edited it to the following:
#!/usr/bin/env python3
import socket_server
import signal
import speakerphat
BRIGHTNESS = 255
class OutputSpeakerPhat(socket_server.OutputDevice):
def setup(self):
self.base_colours = [(0,0,0) for x in range(speakerphat.numpix)]
self.generate_base_colours(BRIGHTNESS)
def generate_base_colours(self, brightness = 255.0):
for x in range(speakerphat.numpix):
self.base_colours[x] = (float(brightness)/speakerphat.numpix-1) * x, float(brightness) - ((255/15) * x), 0
def display_fft(self, bins):
pass
def display_vu(self, left, right):
left /= 2000.0
right /= 2000.0
level = max(left, right)
level = max(min(level, 8), 0)
for x in range(speakerphat.numpix):
val = 0
if level > 1:
val = 1
elif level > 0:
val = level
r, g, b = [int(c * val) for c in self.base_colours[x]]
speakerphat.set_led(x, int(val * 255.0))
level -= 1
speakerphat.show()
def cleanup(self):
self.display_vu(0, 0)
socket_server.run(OutputSpeakerPhat)
I then created a variable called numpix in speakerphat.py and set it to 10,
I’m using python 3, so I also had to change
os.chmod(SOCKET_FILE,0777) in socket_server.py
to
os.chmod(SOCKET_FILE,0o777)
Then in my script I start the server with:
import speakerphat
import speakerphat_server
VU = speakerphat_server.OutputSpeakerPhat()
VU.display_vu(0,0)
Now sn3218.disable/enable work fine with VLC output!