Although suitable for any Pi, one of my goals was to achieve the lowest possible cost. This made the Pi Zero the ideal choice (or the A+, if you can't get a Zero). In fact "any Pi will do" (even the early Pi A/B with the 28 pin header), so don't be put off by my use of 'Pi Zero' below
PhotoFrame phase 2 - fitting a remote control
After looking into 'clever' BlueTooth systems, I eventually went for the KIS and cheapest :-)
A 17 button IR remote can be had for less than £2 on eBay (search for "Infrared Wireless Remote Control Kits for Arduino Raspberry pi AVR PIC", £1.82 each, postage included (from China)). This 'Xinda/KEYES' controller transmits a 38kHz modulated 9600 baud serial data stream when a button is pushed. Notes. The hand held transmitter module is shipped without it's battery (it needs a CR2025, available from the £1 store in a pack with various other useful button cells). Most kits come two means of 'detecting' the transmisions = a mini-PCB mounted detector chip (VS1838B or similar) PLUS an iR sensitive diode. The detector will convert the 38kHz modulated iR transmission into a 9600 baud bit stream (whilst the diode will not), so use the detector :-)
The detector
The button code is transmitted using the standard serial link protocol (1 start, 8 data, 1 stop) at 9600 baud using a 38kHz 'carrier' (i.e. '1' = 4x iR pulses (38.4Khz), '0' = nothing)
The mini-PCB iR detector (Xinda / KEYES KY-022 TL1838 VS1838B 1838 Universal IR Infrared Sensor Receiver Module), strips the 38kHz carrier and converts the code back into a serial pulse stream, so you can just wire it direct to the Pi serial input 'RxD' (header Pin10). The detector has it's own internal pull-up, so you only need 3 wires (although some kits come with a nice 4 wire cable, so you can add your own 'button click feedback' LED). The 3 wires are connected to the end of the KEYES module, marked '-' = Gnd (brown), '+' or no marking (the middle pin) = 3.3v (red), 'S' = 'sense' (serial pulse stream) - orange wire. The receiver operates at both 3v3 and 5v and contains it's own internal 'pull up' to Vcc (so no external resistor needed). It's unclear why there are two additional components on the mini-PCB, however since the 1838 is known pick up interference in bright sunlight perhaps they are intended to reduce it's susceptibility. The Pi RxD is a 3v3 input and can be found on header Pin10 (but see below re: LIRC software expecting Pin12), the nearest Gnd is on Pin14 and the nearest 3v3 on Pin17
Just like a TV remote, the controller has to be 'pointed' at the detector. I mounted it on the bottom edge of the display, near the center, pointing 'forward' i.e. where most users will instinctively 'aim' a remote control. Even so, it was soon necessary to fit some sort of 'feedback' so the user can immediately 'spot' when a key code has been seen.
Since my kit came with a 4 wire cable, I went for an 'activity/busy LED' (and used the same LED when photos were being loaded from USB memory stick) Those who opted to add sound system to their Photoframe (so it can also be used to play movies) might choose issue an audible 'click' instead
Phase 2 - the software
The Linux Infrared Remote Control (LIRC) Daemon is included in the Pi Jessie distro., HOWEVER, as with anything Linux, if you manage to get it working with the IR controller, DON'T UPDATE ANYTHING ! (see here for what happens when you make the mistake of updating after getting something working on the Pi)
It's amazing how many out-of-date 'how-to' guides Google manages to find for setting up the Pi = and how few guides bother to state their what version ofPi distro or even the date. So, in case you are wondering, I wrote in July 2016 for 2016-05-27-raspbian-jessie-lite on the Pi Zero
The problem with the LIRC Daemon is that, by default, it expects the IR 'sensor' to be wired to header Pin12, 'BMC 18' (aka 'GPIO 18') which is the I2S input. Whilst this 'saves' using the serial command terminal RxD (BCM 15, Pin 10) it 'clashes' with the 'pHAT DAC' (an audio 'plug in' board or 'hat') used in my Pi Zero Internet streaming radio project. Furthermore, it generates 'events' that you have to 'handle' by defining 'actions' in it's 'config' file.
To go the lirc route, strat by getting and installing the latest code :-
sudo apt-get install lirc
Modify lirc config file /etc/lirc/hardware.conf :-
$ sudo nano /etc/lirc/hardware.conf
########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput"
# Try to load appropriate kernel modules
LOAD_MODULES=true
# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"
# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
########################################################
save and exit
Modify Pi set-up files to load lirc :-
$ sudo nano /etc/modules
add at end :-
lirc_dev
lirc_rpi gpio_in_pin=23 gpio_out_pin=22
save and exitadd at end :-
dtoverlay=lirc-rpi,gpio_in_pin=23,gpio_out_pin=22
save and exit
Alternatives to lirc
instead of using LIRC, I wrote a simple 'script' that just waits for 'user input' from the 'command terminal' (RxD pin). The advantage of this is, of course, that you can manually 'drive' the script allowing it to be fully tested before expecting it to work with the actual hardware
The script looks for serial input and then shows a 'menu' on the display. Again, the goal is to keep it simple, however there is one thing that forces complexity on us - the fbi script running in the foreground.
There are a number of possible approaches - 'abort' fbi, grab the screen from fbi (and cause it to crash) or 'work with' fbi (by displaying the Menu as jpg's). Of these, the last allows 'continued' operation (since otherwise a Restart will be needed) and, more to the point, lets the 'same' code step through photos (rather than Menu images)
There is one additional complication - whilst showing 'static' Menu pages (as jpg's) is no problem, how do we display a Directory listing ??? The answer is to 'create' an image to display using ImageMagick ...
The KEYES 17 button IR controller transmits a serial code string when a button is pressed. If the same button is held down, a 'repeat' code is transmitted - so if a button is not 'spotted' when first pressed, holding it down isn't going to do any good.
The software will need to provide visual 'feedback' to the user - for example, 'blinking' or 'highlighting' some text on the display - so the user can be reassured that a button press has been 'seen'
KEYES 17 button IR remote control button codes:- 0xFF629D: = "UP" 0xFF22DD: = "LEFT" 0xFF02FD: = "-OK-" 0xFFC23D: = "RIGHT" 0xFFA857: = "DOWN" 0xFF6897: = "1" 0xFF9867: = "2" 0xFFB04F: = "3" 0xFF30CF: = "4" 0xFF18E7: = "5" 0xFF7A85: = "6" 0xFF10EF: = "7" 0xFF38C7: = "8" 0xFF5AA5: = "9" 0xFF42BD: = "*" 0xFF4AB5: = "0" 0xFF52AD: = "#" 0xFFFFFFFF: = "REPEAT" (button held down)