Calibrating a 5″ Raspberry Pi touchscreen in Jessie

Previously, I posted about a 5″ touchscreen for the Raspberry Pi.

But I did not mention calibrating the touchscreen.

After a week’s holiday, I came back and sorted this fairly easily.

I was using Raspbian Jessie from NOOBS 1.8

First I installed a new utility:

sudo apt-get install xinput-calibrator


To calibrate the touchscreen, go to the menu>preferences>select “Calibrate touchscreen”

Touch each of the red crosses on the screen in turn, then cut and paste the resulting snippet to the following file by using this command:

sudo nano /usr/share/X11/xorg.conf.d/98-calibration.conf

(this will create a new file and open it for editing)

My entries are below:

Section “InputClass”

Identifier “calibration”

MatchProduct “ADS7846 Touchscreen”

Option “Calibration” “120 3970 205 3920” #(enter your numbers here)

Option “SwapAxes” “0”


Ctrl-O to save, Crtl-x to exit, and then reboot, and your pointer should follow your finger correctly!

Orange Pi One

This is just a quick and dirty guide to getting the Orange Pi One up and running.

First steps:

  1. DON’T connect a microUSB charger to the MicroUSB port. That port is for USB On the go only, i.e. for connecting flash drives etc.
  2. You will need a 5V power supply with a 4mm x 1.7mm barrel connector, centre positive. I used a USB to barrel connector lead, and a Samsung USB charger, which can easily supply 2A. Apparently PSP chargers work as well.
  3. You will need an SDcard for the OS. At least 8GB and preferably at least class 4. A fast one is recommended, apparently the Opi1 may not boot with a slower one.
  4. EDITED:I have since found that some class 10 cards will not work with the OPi1 or even the Raspberry Pi. I used class 4 Kingston 8GB cards, and they work perfectly with both.
  5. If you power on the OPi1 without a properly set up SDcard, nothing will happen, except that the LEDs on the Ethernet port will light. THIS IS NORMAL.
  6. Prepare the SDcard. I followed this excellent guide:
  7. Once connected up with a valid Boot image, the Ethernet port LEDs light up, followed after a pause of about 20 seconds by the red LED and then the green one will flicker as the system loads. (note on some boards the green LED lights first)
  8. Note: I noticed that if the Ethernet port is not connected, it takes a lot longer to start up.

I have added a Youtube video showing a working Orange Pi One  (and a faulty one)

5″ touchscreen for a Raspberry Pi

Recently bought a Generic 5″ touchscreen from AliExpress.

Model number ZC37200

resolution 800×480

XPT2046 touch controller.

Excellent quality, but getting it working was a bit of a trial.

Many of the tutorials out there are misleading, outdated, or just plain wrong.

This is what I did:


First (easy part), connect it all up, and install Raspbian from NOOBS 1.8.

Either open a terminal or from another PC:

ssh pi@<IP address of your pi>

First the easy part, we get the screen working with a full display.

Because these small screens will only display at native resolution, you may get a partial screen display, or a distorted one.

You need to force native resolution, in the case of the 5” display, that is 800×480.

edit /boot/config.txt

sudo nano /boot/config.txt

edit these lines as follows:

# uncomment if hdmi display is not detected and composite is being output
# uncomment to force a specific HDMI mode (here we are forcing 800x480)
hdmi_cvt 800 480 60 6 0 0 0

The next step is to enable the touchscreen.

In the same file, remove the # from this line:


and add this line:


save and reboot, everything worked!

Next we need to calibrate it, but I need more time to work that one out, will post in the next few days.






MythTV and a TBS HDTV (DVB-T2) Card

HDTV cards with Linux support are fairly few and far between. Although TBS support Linux, you have to compile the driver yourself.

(and again every time you update your kernel).

I Use mine in a MythTV server, running Mythbuntu 14.04

Quad core AMD 5350 Kabini processor, Asus  AM1-A miniITX motherboard, 4GB RAM, and a TBS 6280 HDTV PCIe Dual DVB-T2 tuner card.

I found that to get smooth 1080p video on the device’s screen, , the proprietary AMD drivers were necessary.

MythTV works well, I am using Kodi (XBMC) on devices around the house for streaming.

Downloading and compiling TBS HDTV card drivers

First you need to add the tools: Zip, GCC and headers:

sudo apt-get install p7zip-full unzip build-essential linux-headers-generic-$(uname -r)

TBS driver downloads:
latest one:
or paste this into a terminal:

Some people have reported problems with the latest driver, here is where to get an earlier version:…
or paste this into a terminal:

In terminal (assuming you are in your home directory, and you downloaded the TBS driver into Downloads)
mkdir tvdrivers
cd Downloads
for the latest version:
cp /home/tvdrivers

cd /home/tvdrivers
tar xjvf linux-tbs-drivers.tar.bz2
cd linux-tbs-drivers

for version 141019:
cp /home/tvdrivers

