logo
background
 Home and Links
 Your PC and Security
 Server NAS
 Wargames
 Astronomy
 PhotoStory
 DVD making
 Raspberry Pi
 PIC projects
 Other projects
 Next >>
[The software] [Using samba] [Using a 4Gb SDHC card] [Using fbi] [Downloading the scripts] [Auto-running the scripts] [Alternatives to fbi]
Pi PhotoFrame (fbi)

The software

As usual, what you need depends on what you want to do !

Many 'NOOBS' users will go straight for the GUI (startx) .. however instead of 'photo-frame', that means we have a computer with a 'screen saver' to program. For me, the problem of a GUI is it's complexity - my experience with a PC based Photoframe convinced me that there would always be 'something' that prevented the display running 'as it should' (and tracking down the 'something' can be next to impossible)

So I started by running (testing) everything from the command line interface (CLI), after which the commands were 'transferred' to a simple Bash shell script. As usual, of course, nothing was ever as simple as it should be (for one, to allow the Bash shell script to be 'launched' after a power-up sequence, it must be 'executable' (chmod 775 or +x), and second, if you want to keep things 'simple', the script should be in the same folder as the images you want to display).

After looking into various command line display utilities (see at end, below) I eventually discovered that the simplest (fbi) was the only one that could be 'convinced' to do the job

[top]

Using samba (and finding folders)

One 'feature' for *nix systems is that each 'logged in user' has their own 'home' directory (just like in Windows you default to your own desktop).

This is fine when multiple users are doing multiple different things, but a REAL PAIN when you are trying to get the scripts you setup in your 'home' to launch at power-on (when 'home' = system) and then find photos in some other (hopefully 'fixed' folder)
 
The 'secret' is to make ALL new folders fixed 'off the root' (for example "mkdir /photos/" and NOT "mkdir photos/") and place the scripts and photos in them, and not in your 'home# directory

Needless to say, everything is a lot easier (testing, modification, loading photos, backup etc) if the 'root' of your photoframe directory 'structure' is 'visible' from your PC

This means installing 'samba', which allows a Pi directory (and everything in it) to be seen as a 'mapped network drive' on a PC

(+) Installing samba - (the Pi as a Network Share on your PC)


[top]

Using a 4Gb SDHC card

The 'easy' way to 'back up' a Pi is to 'image' the contents of the SDHC card to a file on your PC using Win32 disk Imager - and then 'write' that out to a new card that's 'double the size'

To 'restore' a back-up to the same sized card usually means 'shrinking' the Pi partition sizes and making a new backup - it's possible but a right pain - for details, read the Note below :-

(+) How do I change the Pi System partition size ?

Since I'm going to use a cheap Class 4 8Gb card for the final Photoframe Project, starting with a 4Gb card avoids all that partition size issues

After you copy the 4Gb image to an 8Gb SDHC, boot the 8Gb and run the init_resize.sh script :-
sudo init_resize.sh
(this will 'auto-resize' the 4Gb partitions to the new 8Gb card)

[top]

Using fbi

The 'Frame Buffer Interface' program (fbi) has one major shortcoming = it can't be run as a background task (and can't even be 'launched' from a background running script).

When fbi is launched it 'grabs focus' i.e. runs in the foreground, preventing a script from executing any other instructions, until it has finished displaying all the images you specify.
 
For a photoframe, the obvious approach is to tell fbi to display photos 'for ever', in which case fbi will 'lock up' your command terminal window preventing that 'terminal session' being used for anything else. The other problem is (of course) that fbi only shows the images that were present when it is launched (so you can't update a 'running' slideshow)
 
If, on the other hand, you tell fbi to display images 'one at a time' (so you can update), there will be a very visible 'gap' between images.
 
When fbi is run 'one image at a time', after showing the 'one image' it switches the display back to the CLI terminal window before allowing you to launch it again to show the next image. Worse, fbi appears to have some sort of 'memory leak', since, after showing only a few dozen images 'one at a time' (on Wheezy) it filled up all the RAM and crashed the Pi !
 
Of course you can tell it to 'run for-ever' and then 'kill' fbi (and re-launch it) in order to update the photos - however whilst that may 'fix' the RAM leak, the display still reverts to the 'terminal session' (boot status text), plus, after a 'kill', an on screen 'Oops: terminated' complaint, all of which is very noticeable :-)

In the end I gave up and just designed the system so fbi could be launched last and run in 'loop for ever' mode. This meant 'cheating' fbi in order to 'update' the display

The trick is to let fbi 'loop for ever' showing a 'fixed' sequence of a few photos and then 'swap them out' by 'overwriting' them with new ones. This (the swap out) can be done by using a second script running 'in the background'.
 
It turns out that this only works if you start fbi with AT LEAST 3 photos (with 2, fbi just pre-loads them both into RAM - despite the use of the '-cachemem 0' option - and thus never picks up the new file contents, however with 3 (or more) fbi will actually fetch the 'next' photo from the (SDHC card) each time).
 
The really clever bit is to use 'alias' links, so you can give fbi 3 'fixed' file names that all 'point' to the same 'real' image file.
 
A script running in the background can then update the photoframe image by changing the single 'real' image file that all the 'alias links' are 'pointing at' (instead of having to work out 'which one' to change next)
 
This has the advantage that there are no 'gaps' between images, and, so long as the 'fbi 'cycle time' is short (3 seconds is about the minimum) 'updates' will appear quickly (in 1/3rd the cycle time)

The final trick is to avoid wearing out the SDHC card directory by holding all the 'alias' files in a ram-disk (tmpfs).

[top]

Downloading the scripts

To download the fbi script, right click and 'save link as' go-fbi.sh script (Note 1).
Further details can be found below :-

To download the 'companion' background script, right click and 'save link as' go-photo.sh (Note 1).
Further details can be found here :-

Note 1. If your don't 'Right click' to save the .sh scripts, you will get 'File not found'

[top]

Auto-running the scripts

So the Photoframe starts up automatically at power-on, just add your scripts to rc.local, the list of the 'things to be done' at power-on

cd ..
cd ..
cd etc
sudo nano rc.local
 
If you placed the scripts in the /photos/ folder, add the following directly above the 'exit 0' line :-
bash /photos/go-photo.sh &
bash /photos/go-fbi.sh

Don't forget the '&' after go-photo.sh, so it runs in the background :-)

[top]

Alternatives to fbi

Before I managed to get fbi working the way I wanted, I tried a number of other utilities (with even less success) :-

(+) Other display utilities


Next I add a GPIO sensed 'button' to control the Photoframe 'display of the next photo

Next page :- Pi GPIO - (Photoframe pause button)

[top]