Tag Archives: piscreen

Digital Compass with the Raspberry Pi – Part 4- “Smartphone Replica”

This guide shows how to use a BerryIMU and a small TFT to create a digital compass, similar to those that can be found on smartphones.

  • The TFT used in this guide is a PiScreen
  • The IMU is a BerryIMU – Magnetometer,  gyroscope, accelerometer and pressure sensor
  • SDL is used to display the output to the TFT
  • Tilt compensations is used
  • A low pass filter is used to reduce noise
  • Compass calibration is needed

If you don’t a small TFT like the PiScreen, you can still use this guide to display the output to a monitor via HDMI.

 

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

pi@raspberrypi ~ $ git clone http://github.com/mwilliams03/BerryIMU.

 

The code for this guide can be found under the compass_tutorial04_graphical_output directory.

 

Prerequisites for this guide;

  • A working TFT (not covered in this guide)
  • A working magnetometer (compass) with tilt compensation. A guide can be found here
  • Understand how to perform Hard Iron calibration. A guide can be found here

We will be covering some basic SDL which will be used to produce our graphics.

 

The IMU used in this guide is the BerryIMU. However, other IMUs or accelerometers and gyroscopes can be used.. Eg Pololu MinIMU, Adafruit IMU and Sparkfun IMUs

Continue reading Digital Compass with the Raspberry Pi – Part 4- “Smartphone Replica”

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

How to Create an Inclinometer using a Raspberry Pi and an IMU

This guide covers how to use an Inertial Measurement Unit (IMU) with a Raspberry Pi to create an inclinometer, just like the type you will find in a 4WD.

A prerequisite for this guide is to have a gyro and accelerometer from an IMU already up and running on your Raspberry Pi. A guide to interfacing an IMU with a Raspberry Pi can be found here.

We will be covering some basic SDL which will be used to produce our graphics.

 

The IMU used in this guide is the BerryIMU.  However, other IMUs or accelerometers and gyroscopes can be used.. Eg  Pololu MinIMU, Adafruit IMU and Sparkfun IMUs

Continue reading How to Create an Inclinometer using a Raspberry Pi and an IMU

Matchbox-Desktop on the Raspberry Pi

Matchbox-desktop is a lightweight windows manager for embedded systems. It works great on a Raspberry Pi with one of the smaller TFTs attached. E.g. PiScreen, PiTFT , etc…

Matchbox-desktop is “finger friendly” and makes it easy to navigate while just using your fingers on the touchscreen.

Mathcbox-Desktop needs to be installed from source and via apt-get to get it going correctly, in this order;

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install autoconf autogen intltool libtool libx11-dev libxext-dev libxft-dev libpng-dev libgconf2-dev libgtk2.0-dev libstartup-notification0-dev libdbus-glib-1-dev -y
pi@raspberrypi ~ $ git clone http://git.yoctoproject.org/cgit/cgit.cgi/libmatchbox/
pi@raspberrypi ~ $ git clone http://git.yoctoproject.org/cgit/cgit.cgi/matchbox-common/
pi@raspberrypi ~ $ git clone git://git.yoctoproject.org/matchbox-desktop
pi@raspberrypi ~ $ cd libmatchbox
pi@raspberrypi ~ $ ./autogen.sh
pi@raspberrypi ~ $ make
pi@raspberrypi ~ $ sudo make install
pi@raspberrypi ~ $ cd ../matchbox-common
pi@raspberrypi ~ $ ./autogen.sh
pi@raspberrypi ~ $ make
pi@raspberrypi ~ $ sudo make install
pi@raspberrypi ~ $ cd ../matchbox-desktop
pi@raspberrypi ~ $ ./autogen.sh
pi@raspberrypi ~ $ make
pi@raspberrypi ~ $ sudo make install
pi@raspberrypi ~ $ sudo apt-get install matchbox-desktop

To start matchbox-desktop

pi@raspberrypi ~ $ FRAMEBUFFER=/dev/fb1 xinit /usr/local/bin/matchbox-desktop

UPDATE: Matchbox-desktop doesn’t work with  newer Raspbian images. The last confirmed image it works on is 2014-06-20-wheezy-raspbian.img

To get matchbox-desktop working;
1. Burn the above img.
2. Follow the instructions above and matchbox-desktop will compile correctly.
3.Perform updates

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo rpi-update
pi@raspberrypi ~ $ sudo apt-get upgrade
pi@raspberrypi ~ $ sudo apt-get dist-upgrade
pi@raspberrypi ~ $ sudo apt-get install raspberrypi-ui-mods

4. Remove SPI from black-list
Open raspi-blacklist.conf

pi@raspberrypi ~ $ sudo nano /etc/modprobe.d/raspi-blacklist.conf

And place a hash ‘#’ in front of ‘blacklist spi-bcm2708’.

5.Configure drivers for any attached TFT.
6. Disable framebuffer driver option for /dev/fb0.
Open up the framebuffer conf file;

pi@raspberrypi ~ $ sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf

Comment out the line of text below;
Option "fbdev" "/dev/fb0"
This can be done by adding a hash (#) at the beginning of line.
#Option "fbdev" "/dev/fb0"

7. Now startmatchbox-desktop.

pi@raspberrypi ~ $ FRAMEBUFFER=/dev/fb1 xinit /usr/local/bin/matchbox-desktop

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