cd /home/tvdrivers
tar xjvf linux-tbs-drivers.tar.bz2
cd linux-tbs-drivers

for both versions:
check for version (32bit or 64bit)
uname -a
for 32 bit:
sudo ./v4l/
for 64 bit:
sudo ./v4l/
You should see “TBS drivers configured for (32bit or 64 bit) platform”
sudo make

go and make a cuppa
once complete :
sudo make install
and when complete, reboot.

v4l files are stored at:
/lib/modules/(your kernel version)/kernel/drivers/media
If you have problems, it may be worth clearing this directory before compiling.
You can find out your kernel version with the command:
uname -r
You can make sure you have the correct kernel headers with the command:
sudo apt-get install linux-headers-$(uname -r)

More info and links here:….

Back from the the brink…

Sometimes the easiest things become difficult.
I decided to swap the monitor on my living room PC.
The new monitor is physically the same size, despite having a slightly larger (23″ as opposed to 22″) visible screen. It also has a higher resolution, 1920×1080 instead of 1640×1050. So I thought it would fit nicely in the bookcase where the current Samsung was.
First problem: no VESA mount, so needs the stand.
Had to move one of the shelves.
Homemade bookcase, screwed together, but not too much of a problem.
Half an hour later, boot up, on HDMI lead. no picture.
Close down, boot on vga ok.
Reboot, oops, caught power lead, pc switched off, Boot up, kernel panic.
After a short google, downloaded and tried Rescatux recovery CD.
Brilliant package! PC working again.
Now just have to figure out why monitor not working with HDMI>DVI lead.(sigh)

An alternative to LIRC for MythTV remotes

What I don’t understand is why nobody else has come up with this and posted it.
MythTV has been both a bane and a joy over the years, the main bane being getting the remote to work properly. The most annoying and recurring symptom is that most of the keys work, but for some reason, the most important, the “OK” key never does.
The latest kernel now has ir keymaps built in, unfortunately this means that my carefully crafted LIRC configuration for my Hauppuage remote no longer works, and the default keymap settings are as useless as ever, Basically, the 1-9 keys, volume controls, up, down, left and right work, but nothing else.
There must be some well hidden documentation about this somewhere, but after much use of Google and reading webpages, I came to the conclusion that to get the best results without using LIRC as a “bridge” I would need to configure my remote as a keyboard.

To do this, I basically ignored all of the internet posts and guides, apart from the ones that gave me the clues to where the keymap files were kept.
First I installed the ir-keytable package from the repositories.
This also installs a selection of ir keymaps in /lib/udev/rc_keymaps

Using the ir-keytable, command,  you can find out which drivers are in use and which keymaps they use.

on my system, it returns:

Found /sys/class/rc/rc1/ (/dev/input/event7) with:
Driver (null), table rc-dib0700-rc5
Supported protocols: NEC RC-5 RC-6
Enabled protocols: RC-5

I started by looking at the relevant keymap (dib0700_rc5) in /lib/udev/rc_keymaps, and tested the remote to see what buttons actually worked.
Then I ran ir_keytable -t > ~/devtest.txt, pressed every key on the remote in sequence from left to right descending in rows. This gave me a text file with the scancodes and their key attributes.
I then saved a copy of the dib0700_rc5 keymap, and edited it.

The first entry that I tried changing was KEY_OK.

I changed this to KEY_ENTER, rebooted, and lo! The OK key worked! I could now select items in the menus!
So basically, I edited the dib0700_rc5 keymap so that every key corresponds with a key on the keyboard, then going through the key setup in MythTV’s frontend creating links where necessary.

Unfortunately, there are a lot of keys already mapped to functions in MythTV, so this last bit was a little hit and miss, as some symbols or combinations such as CTRL+P don’t seem to work, but finally I can use every key on my Hauppuage remote. I have an MCE remote as well, but I haven’t bothered to do that one yet.
My Keymap is here

Yes I know that using devinput with LIRC as a bridge is more elegant for applications that support LIRC, but I only use a remote with MythTV, and the LIRC solution seems just too convoluted and unreliable to be worthwhile, too many links in the chain.

Note: you need to cold boot, i.e.shut down the PC and then restart it, for the new keymap to be read. I found that the remote would not work after a warm reboot, not sure why.

Faxing the lost art

Despite Faxes slowly going the way of the Dodo, there are still some circumstances that require a fax machine.
We need to collect meter reading son a monthly basis form many of our customers.
Although we have tried to move all of our customers to email or automated recovery systems, there remain a few hundred that we still have to fax once a month.
For this, we use a Crystal report with an embedded fax number, using a special font, which the fax printer driver recognises.
However the software that we use for this is antediluvian, and we were running a Win2K VM to support it.
Now that we are moving to windows 2008 and a new domain structure, this will no longer be viable.
There are several windows solutions that could replace this, but we decided to try Hylafax, running on our backup server, which is idle much of the day.
The server is running Ubuntu server 10.04, and the process was quite simple, even though there were a few bumps on the road.

