User avatar
MeneerJansen
Posts: 27
Joined: Sat May 14, 2016 1:51 pm

GoodTFT 3.5" screen from Aliexpress

Fri Apr 12, 2019 1:44 pm

My personal "How To" text file:

Code: Select all

 ____  _   ____                           
|  _ \(_) / ___|  ___ _ __ ___  ___ _ __  
| |_) | | \___ \ / __| '__/ _ \/ _ \ '_ \ 
|  __/| |  ___) | (__| | |  __/  __/ | | |
|_|   |_| |____/ \___|_|  \___|\___|_| |_|
- GoodTFT 3.5" screen from Aliexpress -


Contents
1. Introduction
2. Install "driver"
3. Set display upright
4. Configure Xorg
  • 4.1 /etc/X11/xorg.conf.d/99-calibration.conf
  • 4.2 Setting for the pen/touch screen
  • 4.3 Calibrate touch screen
  • 4.4 Right mouse button
5. Switch back to HDMI
6. Dual screen
X. References

1. Introduction
You can buy this screen from Aliexpress [1] together w/ a case in which both the Pi and the screen will fit. It's a clone from the better known Waveshare device [6], [7]. This device is called "GoodTFT".

The instructions in this text file will probably only work with Raspbian 9.8 (code name "Stretch").


2. Install "driver"
Open a terminal and run [1] (beware: scripts need to be altered before executing, read on):

Code: Select all

   sudo rm -rf LCD-show
   git clone https://github.com/goodtft/LCD-show.git
   chmod -R 755 LCD-show
   cd LCD-show/
   sudo ./LCD35-show
The script creates a non working Xorg config file (see further on), does not make a backup of the 'cmdline.txt' and 'config.txt' files it overwrites in '/boot/' and it overwrites '/etc/inittab'. So changes you made in those files (e.g. to make the Pi boot faster) must be backuped by you yourself!

The script that lets you use the HDMI port again (LCD-hdmi) has notorious flaws too (see further on).

Download my versions of the scripts as well as '99-calibration.conf-35' from [8] (see ref on where to place them). Probably only works with Raspbian 9.8 Stretch.

In fact, the scripts do not install a device driver at all. They make changes in settings. These settings are probably for a Raspbian version older than 9.8 Stretch which might be why they fail.


3. Set display upright
Rotate the screen so that it can be set upright (with the cables coming out of the top). Change this setting in '/boot/config.txt' to [3]:

Code: Select all

   dtoverlay=tft35a:rotate=270
(Or into: dtoverlay=tft35a:rotate=270,swapxy=1)

rotate=0 top of screen is at physical left
rotate=90 top of screen is at physical bottom (up-side down)
rotate=180 top of screen is at physical right
rotate=270 top of screen is at physical top (right-side up)

See ref. [8] on where to download the proper versions of 'config.txt' and where to place them on the Pi because it will be replaced by the scripts. And yes, there is a typo in "config-nomal.txt".


4. Configure Xorg
You configure Xorg via the file '/etc/X11/xorg.conf.d/99-calibration.conf'.

4.1. General
Make '/etc/X11/xorg.conf.d/99-calibration.conf' look like this [4]:

Code: Select all

Section "InputClass"
   Identifier "calibration"
   MatchProduct "ADS7846 Touchscreen"
   # Hat trick to get the pen to work properly on the touch screen, rotate 90 degrees clockwise:
   Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
   # Don't use libinput but evdev for the touch screen and the pen so calibration works:
   Driver "evdev"
   Option  "Calibration"   "3936 227 268 3880"
   Option "InvertY" "false"
   Option "InvertX" "true"
   # Right mouse button is long press with pen:
   Option "EmulateThirdButton" "1"
   Option "EmulateThirdButtonTimeout" "750"
   Option "EmulateThirdButtonMoveThreshold" "30"
EndSection

Section "Device" 
   # WaveShare SpotPear 3.5", framebuffer 1
   Identifier "uga" 
   driver "fbdev" 
   Option "fbdev" "/dev/fb1" 
   Option "ShadowFB" "off"
EndSection 

Section "Monitor" 
   # Primary monitor. WaveShare SpotPear 480x320
   Identifier "WSSP" 
EndSection 

Section "Screen" 
   Identifier "primary" 
   Device "uga" 
   Monitor "WSSP" 
EndSection 

Section "ServerLayout" 
   Identifier "default" 
   Screen 0 "primary"
EndSection

4.2 Setting for the pen/touch screen
To rotate clockwise 90 degrees, change to [5]:

Code: Select all

    Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"

4.3 Calibrate touch screen
Making the touchscreen device default to the evdev driver rather than the libinput driver is pretty simple, and solves the problem [3]. Make sure the evdev driver is installed:

Code: Select all

   sudo apt-get install xserver-xorg-input-evdev
Example:

Code: Select all

   Driver "evdev"
   Option  "Calibration"   "3936 227 268 3880"
   Option "InvertY" "false"
   Option "InvertX" "true"

4.4 Right mouse button
Long press is right mouse button. Add:

Code: Select all

   # Right mouse button is long press with pen:
   Option "EmulateThirdButton" "1"
   Option "EmulateThirdButtonTimeout" "750"
   Option "EmulateThirdButtonMoveThreshold" "30"

5. Switch back to HDMI
If you need to switch back to the traditional HDMI display [2]:

Code: Select all

   cd ~/LCD-show
   sudo ./LCD-hdmi
That script doesn't work properly; use the one I made myself. Among others the "official" script creates non-working versions of '/usr/share/X11/xorg.conf.d/99-fbturbo.conf' and '/etc/X11/xorg.conf.d/99-calibration.conf'. Xorg does not need them to work w/ HDMI, so simply delete them. The "official" script also replaces '/etc/modules' with a non-working one. Replace it with:

Code: Select all

   # /etc/modules: kernel modules to load at boot time.
   #
   # This file contains the names of kernel modules that should be loaded
   # at boot time, one per line. Lines beginning with "#" are ignored.
   
   i2c-dev
It also overwrites '/boot/config.txt' and '/etc/inittab'.


6. Dual screen
You can "activate" the HDMI monitor next to the TFT screen. However, the keyboard does not work in applications on the HDMI screeen but the mouse does. The keyboard does work in the context menu (right click on an icon). You can start applications that you place on the desktop. Apparently there is no window manager active on the HDMI screen. You cannot move windows nor do they have a window border.

If you want full resolution from the HDMI monitor/TV start the Pi with the TV on and connected.

Code: Select all

Section "Device"
        Identifier      "hdmi_device"
        Driver          "fbdev"
        Option          "fbdev" "/dev/fb0"
EndSection

Section "Monitor"
   # HDMI
   Identifier "hdmi_monitor"
EndSection

Section "Screen"
   Identifier "hdmi_screen"
   Device     "hdmi_device"
   Monitor    "hdmi_monitor"
EndSection

Section "ServerLayout"
   Identifier "default"
   Screen 0 "primary"
   Screen 1 "hdmi_screen" RightOf "primary"
EndSection


X. References
[1] Instructions from Aliexpress:
https://www.aliexpress.com/item/Latest- ... 4c4dSiCClj

[2] Github, GooodTFT:
https://github.com/goodtft/LCD-show.git

[3] Github, set GoodTFT display upright:
https://github.com/goodtft/LCD-show/issues/34

[4] Configure Xorg:
https://www.raspberrypi.org/forums/view ... p?t=162323

[5] Rotate pen touch screen:
https://github.com/swkim01/waveshare-dt ... /README.md

[6] Waveshare github:
https://github.com/waveshare/LCD-show

[7] Waveshare "Wiki":
https://www.waveshare.com/wiki/3.5inch_RPi_LCD_(A)

[8] My versions and where to place them:
LCD-35-show https://pastebin.com/gZ9fTHxe (place in /home/pi/LCD-show/)
LCD-hdmi https://pastebin.com/LrhE2QYX (place in /home/pi/LCD-show/)
99-calibration.conf-35 https://pastebin.com/Vn5zaqde (place in /home/pi/LCD-show/usr/)
config-35.txt https://pastebin.com/5FdjhvJZ (place in /home/pi/LCD-show/boot/)

Return to “HATs and other add-ons”