Skip to content

RPy-Frame is a python software made for Raspberry PI that enables you to make your own awesome-looking budget digital photo frame.

License

Notifications You must be signed in to change notification settings

peterdolenc/rpy-frame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RPy-Frame

RPy-Frame is a python software made for Raspberry PI that enables you to make your own awesome-looking budget digital photo frame.

Screens

Highlights & features

  • Makes a slideshow of your photos, where each image is displayed for a configured amount of time
  • Photos are played in random order, however, once a photo is played a few images that were taken at about the same time will be played after it. The aim was to see a part of the event.
  • Photos are either scaled down so that they fit the screen or enlarged and scrolled during the playback. Since I find this behaviour tricky to get right, there are quite a few configuration rules available to tweak it.
  • When photo does not take the full screen, a background will be generated with a pattern that will use the dominant colors of the current photo.
  • There's also support for a GPIO push button, that can do the following at the moment:
    • short press: advance to next photo
    • long press: show previous photo
  • You can also use keyboard keys: left, right, space, ESC
  • Almost everything is configurable - have a look at src/settings.py

Running the slideshow

You can run the presentation by executing the following:

python3 main.py /path/to/your/images/dir

You can always press Q or Esc during the presentation to stop it (to quit the app). If you don't specify the path to the images, then samples dir will be used.

If you want to explore configuration options of the app, then edit settings.py file. Currently there's no other documentation of all the settings but the settings.py, which is heavily commented.

You can run the program on your PC/Mac as well. Then you can use Q key to exit presentation or space to simulate the phisical button. On PC it's suggested to run it in dev/demo mode:

python3 main.py dev

Installation

Python 3

rpy-frame needs Python 3 to run. If you are using Raspberry PI, chances are you don’t have it yet and it might not be available through the apt package. Follow this guide to install it: https://gist.github.com/dschep/24aa61672a2092246eaca2824400d37f

Clone the repository

Clone rpy-frame repository:

git clone https://github.com/peterdolenc/rpy-frame.git

Try running it

cd rpy-frame/src
python3 main.py

Install python packages

Probably you will need to install all the missing python packages first. For most of pip packages you could instead make a global package installation with "sudo apt-get install python3-package-name" For me the recipe was the following:

sudo apt-get update
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libfreetype6-dev python3-setuptools python3-dev python3 libportmidi-dev
sudo apt-get install python3-numpy libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libavformat-dev libswscale-dev libjpeg-dev
sudo pip install --upgrade pip
sudo pip install pygame-ce
sudo pip install pillow
sudo pip install numpy
sudo pip install matplotlib
sudo pip install six
sudo pip install fast_colorthief
sudo pip install rpi-lgpio
sudo pip install aiohttp

Optional setup

There are two extra optional setup steps that you might want to configure.

Auto start presentation on boot

Create an sh file in your home directory called "slideshow.sh". This is the script that will get executed on startup. Set the path to your photos as desired. I also like to keep a log of last run somewhere.

/home/pi/rpy-frame/src/main.py /home/pi/photos/ >> lastrun.log &

There are multiple ways to configure auto start of an app when UI starts. I found this one to work best. Edit "/.config/lxsession/LXDE-pi/autostart" and add:

@/home/pi/slideshow.sh

For bookworm or newer add this file instead - /etc/xdg/autostart/rpy.desktop:

[Desktop Entry]
Type=Application
Exec=/home/peter/slideshow.sh
Hidden=false
NoDisplay=false

Also don't forget to setup your raspi to boot to desktop and configure that "start bar" to auto.hide. This will give you the full "kiosk mode" experience.

Add API port redirect

Raspbian linux probably comes with security restriction that only allows apps executed by the root to bind to ports bellow 1024. If you want the API to be served from default HTTP port 80, then the most flexible resolution is to actually run the API on another port, say 3000, and make a permanent redirect from 80 to 3000.

sudo apt-get install iptables iptables-persistent
sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
sudo su
iptables-save -c > /etc/iptables/rules.v4
exit

Turn off the display during the night to save energy

I used crontab for that. The commands handle raspi's video out and basically get the screen to go to standby. Here are the two crontab commands that will add a schedule to turn off the display every day at 22.30 and turn it back up at 05:15 in the morning. Feel free to adjust to your needs.

crontab 30 22 * * * vcgencmd display_power 0 >/dev/null 2>&1
crontab 15 5 * * * vcgencmd display_power 1 >/dev/null 2>&1

On bookworm or newer you can use these instead:

crontab 30 22 * * * xrandr --output HDMI-1 --off >/dev/null 2>&1
crontab 15 5 * * * xrandr --output HDMI-1 --auto >/dev/null 2>&1

Or use the script posted by p1r473 here: https://forums.raspberrypi.com/viewtopic.php?p=2193330&hilit=ddcontrol#p2193326

Setting up the phisical button

Generally any pull-up button will work as long as it will read 1 when pressed and 0 when idle. By default the app will expect the button to be connected to GPIO header pin nr. 23. But it can be configured in settings.py.

You can use this little snippet to debug and test your button prior to using it with your app:

import RPi.GPIO as GPIO

# use P1 header pin numbering convention
GPIO.setmode(GPIO.BOARD)
GPIO.setup(23, GPIO.IN)
print(GPIO.input(23))

Building the picture frame hardware

It's not too difficult or expensive. In any case you will need:

  • Rasperry Pi (any as long as it has HDMI)
  • power adaptor downto 5V for raspi; can be combined with whateve the monitor uses, but it of course depends
  • a nice wooden picture frame; it has to be larger than the screen so that you have some space on the edges to fit the components
  • optional: phisical button

Missing component is the screen. There are generally two approaches.

  1. You buy used PC screen: this is the best and by far the simplest approach. The screen will already come with the panel, the driver board, backlighting and power adaptor. Be careful to find one that uses slim components (most of them do). This is suitable, if you are building a large photo frame. I really like my 24" inch photo frame. And one more tip: you must go for LED IPS screen if you value your photos. You will thank me later.
  2. You have a spare screen from an old laptop you would like to use. This is going to be more difficult as you will have to source the backlighting driver, power adaptor and the driver-board yourself. Search ebay for a good board where your EXACT model of the screen panel is listed as supported. Universal boards only gave me TONS of headaches.

Credits:

Code for the patterns taken and adapted from: https://github.com/eleanorlutz/AnimatedPythonPatterns/blob/master/PatternMaker.ipynb

Original idea and some base concepts for pygame photo frame: https://github.com/gitajt/PGslideshow

About

RPy-Frame is a python software made for Raspberry PI that enables you to make your own awesome-looking budget digital photo frame.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages