TFT touchscreens for the Raspberry Pi
Apps for Raspbian?
Apple recently showed the world how a simple and sensible user interaction works on a small screen by placing touch buttons big enough to use easily in a single window mode. High-performance toolkits are available to developers for use on iOS and Android that make it much simpler to create applications. The users also benefit from the unified design standards.
Nothing similar exists for Raspbian in combination with the 2.8-inch display screen. Therefore, the assembly work is really just beginning after putting everything together, in spite of the X drivers. Without knowledge of programming, the screens are pretty much useless. It is also not clear whether the screens will be used widely enough that a community will arise to offer generic support for the development of applications.
Technically, there are various approaches for this kind of 2.8-inch toolkit. HTML5 would be a top candidate, but it would need a browser optimized for small display screens to serve as a run-time environment. This would be something like what Firefox is doing with its Firefox OS.
The following sections deal with an alternative solution that even users with little programming experience can adapt for their own needs. The solution is based on the script language Python and the graphical elements available in the PyGTK toolkit [9].
Python is an integral ingredient of Raspbian itself. You can install PyGTK with the following calls:
$ sudo apt-get update $ sudo apt-get install python-gtk2
The basic idea behind the solution presented here is to provide the user with a user-friendly way to operate various functions of the Rasp Pi by touch. Primarily, I'll deal with simple things like restart, shutdown, and status requests. Programs are already available that merely need to be packaged into an app.
The Launcher
The main priority is the startup screen, or "launcher." This screen contains a window with icons for all of the apps. These icons are simply PyGTK buttons. If there are too many apps to fit on the screen, the Launcher automatically distributes them to several pages. Navigation through the pages is accomplished via the toolbar (Figure 5).
You will need to configure the system via sudo raspi-config
so that it automatically boots in the desktop, which starts the launcher. Then, you should create the .config/lxsession/LXDE/autostart
file along with the higher level directories in the home directory of the standard user pi. This contains just one line, @PiAppLauncher.py
. Provided the program exists, the start screen with the apps will appear after a restart.
Every application uses its own subdirectory and all of the files it contains. The launcher looks for apps in designated locations such as ~/.local/lib/pi28apps
and /usr/lib/pi28apps
. For each app directory, the launcher loads a configuration file by the name of appconfig.py
, and then you're done. A minimal configuration for a system restart looks like:
name = "Reboot" icon = "./system-reboot.png" cmd = ["sudo","reboot"]
The Python list named cmd
contains both the command elements as well as all of the parameters, enclosed in brackets and separated by commas.
« Previous 1 2 3 4 Next »
Buy this article as PDF
Pages: 6
(incl. VAT)