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

 Calibration

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”

EndSection

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: http://www.cnx-software.com/2016/03/16/orange-pi-one-board-quick-start-guide-with-armbian-debian-based-linux-distribution/
  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
hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (here we are forcing 800x480)
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
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:

dtparam=spi=on

and add this line:

dtoverlay=ads7846,penirq=25,speed=10000,penirq_pull=2,xohms=150

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:
http://www.tbsdtv.com/download/document/common/tbs-linux-drivers_v150525.zip
or paste this into a terminal:
wget http://www.tbsdtv.com/download/document/common/tbs-linux-drivers_v150525.zip

Some people have reported problems with the latest driver, here is where to get an earlier version:
http://www.tbsdtv.com/download…
or paste this into a terminal:
wget http://www.tbsdtv.com/download…

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 tbs-linux-drivers_v150525.zip /home/tvdrivers

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

for version 141019:
cp
tbs-linux-drivers_v141019.zip /home/tvdrivers

cd /home/tvdrivers
unzip tbs-linux-drivers_v141019.zip
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/tbs-x86_r3.sh
for 64 bit:
sudo ./v4l/tbs-x86_64.sh
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:
http://linuxtv.org/wiki/index….

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

run
faxsetup

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

faxaddmodem

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)

example:

#
# Hylafax Faxing Users
#
^administrator@localhost:::ATBQ4ESC8wphE

#
# Hylafax Faxing Hosts
#
localhost
127.0.0.1
192.168.1.*

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 salsafax.pl

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 salsafax.pl:

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/pssplitter.sh

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.

MythZoneminder episode 2

Well, it seems that there is a problem with Mythbuntu and Zoneminder.

after installing Zoneminder and MythZMserver, etc. making a symlink from ZM.conf to apache modules, it all runs, but no images.

It seems to be a shared memory issue, or a database issue, not sure yet, and I have given up until after the weekend.

It could just be a permissions problem, as Firefox seems unable to save files unless run sudo, so will have to look into that too.

I can view images from the Webcam remotely using uvc_streamer on port 8080.

MythTV: Mythzoneminder

If  you have a PC in the living room, on constantly to record TV programs, why not make more use of it?

That’s what I thought, so I’m trying to set up Zoneminder, and the Mythtv plugin for it.

First steps:

Install  Zoneminder, Mythzoneminder

I am running Mythbuntu, with Mythweb installed and running,  so I will access this via <http://IPaddress/zm&gt; locally, or from the internet  <http://IPaddress:portnumber/zm

Put a symlink to the Zoneminder.conf file in the /etc/apache/modulesenabled directory:

sudo ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf

restart apache

sudo /etc/init.d/apache2 force-reload

allow apache access to video

sudo adduser www-data video

Next set up your webcam.

I am using a Logitech E3500, which is well supported in Linux, I hav e used it with Skype.

It requires the uvc cam driver, so used synaptic to install it.

Mealtime beckons, will continue tomorrow