Hi,
maybe i have overseen some threat here, otherwise maybe a new useful feature:
"When PiCorePlayer is playing a GPIO Port ist pulled up or down"
My use case: Swithing the Amp with the already configurable "Power GPIO" i would like to use a second GPIO to switch a two way relay for toggling the line input of the amp to external source, when picoreplayer is paused.
Thanks and
best Regards
Axel
Results 1 to 10 of 30
-
2019-03-05, 08:24 #1
- Join Date
- Dec 2017
- Posts
- 57
Feature request picoreplayer: Play state to GPIO
-
2019-03-05, 13:06 #2
hi Aki7,
This should be possible with a simple shell script. People have been doing similar things to a drive LEDs etc.
Use wiringPi to set GPIO (or shell commands).
Use $pcp mode to determine if squeezelite is play/stop.
I assume you know about the hardware for a relay. A GPIO can not drive a relay directly.
In the home directory there are a couple of scripts that should give you some ideas.
https://www.picoreplayer.org/how_to_..._via_ssh.shtml
https://www.picoreplayer.org/pcp_cli.shtml
regards
Greg
-
2019-03-05, 15:10 #3
- Join Date
- Dec 2017
- Posts
- 57
Hi Greg,
thanks for the fast response. Relays used already, no problem with this.
Need some help with:
On play -> GPIO high
On pause -> GPIO low
Event driven. So i think in my small knowledge, squeezelite code has to be changed. I am not a linux freak, but lot of programming in former days.
Axel
-
2019-03-05, 16:28 #4
hi Axel,
Although not a good as an interrupt solution a simple loop inquiry of LMS may be OK.
The command "pcp mode" returns "play" or "stop". Do the inquiry every second and set relay appropriate. This only create a 1% load on CPU and little network traffic, not enough to cause problems.
regards
Greg
-
2019-03-05, 17:36 #5
The code used to be almost that way, but it was causing more problems than anything. So it was changed to what it is now.
I would recommend installing the powersave plugin to LMS and that will power down your player if it is paused for a period of time.
*Edit* read the OP, we are not doing two GPIO's, so you need to use the script method Greg mentioned, or build your own version of squeezelite. Source code is here
https://github.com/ralph-irving/squeezelite
Take a look at gpio.c and then also look at all sections of the code flagged with #if GPIO
You can also have a look at the commit https://github.com/ralph-irving/sque...c6dff0283a05a1 that removed the gpio trigger on a pause event.Last edited by paul-; 2019-03-05 at 17:59.
piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
-
2019-03-06, 06:47 #6
- Join Date
- Dec 2017
- Posts
- 57
Hi Greg, hi Paul,
thanks for your input.
@Greg: Polling from the LMS ... feels not so elegant for me ;-) and will result in delayed sound on play start in my use case. There seems to be some code, discussed on this forum. Not shure if it has worked finally.
@Paul: Have taken a look at your 2nd link. Maybe my misunderstanding, but i would like to set a GPIO according to play state, not reading a GPIO and doing something afterwards.
I have neither linux nor c knowledge, so creating my own fork seems not so realistic for me :-) Anyway, do you have a hint, in which module squeezelite is receiving commands from the LMS? My idea would be first stage, writing or deleting a file (or some flag variable) according to play state. So polling this file or "global environment variable" could be done asynchron by other modules, local on the "machine". Maybe every 1/10 s.
Setting the GPIO synchron from squeezelite may have introduced some timing problems? On the other hand, there should be time enough, when squeezelite changes his play state.
regards
Axel
-
2019-03-06, 09:24 #7
All you would need to do is initialize a second GPIO and then track the pause state. But if you don't know C programming, then your going to have to be at the mercy of someone wanting to do this for you.
piCorePlayer a small player for the Raspberry Pi in RAM.
Homepage: https://www.picoreplayer.org
Please donate if you like the piCorePlayer
-
2019-03-06, 09:48 #8
- Join Date
- Dec 2017
- Posts
- 57
Paul,
yes. Therefore the "feature request". I can only hope and pray to the c lords :-)
Axel
-
2019-03-06, 13:14 #9
hi Aki7,
FYI: Although we use squeezelite, it is used by lots of other "players" and is really maintained separately from piCorePlayer. We have been very lucky to have Ralphy as part of the pCP Team, but his squeezelite work covers all the other platforms.
regards
Greg
-
2019-03-06, 15:29 #10
- Join Date
- Dec 2017
- Posts
- 57
Greg: Ok, so i understand: Little hope for this feature, only useable with GPIO devices.
Paul: Thanks for the hints, sounds easy. Do you know if the „play state“ is published by squeezelite in any form for usage from other modules? Or: Can a script „request“ the play state from squeezelite?
Can i support the experts on the solution for this problem, f.e. with some bottles of good wine? :-)
Axel