picoFlamingo Pi Edition. Raspberry Pi based mini presentation system

Some weeks ago I had to show a set of images in something you can "wear" and that sounded as a good opportunity to play a bit with my Raspberry Pi. The first solution (out of three :) I come out with was to convert the images into a big PDF file (thanks ImageMagick) and then use xpdf cool "-remote" flag to navigate the pictures. Do not know about -remote?... Type "man xpdf"!

(Check the video at the end of this blog entry...)

As the system had to be autonomous I need to provide some mean to interact with the system and a couple buttons looked like a good solution. I found a great tutorial from Adafruit (http://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberr...) that did basically what I needed. So I build the tutorials circuit in a small protoboard and changed the Python script to use xpdf instead of mpg123.

Everything worked OK on the breadboard prototype but it was a bit slow. Anyhow I then prepare a second piece of protoboard to include my three buttons. Yes, during the testing I realised that I need a way to switch the system off. Then I put the small board with the buttons on a piece of wood and I was done with the hardware.

picoFlamingo Mini Presentations with Raspberry Pi - ControlpicoFlamingo Mini Presentations with Raspberry Pi - Control

The wood I used was not very high quality and it broke down around the hole to access the buttons. So I covered the small control with some plastic cut off from a folder.

picoFlamingo Mini Presentations with Raspberry Pi - Control Work in ProgresspicoFlamingo Mini Presentations with Raspberry Pi - Control Work in Progress

I still have to improve my manual skill but the control looked a bit better... and, as a plus, it looked a bit like a robot face :)

picoFlamingo Mini Presentations with Raspberry Pi - Control - Robot Face :)picoFlamingo Mini Presentations with Raspberry Pi - Control - Robot Face :)

So I was done with the hardware but I still had to sort out some hardware issues. I changed the initial run level in /etc/initab to start the X-Windows system directly. That you will probably already know how to do it. Then I changed the lightdm configuration to allow automatic login.

For that you need to edit the file /etc/lightdm/lightdm.conf and uncomment the following lines:

Finally, I didn't want the system to boot in a Desktop, I just need to start the X-Server and launch my xpdf application on remote mode. For that purpose I added a file named .Xsession on the pi user's home directory with the following content:
xpdf -fullscreen -remote viewer /home/pi/ui.pdf &
sudo /home/pi/buttons.py
This starts xpdf in fullscreen and remote mode using identifier viewer for remote controlling the application. Then it starts the buttons.py script which actually drives xpdf whenever a button is pressed. The solution worked OK but Raspbian takes a long time to boot and also to switch down so I tried something different. Some years ago I was playing with uClibC and buildroot (http://www.buildroot.net/) and I decided to give it a try to build a minimal bare bones file system. It was very easy to get a workable file system with buildroot but as I wanted it to be very minimal I left out the X-Windows system and tried to make the thing work on the framebuffer. So I activate the framebuffer support on the buildroot configuration system Bad news are that I cannot use xpdf directly on the framebuffer without an X-Server. Good news were that buildroot can compile for me a framebuffer image viewer that I can easily control from a script. The new system booted up in a few seconds into this framebuffer image viewer controlled this time by a shell script, as I did not wanted Python on the minimal configuration. Unfortunately there were some glitches with the screen update and I was not happy with the result, so I had to try something else. A great thing about build-root is that it makes available a complete toolchain for your target platform (either compiling one or downloading it). As freetype library was already in the system and picoFlamingo works OK with the framebuffer I just had to recompile my beloved presentation system and dump it on the new file system. I have to admit I haven't done it properly as I was running out of time. Basically I copied the libraries I needed (all that stuff on /opt/vc) in a place where my toolchain could find them. Anyway, I copied my cross-compiled picoFlamingo into my brand-new framebuffer based buildroot filesystem. Then I added a service start script like this: /etc/init.d/S60slide
# Start the slides....

case "$1" in
 	echo "Starting Slides..."
	echo -n "Stopping Slides (doing Nothing)..."
	"$0" stop
	"$0" start
	echo "Usage: $0 {start|stop|restart}"
	exit 1

exit $?
That made the trick and picoFlamingo started straight away after booting. The pf.sh script just launches my button monitoring scripts in background and then starts picoFlamingo. Something like this: pf.sh

/root/buttons.sh &
cd /usr/share/pf/examples

/usr/bin/picoFlamingo --w 750 --h 550 --dir pf > /dev/null 2>&1
picoFlamingo (http://paperming-designs.com/picoflamingo) is network enabled so, the easiest way to command it from my buttons.sh script is to use Netcat. NetCat can be compiled directly from the buildroot environment, however it didn't worked for me this time. Problem was that the connection was not broken after sending the command and therefore, only the first command was interpreted. So, I had to fallback to that tool that has saved my life some many times: NetKitty (http://www.papermint-designs.com/dmo/prj-netkitty.html). Netkitty does not depends on anything so it pretty unlikely you will expect compilation problems with it. Just dumped to the buildroot toolchain and I got a Raspberry Pi executable. Using NetKitty, my control scripts now looks like this: buttons.sh

# Set up GPIO 7 and set to input
echo "4" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio4/direction

echo "17" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio17/direction

echo "18" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio18/direction

while true; do

	B1=`cat /sys/class/gpio/gpio4/value`
	B2=`cat /sys/class/gpio/gpio17/value`
	BX=`cat /sys/class/gpio/gpio18/value`

	#echo "B1: $B1 B2:$B2 BE:$BX"

	if [ $B1 -eq "0" ]
		#echo "Button 1"
		echo "next" | nk -c T,,5000
	if [ $B2 -eq "0" ]
		#echo "Button 2"
		echo "prev" | nk -c T,,5000
	if [ $BX -eq "0" ]
		echo "Button Exit... Power OFF"

	usleep 50000; 
So with all this, the final result looks like this: cheers! The picoFlamingo Team