set gpio pin after start of piCoreplayer

Status
Not open for further replies.
Hello,

I am searching for a solution to set a GPIO pin from raspberryPi after starting piCoreplayer.
During playing music a GPIO pin can be set over web UI.
But how can I set one generally after starting?

I want to control a muting from power on to a running piCorepayer.

Many thanks
 
Who said anything about Python???

It's a shell script. That is a text file that contains commands, one per line, just like you would type them at the command prompt. The file should have the extension '.sh' for "shell script". After you create it, you change the file attributes to make it an "executable" file. Then you type the filename and it runs. This is very basic linux programming, just like a Windows batch file if you know what that is.

So, open an editor. Enter the following three lines exactly as shown:
Code:
#! /bin/bash
echo 'Hello, I am your first script file!'
date
Now save the file as "test.sh".
Open a linux shell (where you get to the command prompt), and change directory to where the file you just created is saved. Then type
Code:
chmod +x test.sh
Now run the file by typing at the command prompt:
Code:
./test.sh
Make sure to include the "./" part of the command. You should see the message, followed by the time and date.

If you are stuck, use Google and teach yourself this very basic skill. It is really not hard and is very, very useful.

If piCoreplayer or whatever doesn't give you this kind of access to the OS, etc. then this won't work. Just install a regular version of some kind of linux and then you can do whatever you wish with the system. Otherwise you are stuck with the pre-programmed PiCoreplayer interface. That's no better than some piece of fixed hardware. You are using a general computer - make use of it!
 
Last edited:
piCoreplayer just uses an *extremely* small version of Linux (piCore) running in RAM.

pCP - piCorePlayer

A couple of points, piCorePlayer:

  • Uses ash rather than bash to save a few MB.
  • As it runs in RAM, you must backup your script by doing a "pcp bu" to make it available after a reboot.
  • piCore has microPython installed but very few libraries.

regards
 
@ CharlieLaub
thanks for information. Using a shell script is not the problem. I searched a "best way solution" on picorePlayer.

I tried something and after permission problems (user tc) I found working shell commands. Here my example for GPIO pin 18 setting to "1":

sudo chown tc /sys/class/gpio/export
sudo echo "18" > /sys/class/gpio/export
sudo chown -R tc /sys/class/gpio/gpio18/
sudo echo "out" > /sys/class/gpio/gpio18/direction
sudo echo "1" > /sys/class/gpio/gpio18/value

I will try the same with microPython.
Are there any differences to "normal" Python I have to consider?
 
hi papaarrugada,

Here is an GPIO code example from a couple of years ago:

Be real neat if - pink fish media

In our "piCorePlayer sourceforge repository" there is a extension called Audiophonics-powerscript.tcz that uses wiringPi library. Accessible via [Main Page] > [Extensions].

While these example are not exactly what you are doing they may help.

piCore included microPython to speed up one of the piCore startup scripts (loading extensions I think?) so there is only a couple of python libraries included by default.

regards
 
Hi Greg,


thanks.
I studied this link and found a very interesting example to poll buttons with GPIO input and controlling the player.
This can be a next step and a further extension for a simple standalone player. Buttons for "next" and "previous" are also possible.


My main intension is the power on/off plop.
I added my script to switch the GPIO in /opt/bootlocal.
And of course it comes earlier than the -G parameter of the player instance.


What is the idea for the -G parameter switching a GPIO?
I have 4 instances running and I can setup 4 different GPIOs (low or highactive).


I think it makes no sense to use it for avoiding power on/off plops. Right?
I have 8 mono amp boards.


Probably its better to use one GPIO (in /opt/bootlocal) for switching power off for all over a relay and use -G parameters for muting all amp boards over optocoupler?
I have 2 power supplies.


regards
 
Status
Not open for further replies.