1. Install Hylafax.
sudo apt-get install hylafax-server


which asks various questions (area codes, etc), and then runs


which tests and sets up the modem device, in our case on ttys0.

sudo /etc/init.d/hylafax restart, and everything should be up and running.
The /var/spool/hylafax/etc/hosts.hfaxd file needs to be edited it manually, I found a default one on the web. The format is:
client:uid:passwd:adminwd (passwords should be encrypted)


# Hylafax Faxing Users

# Hylafax Faxing Hosts

First hiccup.
On testing it with a hylafax client, I got blank faxes

a swift Google later,I added the line

use2D: no

So now I could send faxes.
I was using Winprint Hylafax reloaded, but I could only send individual faxes or batches of identical ones.
Our customer faxes contain the customer’s name, account number, machines on site and a space next to each machine for the meter readings, so I needed a way of splitting the job into single pages, and extracting the fax number for each one.

Next step was to look for a simple way to do this.

I found a script called salsafax (an earlier version is called sambafax), by Mark Bennett, which is a perl script to allow Samba printing to Hylafax.

I installed CUPS, perl and psutils

sudo apt-get install perl
sudo apt-get install cups
sudo apt-get install psutils

I also needed the perl modules
perl module Getopt-Long-2.32
(.deb libgetopt-long-descriptive-perl)
perl module Mail-Sendmail-0.78
(.deb libmail-sendmail-perl)

I copied salsafax to the /usr/lib/cups/backend directory, and changed the permissions
sudo chmod 755

I added the line:

Filedevices Yes

to /etc/cups/cupsd.conf near the top of the file.
(it is recommended to remove this after creating the printer configuration, as it is a security risk).

Then I created a printer

sudo lpadmin -p SalsaFax -E -v

and restarted cups.
now I could print a file to hylafax, but it was still a single fax

I then installed another perl script called pipe by Jiri Srain of Suse ( I tried a later, bash script by Johannes Meixner, but it failed for some reason that I could not fathom)  this pipes print input to a command.

I added it to the cups/backend directory, and

chmod 755 pipe

I then wrote a script, I called pssplitter, which uses psselect to split the print file into pages, then prints them to Salsafax, which in turn sends them via Hylafax.

and added another printer

sudo lpadmin -p Piper -E -v pipe:/usr/lib/cups/backend/

After a few false starts, pssplitter worked fine, except it seemed the maximum number of jobs it could send was 50.

This was cured by editing the /etc/cups/cupsd.conf file line

MaxJobs 50  to read
MaxJobs 400

I now print the Crystal report to a postscript printer on the local PC, and it is split into single pages and then faxed.
Other notes:
In a complex page, Salsafax can fail to detect the fax number (formatted as  Fax-Nr. : ), so it is a good idea to place the fax number at the top of the page. If you don’t want it to be visible on the fax, set the font colour to white, it will still be detected.

psselect may not  be the best solution, as it has to parse the file repeatedly, but it works.

We use Webmin a lot, so I installed the Hylafax server Webmin Module to monitor the queues.
the perl modules were installed from the webmin

Final Hiccup, Hylafax has a “Killtime” of 3 hours.

corrected this by adding

KillTime: “now + 7 days” to /etc/hyla.conf

Many thanks to those in the forums that I extracted the relevant information from.

7 versus Lucid

Well, I’ve installed Ubuntu 10.4 (aka Lucid Lynx) on 11 PCs so far, including 2 netbooks and a laptop, all without tears (even my
Mythbuntu box, which is running all sorts of wierd stuff, upgraded without problems)

The PCs are 2 netbooks and a laptop, 2 desktop PCs in general office use for exchange email, data input, web ordering and wordprocessing, etc., an FTP relay,a Kitchen PC (mini-ITX), a Mythbuntu PVR/media centre, 2 home user desktops and my multi-OS testbed machine.

These include Nvidia, ATI, and GMA graphics, Intel P4, Atom, Core duo and Celeron 2, AMD single and dual core, various screens, chipsets, drives, opticals, peripherals, etc, etc.

Flavours include UNR, Desktop 64&32 bit, mythbuntu 64.

After running 7 and Lucid side by side on my laptop for some time now (since ubuntu RC1), Ubuntu is actually far more stable than 7, but to be fair, I do have a lot of specialised software installed on 7.

7 generally fails to recover from Hibernation and it has crashed a couple of times when plugging in an external projector. The wifi and VPN sometimes go on holiday too, whereas Lucid has remained rock solid.
In most respects, Lucid is a very well behaved and flexible desktop, and it is just nicer to use than 7.
I personally find the clunky start menu and reduced features in 7 an annoyance. “Classic view” is no longer available, and making changes to the look and feel is not as easy as it should be.

And before anyone says it, no CLI required on any of these installs, apart from Mythbuntu and the FTP relay (and that was not required except for some of the more specialist stuff that most users wouldn’t need anyway).