Install the drivers
Taken from: https://s3.amazonaws.com/ttbox/35screen.zip
This is taken from information last updated on 2015-09-05
Below you will find instructions for installing the appropriate drivers for the Tontec 3.5 inch screen on your Raspberry Pi (including Pi 2). This guide was written for Raspbian wheezy, specifically 2015-05-05-raspbian-wheezy.img, though the guide should work on later versions as well.
1. Initial Config of New Raspberry Pi Install
After booting your Raspberry Pi for the first time on Raspbian-Wheezy, we will need to perform the normal tasks of setting up our Raspberry Pi. E.g expand filesystem,
Then we need “update” and “upgrade”
sudo apt-get update
sudo apt-get upgrade
2. Update Firmware
We now need to update the dtb file to the newest version to support Tontec screen.
sudo rm mz61581-overlay.dtb
sudo wget http://www.itontec.com/mz61581-overlay.dtb
3. Enable SPI and set overlay for Tontec MZ61581 Screen
sudo nano /boot/config.txt
And add these lines to the bottom
Then save and reboot
4. Set Tontec 3.5 Screen as the default display instead of HDMI
sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf
Here we will change the default output display from HDMI to Tontec Screen
Option "fbdev" "/dev/fb0"
Option "fbdev" "/dev/fb1"
– if you want to switch back to the HDMI display, just change it back to fb0
5. Edit cmdline.txt
Here we will enable Tontec Screen to display during the booting process
sudo nano /boot/cmdline.txt
Add fbcon=map:10 at the end of current line. (No need to start a new line)
Calibrate the touch screen for X Windows
Taken from: http://s3.amazonaws.com/ttbox/35calibrate.zip
We’ll install an xinput_calibrator and a script to load the calibration data each time X starts.
1. Install all the prerequisites required for calibration
sudo apt-get install libtool libx11-dev xinput autoconf libx11-dev libxi-dev x11proto-input-dev -y
2. Download and install xinput_calibrator
git clone https://github.com/tias/xinput_calibrator
sudo make install
3. Download and setup the calibration script
sudo cp ~/xinput_calibrator_pointercal.sh /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh
sudo sh -c 'echo "sudo /bin/sh /etc/X11/Xsession.d/xinput_calibrator_pointercal.sh" >> /etc/xdg/lxsession/LXDE-pi/autostart'
Start up X Windows
Plug in a USB mouse as you won’t be able to click on much as the screen’s not calibrated.
Click on [Menu] -> [Preferences] -> [Calibrate Touchscreen]
Go through the calibration and a console window will appear.
The calibration program will create a file which stores the calibration data( /etc/pointercal.xinput)
Click [File] -> [Close]
To perform calibration again, just delete /etc/pointercal.xinput and restart X. You will be presented again with the calibration program once X starts.