Tag Archives: touchscreen

Camera Pan and Tilt control with TFT and Touchscreen

Here is an example of how to use a TFT screen to control the pan and tilt of a Raspberry Pi camera.

Git repository here
The code can be pulled down to your Raspberry Pi with;

pi@raspberrypi ~ $ git clone http://github.com/mwilliams03/pan-tilt-touchscreen.git

 

There are a number of elements in place to get this working;

  • Detecting input events on the touchscreen.
  • The use of double buffering for the framebuffer.
  • Using fbcp(framebuffer copy) to copy camera image to back buffer. fbcp source has been integrated into the code above.
  • Updating back buffer with text and buttons.
  • Forking the actual process that starts recording.
  • Create a unique file name fore each recording.
  • Software PWM to control servers. (ServoBlaster)

 

The code has been well documented, so I will only cover imported snippets below.

Drawing buttons

panTiltInterface

The function below is used to draw the buttons and slider outlines to the display.

void drawButton(int x, int y, int w, int h, char *text, int backgroundColor, int foregroundColor);

x & y are the top left coordinates of the button.
w is width.
h is height.

Continue reading Camera Pan and Tilt control with TFT and Touchscreen

Virtual Keyboard for the Raspberry Pi

Matchbox-keyboard is an on screen ‘virtual’ or ‘software’ keyboard which works well for small touchscreen TFTs connected to a Raspberry Pi.


Matchbox-keyboard also uses XML files to specify the layout of the keys, which makes it highly customizable.

The touchscreen used in the above video is a PiScreen.
Continue reading Virtual Keyboard for the Raspberry Pi

Raspberry Pi with stroke and Gesture Recognition

If you are using a touchscreen with your Raspberry Pi, then this guide is for you.

Xstroke (Gesture recognition) is the perfect tool to help you get more out of your touhscreen. I am using a PiScreen

Gesture recognition allows you to draw “strokes” on your touchscreen, which get interpreted as commands or text. Xstroke allows these to be entered anywhere on the screen. In some cases, Xstroke can be used instead of a keyboard.


Continue reading Raspberry Pi with stroke and Gesture Recognition

Controlling the GPIO on a Raspberry Pi with a Touchscreen

In this post I show how to control the GPIO on a Raspberry Pi using a touchscreen.
This is a follow up on my previous post Programming for a Touchscreen on the Raspberry Pi

The TFT doesn’t come up too well in the above video. The picture below gives a better idea of how it looks. Click to enlarge

Touch Screen button example

Link to the code;
https://github.com/mwilliams03/Pi-Touchscreen-basic.git

In the above code touchbuttons.c creates three buttons on the TFT which will be used to turn on/off three LEDs.

This can easily be changed to add more buttons.
touchbuttons.c also requires WiringPI and needs to be compiled with gcc -g -o buttonExample buttonExample.c -l wiringPi
Continue reading Controlling the GPIO on a Raspberry Pi with a Touchscreen

Programming for a Touchscreen on the Raspberry Pi

To accept input from a touchscreen we have to use the event interface of the Linux input system. We use the ioctl capabilities of the event interface, in addition to the normal read and write calls to get information from the touchscreen. This blog post explains how to use the touchscreen within your own programs using C as well as writing directly to the framebuffer.

Images of my TFT from a previous post;

TFT TFT TFT

Continue reading Programming for a Touchscreen on the Raspberry Pi