Igor's Blog

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

comments powered by Disqus
Other posts you may like...
Programming, DIY, Games, Hacks, and Tech

Recent Blog Posts

Swapping HDD logic boards between different brand disks - is it possible?

A guide for plotting your hard drive for Burstcoin mining on a Mac using mjminer

Replacing a broken hard drive in a Samsung Story Station

Fix Java applications slow start and net connection times on macOS sierra

Pierre Cardin Leather Computer Bag (PC2278)

How to stop SSH remote host disconnecting your session

Using PayPal PHP SDK on Google App Engine

Use the Touch Bar to lock your Mac with a single button press

Multi module builds with Maven 3.5 and the parent-child pom version management

Google App Engine local dev server DataStore becoming corrupted after a bad GQL statement is run

Recent Galleries

Monument Valley 2 is released and does not disappoint

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

DIY indoor apartment grow light wiring

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
300 George St Blogumentary

My Online Tools

UUID to OID Converter
Guru JSON-RPC Tester
Extrudifier Object Designer
Travel ┬ÁBlog

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Don't feel obliged, but you could follow me for more great content!
     
Don't show this again