Raspberry Pi Sinclair TV LCD Conversion

Sinclair TV MQTT Display
Sinclair TV MQTT Display

I got the idea for this after watching Dave’s teardown of the 1984 Sinclair flat screen pocket TV and thought it looked like a good candidate to make a cool retro style status display housing.

So soon after watching Dave’s teardown I headed off to eBay and picked one up, this one was non-functional to begin with (dead CRT) so I had no qualms about gutting it. With the guts and the fresnel lens removed you are left with a nice big space with a nice clear window for the screen.

The original guts showing the flat CRT and the fresnel lens on the left
The original guts showing the flat CRT and the fresnel lens on the left

Version 1 – Tiny328 and 1.8″ LCD

Initially I stuck a 1.8″ SPI LCD that I already had spare and one of my Tiny328 boards in it, receiving data directly from my sensors using the RFM12B transceiver. The 1.8″ 160×128 display proved the concept but was just a little too small as its surround and flex cable was visible within the TVs screen aperture so I took a punt on a 2.2″ SPI LCD which seemed like it would be a better fit.

First version with 1.8" LCD
Version 1 with a 1.8″ LCD

 

Version 2 – Spark Core and 2.2″ LCD

The 2.2″ LCD I bought is a QVGA (240×320) display and the panel itself fits nicely into the recess on the inside of the TV case and lines up perfectly with the window with none of its surround showing at all, it could have been made for it. Cost? All of £3.65 including shipping from Hong Kong, crazy.

Second version with 2.2" LCD
Version 2 with a 2.2″ LCD

With this one I decided to swap the Tiny328 for a Spark Core and used it as a WiFi MQTT display for a while but I wasn’t really happy with the resulting graphics and decided that to really make full use of its potential it had to have a Raspberry Pi inside and that case looked the perfect size.

 

Version 3, The Raspberry Pi

It turned out that the Raspberry Pi Model A was almost exactly the right size but despite trying many different orientations I couldn’t quite get the case to fully close with it inside (if only I’d had this then) even after carefully bending the pins on the display over 90 degrees so they were parallel with the board. In the end I bit the bullet and decided to slim the Pi down by desoldering the composite video socket, audio output socket and the 26 GPIO pins. I then soldered the wires from the display directly to the necessary pads on the Pi. Now it fit with room to spare.

I used some Sugru to hold the LCD in position and covered it with a piece of plastic so it doesn’t short out on the Pi which sits nicely above it between the original standoffs. I’ve also used some Sugru to fit an infrared remote receiver in the window for the old tuning dial and to fill the holes for the original control wheels I cut one of the wheels in half and stuck them in with yet more Sugru, From the outside it looks as Sir Clive intended.

2.2" LCD mounted with Sugru
2.2″ LCD mounted with Sugru

For network connectivity I have used the tiny Edimax EW-7811UN WiFi dongle and I’ve added one of these MicroSD adapters to further reduce the footprint of the Pi. With all this done everything fits inside nicely with the USB cable for power exiting via the original power socket hole. There is also a pair of speakers and a small amplifier board hidden under the Pi on the right hand side, more on that later.

The slimmed down Raspberry Pi with LCD, amplifier, speakers and IR sensor fitted.
The slimmed down Raspberry Pi with LCD, amplifier, speakers and IR sensor fitted.

 

Connecting the 2.2″ display to the Raspberry Pi

The LCD is connected to the Raspberry Pi as follows:

LCD Raspberry Pi
SDI (MISO) Not Connected
LED P1-18 (GPIO24)
SCK P1-23 (SCLK)
SDI (MOSI) P1-19 (MOSI)
D/C P1-22 (GPIO25)
RESET P1-16 (GPIO23)
CS P1-24 (CE0)
GND P1-25 (GND)
VCC P1-17 (3.3V)

For the Raspberry Pi GPIO pins refer to the layout here.

 

Setting up FBTFT

Fortunately using these SPI displays with the Pi is a doddle thanks to Notro’s FBTFT kernel drivers which support a range of popular display controllers including the ILI9340 controller used in this one.

There are two ways you can use the FBTFT kernel drivers, either via kernel modules or using a kernel with the drivers built in, I went with the kernel option as it allows you to use the LCD as your console straight from boot.

It’s easy to set up, first make sure you have the rpi-update with REPO_URI support installed with:

sudo wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-upda

then enable the SPI kernel module by editing /etc/modprobe.d/raspi-blacklist.conf and commenting out or removing the line: blacklist spi-bcm2708

Next install the kernel with FBTFT support with:

sudo REPO_URI=https://github.com/notro/rpi-firmware BRANCH=builtin rpi-update

FBTFT used like this needs to be configured on the kernel command line in /boot/cmdline.txt

The display I am using has a ILI9340 controller which is compatible with the fb_adafruit22a driver so I have used the following in the kernel command line:

fbtft_device.name=fb_adafruit22a fbtft_device.speed=32000000 fbtft_device.gpios=reset:23,dc:25,led:24 fbtft_device.bgr=1 fbtft_device.rotate=270 fbcon=map:10 fbcon=font:ProFont6x11

This breaks down as follows:

fbtft_device.name=fb_adafruit22a
Tells FBTFT to use the Adafruit 22a driver.

fbtft_device.speed=32000000
Sets the SPI speed in Hz

fbtft_device.gpios=reset:23,dc:25,led:24
Configures which GPIO pins have been used for the reset, DC and LED pins.

fbtft_device.bgr=1
Inverts the red and blue which is required on this display.

fbtft_device.rotate=270
Sets the angle to rotate display counter clockwise, can be one of 0, 90, 180, 270

fbcon=map:10
Sets the boot console to always uses the LCD

