Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I've received my new Raspberry Pi Model A+ last week to use to replace the old Model A inside my photo frame, so I spent some time on the weekend setting that up. Last time that I've set this photo frame up, I went with out-of-the-box software, which did the job but did feel quite clunky. This time around I decided to do it better and write some software for the photo frame instead.

Since Java is what I'm most comfortable with, and it works on the Raspberry Pi, that's the language I decided to use. I did do some research first however and managed to find jPictureFrame, I couldn't get this to work - it just kept on displaying a blank white screen.

At the moment the software is quite basic. It displays photos from a directory, resizes them to the screen and caches the resized files to use later. It also shows the current date and time. There are a few things missing like weather forecast, web browser control, and more intelligent display of photos. I'll be adding new features at a later point.

This is what the output looks like:
jphotoframe.jpg


Now lets see what I did to set this all up.

Instead of using an OS with a lot of features that I would never use, I went for a minimal distribution. I went with Minibian, but specifically I got the wifi enabled version: Minibian-wifi. Since I'm doing this on a Model A+, there is no ethernet connection and wifi connectivity is essential. I used ApplePi Baker to write the image.

Once the image was ready, the first thing I did was set up networking. A static IP was set to make it easier to connect to the photo frame. Below is the content of the /etc/network/interfaces file. The /etc/wpa_supplicant/wpa_supplicant.conf was also updated to have my wifi SSID and password.
 /etc/network/interfaces
auto lo
iface lo inet loopback
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static
address 192.168.1.254
netmask 255.255.255.0
gateway 192.168.1.1




There is a good getting started guide for Minibian that I made some use of. It's important to expand the file system, set the memory split and overclocking options as required. I used raspi-config for this, since it is not installed with Minibian, I had to get it first:
 Commands
apt-get update
apt-get install raspi-config


Once I was done with that configuration, I ran apt-get upgrade to upgrade all the system packages.

Next I needed to install all the software that I would need:
 Commands
apt-get install git dosfstools lxde oracle-java7-jdk netatalk samba samba-common-bin unclutter


After this, I needed to get the USB monitor working, for that I followed my own blog post from earlier. The only thing I did differently was to force the USB key to be mounted with the sync option to prevent file system corruption. My /etc/fstab file looks like this:
 /etc/fstab
/dev/mmcblk0p1 /boot vfat defaults 0 2
#/dev/mmcblk0p2 / ext4 errors=remount-ro,noatime 0 1
/dev/sda2 / ext4 defaults,noatime,sync 0 1


Once that was done, I followed this post to get Samba and AFP configured. I also added the pi user and made the Raspberry Pi login into a desktop environment (using raspi-config again).

Now I was almost ready to get some Java development happening on the Raspberry Pi. As I was about to start, the USB monitor switched off. Of course this was due to the cron job I've scheduled, but it was the wrong time of the day. I realised that the time zone was wrong, the following command let me change it to my correct time zone (as the root user):
 Commands
dpkg-reconfigure tzdata


Now I was ready for Java coding on the Pi. It took a few hours to write the code, which is available on my GitHub Project Page, the jar file is also there for download.

This needs a configuration file, config.properties to be present in the same directory as the jar file. The contents of mine are as follows (it should be more or less self-explanatory):
 config.properties
screenNumber=0
imageDirectory=/photos
cacheDirectory=/photos/cache
imageTimeout=300000
fontName=Verdana
fontSizeDate=20
fontSizeTime=50
dateFormat=MMM d yyyy
timeFormat=H:mm
dateOffsetX=15
dateOffsetY=10
timeOffsetX=10
timeOffsetY=30


Running it is simple...I actually put this in a script and made it execute when LXDE starts.
 Commands
java -Xms64m -Xmx64m -jar jphotoframe.jar


My photo frame has been running with this software without any issues for a couple of days now. It seems much more stable than the previous attempt using Conky to draw the images. I'll be making updates to this soon and I'll release the source code in due time too.

Enjoy!

-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.