Quantcast
Channel: Support - Pimoroni Buccaneers
Viewing all articles
Browse latest Browse all 6853

MPD and Button Shim

$
0
0

@kit2 wrote:

Hi all, I’m having trouble with my MPD script, what I’m trying to do is whenever I press a button, it should perform an action in MPD.

What I’m finding is that all of my MPD codes are executed when the python script is run, instead of when a button is pressed.

If I press a button, I’ve found it won’t perform the MPD command, and execute another part of the code i.e print(“Japa”)

Could someone have a look at this and tell me where I’m going wrong?

I’ve also tired this with using subprocess, and the MPD python library and get similar results, below is an example code I used to test if the basic functions are working.

Many thanks,

Kit

================
#!/usr/bin/env python

_ import signal_
_ import buttonshim_
_ import subprocess_
_ import os_

_ @buttonshim.on_press(buttonshim.BUTTON_A)_
_ def button_a(button, pressed):_
_ buttonshim.set_pixel(0x94, 0x00, 0xd3)_
_ _
_ print(“Japa”)_
_ os.system (‘mpc clear’)_

_ os.system(‘mpc load Japa’)_
_ os.system(‘mpc repeat on’)_
_ os.system(‘mpc play’)_

_ signal.pause()_

Posts: 8

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6853

Trending Articles