Adding callback to Volumio start/stop events

Hello! I am very new to Volumio and Linux in general. I need to change GPIO states of RPI to show sample rate and bit depth of file being played. So to achieve that, I am going to write Phyton program which will do such a task. But how can I add callback to Volumio start/stop events? Periodic polling is not very good. Or maybe I’m going wrong way. So please give an advise what is the best way to interact with hardware via Volumio: overlay, Phyton program or maybe something else.

Volumio uses MPD.
You can call what is playing through MPD.
like: volumio-plugins/plugins/miscellanea/mpd_oled at master · supercrab/volumio-plugins · GitHub

to use GPIO as requested:

1 Like

Yes! I did it in one of my plugin (start and stop events)

Have a look…

The trouble is writing a plugin for this task might be a bit overkill, maybe you can do it by running node.js instead?

are you going to upgrade it for V3? seems something odd with kew…

1 Like

Thank you very much! I will take a look on it definitely.

I am very new to Linux and by now have poor knowledge on its structure and functioning. I am planning to develope several sound Hats based on different DSPs which are assumed to be I2S master. The idea is that all DSP configuration at startup and regulation on the fly is going to be done by MCU built in Hat. So one does not need to add new software to RPI (new DSP - new software), everything is made by Hat itself, it is needed only to add to RPI one overlay, for example “Generic I2S master DAC”. But MCU needs to know active sample rate and bit depth to reconfigure DSP. When RPI is I2S master, MCU measures LR and BCLK frequencies and makes a decision on DSP project to be loaded. But when RPI is I2S slave I need to get active sample rate and bit depth from RPI somehow. By now it seems to me that changing GPIO state depending on sample rate and bit depth is the solution.
Could you please give some links to read about node.js?
Thank you very much!

Yeah, I think I am and I’ll probably add some new functionality to it too like a customized pulse duration and/or delay…

This is probably a good start:

Plugins are written in javascript which runs on node.js You’ll have to go through the rigmarole of writing a plugin but it’s quite straight forward enough.

Have a look at the code for GPIO buttons which shows how you can write to GPIO

Be careful though as when I experimenting I couldn’t do anything with PWM on the GPIO due to user permissions (I think). The library I was looking at was PIGPIO and it was running within the plugin.

You might be better of writing this thing in C++ as you’ll have better access to GPIO and you won’t need the faff of creating a plugin!

Thanks a lot, supercrab!

You’re welcome!