Shell Script to Run at Boot

Hi everyone. I have tried to add my python script to systemd to run as my ras-pi boots. However, I have not been able to figure out where/how to add the additional arguments such as “–led-cols=64” and so on in that script. If anyone else has this figured out and would like to pass along their knowledge that would be much appreciated.

On a similar note, is there a way to include arguments such as --led-brightness in the python script? I am trying to change the brightness of the display based off the current time and have not been able to figure out how.

Hi porky,

You can find python examples in the bindings directory :

And change options like this :
> # Configuration for the matrix

options = RGBMatrixOptions()
options.rows = 32
options.chain_length = 1
options.parallel = 1
options.hardware_mapping = 'regular'  # If you have an Adafruit HAT: 'adafruit-hat'

For brightness in python see this :

Hope it’ll help you :grin:

Not quite what you want, but I use the /etc/rc.local file to set things up on a boot or reboot. Here’s the key lines:
cd /home/pi/ftp/files/rpi-fb-matrix
sudo ./rpi-fb-matrix --led-brightness=75 --led-slowdown-gpio=2 matrix64.cfg&
That ampersand means the rpi-fb-matrix app runs in the background so that anything sent via hdmi will get displayed on the matrix panels (in my case four 64*64 panels).

I’ve also arranged that whenever a USB storage device (eg thumbdrive) is plugged into the pi, devmon detects this and automatically runs a playlist of videos if the drive contains one.

I also like to add a ‘sleep 30’ before starting any code, because rgb-panel code can overwhelm the CPU in a way that wifi stops working and you can’t ssh in anymore, so it’s useful to be able to ssh in and disable stuff in 30sec before the device gets wedged :slight_smile:

hello,
im researching through the posts for ideas, im a complete newbie (started an online python boot camp this week)
One of the things im looking to do is have the image-viewer display a file (png or gif) that would be displayed on the second HDMI port of a pi4.
OR
ignore the HDMI port and just display direct to the LEDs…

am i reading write the code example you gave displays whatever is on the HDMI to the LEDs by listening?
cd /home/pi/ftp/files/rpi-fb-matrix
sudo ./rpi-fb-matrix --led-brightness=75 --led-slowdown-gpio=2 matrix64.cfg&

if so, does this mean i can have this code in a startup script and then it will output?

thanks in advance

Yes - that rpi-fb-matrix app runs in the background and intercepts and copies whatever is sent to the hdmi port to the led panels. Works for movies and still images. It works even if there is no monitor attached to the hdmi port.

great and thanks for the quick reply! is there a way to specific which hdmi port? for the Pi4?
and is there a way to add a second HDMI port (virtually) for Pi3 and use this?
this could be my arcade leds answer! :slight_smile:
thanks again

Hi Jay

I’m using a Pi 4 which hasd two cdmi ports. I play videos using omxplayer which lets you choose which had port to use - see this page.

Dave

Thanks for sharing…
How would one send to the second display and then have rpm matrix display it then?
I can send a file to the second display using omxplayer but I would like the led matrix to display the same thing? Sorry for keep asking…
I looked at the rip matrix and couldn’t find a switch to select hdmi?

Jay - I need more information before I can help:

  1. which version of raspbian are you running - raspbian_lite? If so you are running headless (which is good)
  2. do you/can you use ssh and the terminal app on your pc to log on to the pi? (
    If you can then you can issue commands to the pi to cancel running apps and start new ones.

hey,
Thanks for reply/help…i can SSH into the PI.
As i said i would like to mirror the second HDMI not the primary to the RGB…the software im using for the second display shows either gif/PNG files as i change menus on the main screen…
Its retropie…using emulation station…so when i choose a game or emulator the script chooses the PNg/gif and displays it on the second HDMI…
therefore i would like to mirror the HDMI output to the RGB… :slight_smile: .

I’m not sure if this will help but there are options in the /boot/config.txt file to do with hdmi. See
Video options in config.txt - Raspberry Pi Documentation
for information.

In my case I have:
hdmi_force_hotplug=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 1024 2014 60 6 0 0 0

Dave

Just want to thank you for your help with this problem.
There’s just no specific info out there on the syntax to make it autostart. Thanks to you it’s now working!