fbcon=font:ProFont6x11
Sets the font to use for the console, can be one of: MINI4x6, VGA8x8, Acorn8x8, PEARL8x8, ProFont6x11, 7×14, VGA8x16, SUN8x16, 10×18, SUN12x22

 

Testing it

Video playback
Video playback

Once the FBTFT options have been added to the kernel command line a reboot should see the console displayed on the LCD straight from boot.

Log in (I did this via ssh) and then you can also launch X with FRAMEBUFFER=/dev/fb1 startx

or play a video from the commandline by installing mplayer and using the command:

sudo mplayer -nolirc -vo fbdev2:/dev/fb1 -framedrop filename.mpg

If you want to have it automatically login at the console you can edit /etc/inittab and change

1:2345:respawn:/sbin/getty –noclear 38400 tty1

to:

1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1

Where pi is the name of the user you want to be logged in.

Default Raspbian Desktop
Default Raspbian Desktop

To run a program automatically on login you can just add it to the end of ~/.profile
eg. Install htop and add htop to the end of .profile, combined with the automatic login the Pi will boot and automatically display htop, ideal for a little status display if you are using it as a server of some kind.

If you want to start X automatically edit /etc/rc.local
and add the following where pi is the name of the user you want to be logged in.

su -l pi -c “env FRAMEBUFFER=/dev/fb1 startx &”

Tip: To disable the screen blanker (default 30 mins) change the BLANK_TIME=30 to BLANK_TIME=0 in /etc/kbd/config

There are some more tricks described here including frame buffer mirroring which allows you to take advantage of the Raspberry Pi GPU for a faster display.

 

Adding an IR receiver

With IR Remote Control
With IR Remote Control

I also added an infrared receiver so I could control things from a remote control. I used a TSOP31238 IR receiver as it was the same one I used in my TinyPCRemote project and I had one spare but other 38kHz receivers that work at 3V3 with an active low output should work fine. The receiver is mounted behind the window used for the original tuning dial using a bit of Sugru.

Connection is simple:

TSOP31238 RasPi
GND P1-06 (GND)
VCC P1-01 (3V3)
OUT P1-12 (GPIO18)

To set it up make sure lirc is installed and then load the module:

sudo apt-get install lirc
sudo modprobe lirc_rpi

Then to test the receiver is working do:

sudo mode2 -d /dev/lirc0

Pressing buttons on your remote control should now result in a series of pulse and space messages being displayed, eg.

pulse 1624981
space 9055
pulse 4481
space 604
pulse 544
space 582
pulse 1653
space 602
pulse 1671
space 573
pulse 537
space 591
pulse 545

Now we know the remote control is working we can set up an lirc.conf file for our remote controls buttons.

To do this first shut down lirc with sudo /etc/init.d/lirc stop

Then run sudo irrecord -d /dev/lirc0 ~/lirc.conf and follow the on screen instructions, when it comes to naming your buttons you need to use names from the lirc namespace which you can get a list of by doing irrecord –list-namespace

The irrecord process will generate a file like this:

# Please make this file available to others
# by sending it to <lirc@bartelmus.de> #
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sat Jul 19 14:03:26 2014
#
# contributed by
#
# brand: /root/lirc.conf
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

name /root/lirc.conf
bits 16
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100

header 9041 4492
one 587 1669
zero 587 540
ptrail 588
repeat 9040 2232
pre_data_bits 16
pre_data 0x61D6
gap 108285
toggle_bit_mask 0x0

begin codes
KEY_POWER 0x48B7
KEY_LEFT 0x20DF
KEY_RIGHT 0x609F
KEY_SELECT 0xD827
KEY_MENU 0xA05F
end codes

end remote

This shows the config file for the basic 5 button remote I am using.

Copy this new file over to /etc/lirc/lircd.conf and edit /etc/lirc/hardware.conf to change the line DRIVER=”UNCONFIGURED” to DRIVER=”default”

and

DEVICE=””
MODULES=””

to

DEVICE=”/dev/lirc0″
MODULES=”lirc_rpi”

Then do sudo /etc/init.d/lirc start

From there you can go on to use it as an lirc device. I wanted to use it with Python so the final step was to install the lirc Python bindings with sudo apt-get install python-pylirc

 

Adding Sound

I originally planned to make a little amplifier based on the mono LM386 and the original speaker but by a stroke of luck this nice LM4871 based stereo amplifier board with speakers fell into my lap (saved from going in the bin due to a broken power switch). Just the job.  I just bypassed the power switch, removed the 3.5mm jack plug and connected the inputs directly to the Raspberry Pi where the original socket was and connected the power to the 3v3 line. Then it was just a case of sticking the board and speakers under the Pi out of the way (Sugru again) and we’re done.

Amplifier board and speakers
Amplifier board and speakers

 

PyGame User Interface

I am using the finished device to display information from my home automation and monitoring system and have started to create some screens using PyGame. The data is coming in from NodeRED via MQTT and I can use the infrared remote control to switch different displays. This is a lot more versatile and with much better graphics than version 1 and 2 of this display.

Sinclair TV MQTT Display
Sinclair TV MQTT Display
MQTT Power Dial DIsplay
MQTT Power Dial DIsplay

Here is an example of some of the (in progress) code I am working on for it.

 

And finally

Just for a bit of fun, here is a video showing the Sinclair TV playing a recording of a News At Ten story on the launch of the Sinclair TV.

3 thoughts on “Raspberry Pi Sinclair TV LCD Conversion

  1. Hi Nathan. Do you still have the faulty internals of the TV ? I’d be interested in the CRT for my collection of strange odds-and-ends. Contact me by mail if are willing to part with it.

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.