If there is one add on for the Raspberry Pi that I have seen frequently requested, it has got to be a portable screen, and preferably a touch screen. There is no wonder, either, with the advent of smartphones and tablets that touch screens that are capacitive or resistive are verily sought after. Especially for development.
It is no secret that the Pi Foundation have been working on a 7" touch screen, and while that is appropriate for a number of projects where you may want to mimic a portable tablet or perhaps a laptop, I have been coveting a much tastier and cuter opportunity for smaller and embedded projects.
Finally, 4D Systems have brought out an affordable 2.4" TouchScreen2.4" TouchScreen compatible with the Raspberry Pi A+, B+ and 2 Model B! It's very, very nice.
{gallery} 4D Systems 2.4" TouchScreen |
---|
Pi Foundation Case: Well protected and contained, what's inside? |
Bright and Cheerful: The 2.4" screen mounted on the Pi fits neatly and viewable through the top of the case |
Gutted: With the entire top off, so we can see the five buttons. |
Barebones: Of course the screen works suitably without the case, if that's what you're after. |
Packaged Up: You receive a small quick start guide inside the box, along with the screen. Nothing else is included. |
All About Presentation
The TouchScreen sits on the bank of GPIO pins (all of them) and almost fully covers the exposed Raspberry Pi (not counting the USB / Ethernet ports) and it hovers and I am re-assured that there will be a set of "stand-offs" soon to be purchasable to secure the screen above the pins and connectors of the Pi.
What you may immediately notice from the photographs is how nicely the screen fits inside the Official Raspberry Pi CaseOfficial Raspberry Pi Case, this was an intentional design decision between element14 and 4D Systems. Perhaps one day the official case will be designed with portable power in mind, too? We can only hope.
The screen is very capable, but it does have limitations which are mainly introduced by how Linux handles framebuffers and how these interface with the VideoCore graphics hardware. For example, it is very capable of playing full motion video as can be seen in the YouTube video above. However, you cannot render OpenGL to the screen because of how it handles the backbuffers (I think that's right) though this may be theoretically possible if it was coded correctly (though the implementation may end up being slow) it means that you won't be seeing hardware acceleration to the SPI screen. This is not unique to the 4D Systems screen, you will find this with any SPI screen, and until someone plays with the Broadcom code for the VideoCore and OpenGL we may never see it happen (if it's even possible).
This means that the screen is appropriate for other applications than hardware accelerated video. Setup properly it could be used as a touch interface or even a portable video player and there's little stopping you from running two screens at once.
Not-So-Quick-Start
I'll pre-empt your gripes:
- A debian package is being worked on for the driver.
- A repo' is possibly being worked on, but co-operation with Raspbian for native support should be forthcoming
So I'm told, and likely because it's early days, I haven't seen evidence of the source code to compile it yourself yet, but I am re-assured that there will be up to date releases in support of the latest kernel at least as the add-on is intended to be fully HAT compatible and automatically identify and setup itself when you plug it into the Pi 2 in future. This feedback has already been given internally to attempt to address and accelerate this.
Step by Step
To start using your 2.4" TouchScreen you can follow these steps, for ease of setup you'll need internet access and a keyboard, mouse and monitor:
- Image the SDCard for your Raspberry Pi A+/B+/2 Model B with Raspbian
- Power on your Raspberry Pi and set it up using either SSH or Keyboard & Mouse with a screen as per usual
- Open up a terminal window, either within X (the desktop environment) or by pressing CTRL-ALT-F2 (F1 to F6 usually work)
- Type the following:
wget http://www.4dsystems.com.au/downloads/4DPi/4DPi-24-HAT/4DPi-24-HAT_kernel_R_1_0.tar.gz
sudo tar -xzvf 4DPi-24-HAT/4DPi-24-HAT_kernel_R_1_0.tar.gz -C /
If you need it, I have also attached the file to this blog post. By default, this file replaces the file /boot/config.txt - so you may want to back that up or make a note of any settings you have in there in case you want to re-apply them.
If you have a Raspberry Pi A+ or B+ you will have to alter the /boot/config.txt file using your favourite text editor (I use vim). I'll let you choose which, but if you're having problems just ask in the comments. Change the following line:
kernel=kernel7_hat.img
to
kernel=kernel_hat.img
Which will give you support for the A+/B+ , why this is different, I do not fully understand but it is likely driver related in how the screen interfaces with the VideoCore on the Raspberry Pi as some of the DMA addressing changed between the two.
Everyday I'm Buffering
Your only steps now to get it to display are playing around with the framebuffer on the device, which it identifies as /dev/fb1 - so for example one way to get your desktop to appear on your touchscreen by default is to edit /etc/rc.local and put the following in before the 'exit 0' line:
sudo -u pi FRAMEBUFFER=/dev/fb1 startx &
Frankly, there are more fun ways to play with the framebuffer. For example, I found a project called "Raspberry Pi Framebuffer Copy" that allows you to extend playing about with what's displayed on the screen. So for example you can push a higher resolution image and possibly other features onto the screen if that's what's typically supported over HDMI pretty easily, though it may not look pretty!
Further Configuration
You may now be asking what else you can do with the screen with questions such as "Where's the calibration?", "How do I tweak the SPI communication speed?" or "What are these buttons?" and perhaps "How do I hold all of these melons?". Some of these questions, and more, will be answered in future released documentation (we're still making sure that they work).
In the file /boot/cmdline.txt you will find:
24-hat.rotate=0
Which you can change to equal '0, 90, 180 or 270' meaning the degrees at which the screen is rotated.
You may also be able to add the values:
4dpi.sclk=
and
4dpi.compress=
To cmdline.txt, example values of these are '48000000' and '7' respectively, this increases the frequency of the SPI bus and the compression of the data sent over it, if set to '1' it lets the kernel handle the compression, which may not be optimal and corruption may occur, '7' is the highest value.
4dpi.pwm=
May allow control over the backlight, setting to '0' will disable it and free up GPIO18 on the Pi, setting to '1' allows values to be sent to /sys/class/backlight/4dpi/brightness to control the backlight (between 1 and 255)
Undocumented Feature
Hidden within the config files for Xorg you will find that the kernel package for the 2.4" touch screen adds the following file:
/usr/share/X11/xorg.conf.d/99-fbturbo.conf
Within this file are settings for the following 'startx' parameters:
startx -- -layout TFT
Which starts the Xorg environment with output to the 2.4" touchscreen
startx -- -layout HDMI
Which starts the Xorg environment with output via the HDMI port on the Raspberry pi.
In the appendix attached to this post, you will find code that will let you configure the buttons for the screen. There's code for C and for Python, which will give you some diversity in using the buttons (first person to create a Kodi/OpenElec plugin gets a cookie).
Now all I need to do is mod a battery and camera into the case and I'll have a nice portable camera!
Top Comments