So here’s my latest Raspberry Pi project. It uses the PiTFT Mini Kit, which is a 320×240 2.8″ TFT display and Touchscreen from Adafruit Industries that fits neatly onto my Raspberry Pi, to control a user interface to drive the back-end time-lapse script I showed you in a previous blog article.
In that article, Lapse Pi -Motorised Time-lapse Rail with Raspberry Pi, I showed you some simple python code to drive the time-lapse rail by running the script from a laptop or smartphone capable of ssh’ing into the Raspberry Pi. The PiTFT allows me to take the project up a notch, by putting the user interface right on the Raspberry Pi, so no external device or connectivity is needed. Here’s a picture of the setup.
The User interface allows you to:
- position the dolly on the rail via the motor control buttons
- change the motor pulse duration between shots
- change the delay between shots
- change the number of shots
- see what time is left for the current sequence
- start and stop the time-lapse
And it’s all done using a few simple screens with a simplistic, easy-to-use touchscreen user interface. The following video shows it all in action.
As you can see in the video, there’s now a motor controller circuit in the mix to allow me to change the direction of the motor from software, rather than having to use a switch.
- $35 – Raspberry Pi
- $35 – PiTFT
- $2 – DC-DC converter
- $8 – Motor Controller (Dual H-Bridge circuit)
- $10 Misc Connectors, transistors, etc.
- $10 – 2 cheap acrylic Pi cases from eBay
Total for the controller – round about $100.
There’s now a guide covering the hardware in more detail at learn.adafruit.com
Originally I had a laptop connected to the Pi via Wifi, and later on I had a smartphone do the same, but then I got my hands on a PiTFT, a shield that sits neatly on top of the Raspberry Pi. When I saw it on the Adafruit website, I knew I had to be quick, so 5 minutes later I had one on order, and five minutes after that they were out of stock. Shipping took a while, the order went in before Christmas, and to be fair to Adafruit, the package shipped the next day, but it took over a month to get here from the States. Small packages are usually a lot quicker than that.
Anyway, when it arrived I started researching the best method to develop a Time-lapse User Interface. I looked a TKinter, and did a few sample apps. This was more suited to Xwindows development, and the controls were all very small and difficult to use with just your finger. Limitations in the controls also meant it was difficult to size them up to be suitable for the 2.8″ display. So I came to the conclusion that TKinter was not a suitable development environment for my needs.
Then I came across the excellent “DIY WiFi Raspberry Pi Touchscreen Camera” tutorial on Adafruit’s website by Phil Burgess. It’s implemented using PyGame, and the GUI looked really slick and simple to use, so I got my hands on the software, installed it and got it up and running. And the amazing thing is that it was all done in about 647 lines of Python! So, I dove into the guts of the code and saw that it was a very elegant method using PyGame to display icons on the screen and allow actions to happen when those icons are touched. Ideal for a simple user interface of a couple of screens, which is what I’d planned for the time-lapse GUI. So I set about tearing it down and adapting it for my needs.
One of the main challenges was doing a numeric keypad entry. That would require lots of icons, and a method of displaying what the user was typing. So I started on that one. Photoshop is great for throwing icons together, and putting fancy effects on fonts, so I used something similar to the Adafruit Camera’s font, a white font with a thick black stroke, and a checkered, semi-transparent background for the touchable icons.
Next was the screen for the main display, which is what’s shown to the user when the time-lapse is running. This allows the user to start/stop the time-lapse, with another button for settings. Everything else on the screen is just information on the current status of the time-lapse.
The final screen is where the use can change the settings. For this initial version of the GUI, there’s only four settings that can be changed:
- The length of the pulse we send to the motor
- The delay before the next shot
- The number of shots
- The direction of the motor
For each numeric setting, there’s a touchable button which brings the user to the numeric keypad entry, where they can change the value passed in.
There’s also two buttons for motor control, one for motor direction, and one to drive the motor. This is used to get the camera dolly into the correct position at the start of the time-lapse.
Once you start a time-lapse running, it runs in a background thread, so you can continue to move about the screens and change settings. If you change any of the settings, they will immediately be reflected in the running time-lapse. I’m not so sure this is a good idea, so I might change that. Also, the motor buttons can also affect the movement of the dolly, so I think I’ll disable those buttons while the time-lapse is running.
The code is based on the Adafruit PiTFT Camera tutorial by Phil Burgess, and I’ve taken the user interface portions of his cam.py application and used them for my time-lapse controller GUI, which I call lapse.py. Fits nicely with the name of the project, don’t you think? 😉
The code is available here on GitHub, with installation instructions and prerequisites. It also includes all the icons needed for the touch screen interface.
Here’s some of my recent work. This was not done with the touch version of the time-lapse controller, but it does give you an idea of what can be done with this system. Most of the footage in this video was shot using a Raspberry Pi controlling the time-lapse rail.
Raspberry Pi is a trademark of the Raspberry Pi Foundation
About the Author:
By day I’m a senior embedded Linux software engineer. In my spare time, I take pictures, and play with gadgets and technology.
Be sure to check out my other Raspberry Pi related articles, and if you like, you can subscribe by entering your email address at the top right of the page. 🙂
If you like this project, and would like help support it’s continued development, and the development of future projects (this Making is an expensive hobby!), then feel free to donate something using the following PayPal button:
Other Related Posts:
- Raid Pi – Raspberry Pi as a RAID file server
- Drop Pi – Water Droplet photography with Raspberry Pi
- Macro Pi – Focus Stacking using Raspberry Pi
- Camera Pi – DSLR Camera with Embedded Computer
- Lapse Pi -Motorised Time-lapse Rail with Raspberry Pi