Wednesday, November 26, 2008

DIY: Digital Photo Frame

I decided to convert my old Compaq Evo N610c into a digital photo frame as it hasn't been used in over a year...and the battery died a long time ago. I bought a D-Link AirPlus wireless card since it seems to be using the Atheros chipset which is well supported by DSL (using the madwifi driver).

The first & most important part was setting up the software. This post will discuss the software in detail and future posts will document the hardware transformation.

After exploring for a bit, I decided to use the McDPF package (it is the most complete package I found) which installs over Linux...and hence, there are no software costs as well. In addition, I didn't like the fact that McDPF can either display photos off of the harddrive or through frame channel but not both at the same time. Thus, I encorporated a script named 'picasaweb-download' which I found online so that the photos can be downloaded and displayed in line with the rest of the photos. I also extended the web interface so that the picasaweb-download script can be run and configured through the web interface.

The problem, is that it did not work out of the box by following all the install instructions. After debugging for a while, I finally got it to work.

The first step is to install "Damn Small Linux" (I used version DSL v. 4.4.10) as per McDPF installation page. DSL v 4.2.5 does not support WPA out of the box.

Once I rebooted and had the restored files from the USB stick, I needed to change quite a few files to get McDPF to install for me and than to add the options that I needed. I couldn't find a way to check in my changes on source forge...so you can download them here. These changes are described below.

To make this all work, download the files in the link to the following locations:

replace mcdpf_setup.sh (in /home/dsl)
upload picasaweb-download to /home/dsl/frame/scripts/
upload run_picasa.pl to /home/dsl/frame/scripts/
replace process_commands.php (in /opt/lampp/htdocs/frame/)
replace basics.php (in /opt/lampp/htdocs/frame/)
upload picasa logo to /opt/lampp/htdocs/frame/images/logos/picasalogo.jpg
upload picasa.php (in /opt/lampp/htdocs/frame/)

My Changes (in detail)

I had to comment out lines 181 & 182
search for the line that had 'Dir::Etc::SourceList' . There should be two of them on lines 181 and 182.
comment them out (put a # in front of them)
and insert the following below them
apt-get -qq -y update
apt-get -qq -y install feh

the first time I ran mcpdf_setup.sh, I got a few errors...so I said 'n' to the reboot question. It did, however, setup my wireless networking, which let me fix the errors.

search for the line referring to pear (there should be two of them for installing Weather Services and a XML Serializer). insert the following line before them:
/opt/lampp/bin/pear channel-update pear.php.net

on line 192, there is a line wget ... for xampp. prior to that line, insert
rm xampp*


edit /etc/apt/sources.list
delete its contents and insert the line
deb http://archive.debian.org/debian-archive/debian woody main contrib non-free

right click / tools / enable apt

run mcdpf_setup.sh

change hostname to what you want (default is box)
edit the file /etc/hostname (as root) and change the hostname to whatever you want

Change the lampp settings so that it is more secure--and the lampp documentation doesn't show up when you go to the frame via a web-browser.

run: /opt/lampp/lampp security
(use the following options: no password, disable mysql, disable xampp pages)

than restart lampp via: /opt/lampp/lampp restart

Download URI-1.37.tar.gz from http://search.cpan.org/~gaas/URI-1.37/URI/Escape.pm
tar -xvzf URI-1.37.tar.gz
sudo mv URI-1.37/URI /usr/lib/perl/5.8.0

Lastly, I needed to edit the crontab in order to make it download photos from picasa every day. The lines I added were:

# Download pictures from picasa
00 7 * * * /home/dsl/frame/scripts/run_picasa.pl

Finally, the files

upload picasaweb-download to /home/dsl/frame/scripts/
edit process_commands.php (in /opt/lampp/htdocs/frame/) to add commands for picasaweb-download
edit basics.php (in /opt/lampp/htdocs/frame/) to add page for picasaweb-download
upload picasa logo to /opt/lampp/htdocs/frame/images/logos/picasalogo.jpg so that the picasa page looks consistant
create picasa.php (in /opt/lampp/htdocs/frame/) so that the picasa page actually works
upload run_picasa.pl to /home/dsl/frame/scripts/ (this is a wrapper script around picasaweb-download that parses multiple user names from the preferences file and than calls picasaweb-download for all of them)

download these modified files from here.

Getting the Powerbutton to work
My laptop has 2 power buttons. A push button and a slider button. By default, neither button does anything...

It turns out that you need to start the acpi daemon in order to receive these events.

sudo /etc/init.d/acpid start

That enabled the sliding switch to reboot the computer and the push button still did nothing.

I saw the following entries in my /var/log/acpid

[Sat Nov 29 14:38:16 2008] starting up

[Sat Nov 29 14:38:16 2008] 4 rules loaded

[Sat Nov 29 14:39:13 2008] received event "button/sleep C19B 00000080 00000004"

[Sat Nov 29 14:39:13 2008] completed event "button/sleep C19B 00000080 00000004"

[Sat Nov 29 14:39:37 2008] received event "button/power PWRF 00000080 00000002"

[Sat Nov 29 14:39:37 2008] executing action "/opt/acpi/actions/powerbtn.sh"

[Sat Nov 29 14:39:37 2008] BEGIN HANDLER MESSAGES

Saved mixer settings to '/home/dsl/.umix'



Broadcast message from root Sat Nov 29 14:39:38 2008...



The system is going down for reboot NOW !!

MurgaLua Version 0.6.8 (http://www.murga-projects.com/murgaLua/

MurgaLua FLTK bindings: Copyright 2006-8 John Murga, GPL license.

Warning: FLTK bindings is a subset of the full MurgaLua environment.

ls: .xtdesktop/*.lnk: No such file or directory

No Icons Found.

[Sat Nov 29 14:39:38 2008] END HANDLER MESSAGES

[Sat Nov 29 14:39:38 2008] action exited with status 0

[Sat Nov 29 14:39:38 2008] completed event "button/power PWRF 00000080 00000002"

Which is good progress. After the reboot, I created /opt/bootcustom.sh with the following entry

#!/bin/bash

# start acpid
/etc/init.d/acpid start


this makes acpid start automatically at boot

Instead of rebooting, I wanted the powerbutton to do a clean shutdown. To do this, edit /opt/acpi/actions/powerbtn.sh and change the last line from

/usr/local/bin/exitcheck.sh reboot to

/usr/local/bin/exitcheck.sh shutdown


Sleep Button
Create /etc/acpi/events/sleepbtn with the following contents:
# /etc/acpi/events/sleepbtn

# This is called when the user presses the sleep button and calls

# /etc/acpi/sleepbtn.sh for further processing.



# Optionally you can specify the placeholder %e. It will pass

# through the whole kernel event message to the program you've

# specified.



# We need to react on "button power.*" and "button/power.*" because

# of kernel changes.



event=button[ /]sleep

action=/opt/acpi/actions/powerbtn.sh


so that it will work like the power button does.

Reduce Power Consumption
I edited /opt/acpi/actions ac_adapter.sh and made it the same as battery.sh since a 2 Pentium 4 is overkill for a DPF...we can step down the CPU and it will still be fine...and will save some electricity.


Disclaimer
I have tried to write about all the steps I took to get this to work. In the progress of getting this up and running, i had to try many different things and sometimes go backwords...so if I have gotten anything wrong...feel free to comment and I will help as best as I can.