tft display orange pi pinout quotation
Hey guys, I"ve spent the last couple of weeks trying to get a TFT display with touch screen to work on my Orange Pi PC board, and I"ve decided to share my step-by-step solution here. This tutorial is heavily based on Guide: How to use Touchscreen + LCD on H3 devices by Kutysam, but I had to do some extra steps for it to work properly. This tutorial is only for Mainline kernel, I was able to get the graphical screen working with Kutysam"s guide for Legacy, but couldn"t make the touch work.
Also, I am using the image Armbian_5.38_Orangepipc_Debian_stretch_next_4.14.14_desktop, but it should work for the headless version (server) too, if you install a display manager, desktop environment and the X server.
Add the following lines to the end of the file (Be careful with spaces in the end of the lines... I lost a couple of days trying to figure out what the problem was when I had an extra space after "param_spidev_spi_bus=0"
Now we need to configure fbtft and fbtft_device on boot. Note: I had to put "98" in the start of the filename, or else I"d get the following error: "fbtft_device: spi_busnum_to_master(0) returned NULL" in dmesg after I installed the touchscreen. I believe it has something to do with the load order, so if you"re having problems with this file you could try changing the prefix to 99 or removing it.
And reboot. At this point your screen should at least turn black. For me, the GUI wouldn"t load unless I typed "startx" on the console. So this is how I fixed it to always display the GUI on boot:
options ads7846_device model=7846 cs=1 gpio_pendown=1 keep_vref_on=1 swap_xy=1 pressure_max=255 x_plate_ohms=60 x_min=200 x_max=3900 y_min=200 y_max=3900
options ads7846_device model=7846 cs=0 gpio_pendown=1 keep_vref_on=1 swap_xy=0 pressure_max=255 x_plate_ohms=60 x_min=200 x_max=3900 y_min=200 y_max=3900
Test your display to see if it works. This matrix worked best for me, but you might need to tweak it. Refer to this guide for more info on how coordinate transformation matrices work.
If you have multiple users logging in the session displayed on your screen, you might need to add this file for every user. ".xsessionrc" was the only file where I could get this working.
– orange pi zero all have 2 SPI bus: one in the main GPIO port, and one for the flash on the back side. If you don’t have the plus model, you can unsolder the FLASH and use the port. FLASH is port 1, so, GPIO is port 1. This is very important when you follow tutorials written for other opis
– before you start following a tutorial, you need to understand which kernel you are using. If the turial is written after jan 2017, and mentions adding an overlay in armbianEnv.txt, then it’s for kernel 4; if the tuto is before feb 2018, and does not mention altering armbianEnv.txt for SPI compatibility, author is using kernel 3. This is critical.
The TFT isn’t ‘plug & play’ with the Raspberry, a patch has to be applied to the kernel to be able to interface via SPI with the ST7735R controller chip on the TFT. Once working, the display will act as a framebuffer device.
As it takes over three hours to compile the kernel on the PI, I will show how to cross compile from another Linux PC. In my case, it is Ubuntu 12.10 running within VMWare on a Windows 7 Quad core PC. Kernel compile time is 15 mins.
-Copy config from the Raspberry Pi to the Ubuntu box using SCP. Replace ‘raspberrypi’ below with the IP address of your Raspberry Pi if hostname lookup fails.
If you are planning on displaying the console on the TFT, then enabling these options in .config will allow you to change the font size and rotate the display later on.
To enable parallel processing for a faster compile. If you have a dual core processor add -j 3 to the end of the command below. If you have quad core, add -j 6
The last step below is to SCP the files from from Ubuntu to the Raspberry Pi. If you have trouble SCPing into your Ubuntu box you may need to install open SSH on Ubuntu with sudo apt-get install openssh-server. This step also copies the files from my home folder ‘mark’… yours would be different.
If you build the st7735 driver pair as built-in, add these options to the end of the line in /boot/cmdline.txt. This will display the console on the TFT.
In the previous article, I described the steps needed to install an LCD touchscreen on the Raspberry Pi. In this article, I will show you how to adjust the screen rotation of the LCD to landscape mode, and will show you how to calibrate the touchscreen pointer for optimal accuracy. Just follow the steps below to compete the process of setting up your Raspberry Pi LCD touchscreen:
1. First we need to change the setting for screen rotation in the /boot/cmdline.txt file. This setting is called fbtft_device.rotate=X. By default, this is set to X=0, which results in a portrait mode screen orientation. In order to switch the orientation to landscape mode, change fbtft_device.rotate=0 to fbtft_device.rotate=90. Enter sudo nano /boot/cmdline.txt at the command prompt. There should only be one line in this file. Go to the end of it and you will find the fbtft_device.rotate=X setting. Change the value from 0 to 90:
After the Pi finishes rebooting, you should notice that when you move your finger across the touch screen, the pointer should follow correctly in both axes. If you are using the Raspberry Pi 2 Model B, you will need to complete the calibration steps below before the pointer follows your finger correctly (and make sure that you have enabled startx to load automatically – see step 6 in this article).
You can rotate the screen 90 degrees (as we did in this tutorial) and the power connector will be at the bottom of the screen, but you can also rotate it 270 degrees so that the power connector is at the top of the screen. To do this, simply enter fbtft_device.rotate=270 in the /boot/cmdline.txt file. Then change the DISPLAY=:0 xinput --set-prop "ADS7846 Touchscreen" "Evdev Axis Inversion" 0 1 line in the /etc/X11/xinit/xinitrc file to DISPLAY=:0 xinput --set-prop "ADS7846 Touchscreen" "Evdev Axis Inversion" 1 0. All you need to do is switch the values of the 0 and 1 at the end of this line.
4. Now we can use ts_calibrate. Enter ts_calibrate at the command prompt (make sure you are still in root mode) to run the ts_calibrate program. The program will consecutively display five crosses on different parts of the screen, which you need to touch with as much precision as possible:
Orange Pi has released the Zero2, a small form factor SBC based on the Allwinner H616 64-bit system on chip (SoC). Capable of supporting Android 10 natively, it contains a quad-core Cortex-A53 processor with integrated Mali G31 graphics. Connectivity is available via Wi-Fi, Bluetooth, and Ethernet, and the Zero2 supports a range of video decoding options up to 4k@60fps.
Compared to Orange Pi Zero, Orange Pi Zero2 offers a 64-bit Arm processor, more RAM up to 1GB, dual-band WiFi, Bluetooth 5.0 (no Bluetooth at all in Pi0), Gigabit Ethernet, and power via a USB-C port instead of a micro USB port.
While googling for any info about lcd controller I came across this page: http://heikki.virekunnas.fi/2015/raspberry-pi-tft/, author managed to get from manufacturer patch file for kernel sources and tested it with 4.1.y - on which lcd worked. But still LCD replace HDMI, but I want to use this screen as additional for user interaction, while the bigger on HDMI as presentation monitor.
Since, fbtft has been merged with rpi kernel, so the fb drivers (including ili9341.c) was moved to fbtft_device driver (so the author of page can"t compile latest kernel with driver+patch).
So something about hardware, which I reverse engineered by the "hard way" - "grab multimeter and run through all LCD FPC pins and shift register pins"
I"m pretty sure about D/C (Pin 37 on LCD) and Reset (Pin 19 on LCD) pins by looking into driver code, but I can"t identify other signals (WR/RD/CS/etc...)
[ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2709.boardrev=0xa01041 bcm2709.serial=0x2938b030 smsc95xx.macaddr=B8:27:EB:38:B0:30 bcm2708_fb.fbswap=1 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
- Controller is not ILI9341/ILI9325 - those are for smaller displays (320x240, etc...), I guess this might be ILI9486/9488 because they are for 480x320 displays. But when I compared init with DS it does not fit right so LCD can have a clone of ILI9486/9488 ...
- Module use only SPI interface and two CE signals (CE0 for touch controller, CE1 for LCD shift registers - compared to others lcd modules, in KeDei module this is swapped),
ER-TFT028-4 is 240x320 dots 2.8" color tft lcd module display with ILI9341 controller and optional capacitive touch panel and 4-wire resistive touch panel,superior display quality,super wide viewing angle and easily controlled by MCU such as 8051, PIC, AVR, ARDUINO ARM and Raspberry PI.It can be used in any embedded systems,industrial device,security and hand-held equipment which requires display in high quality and colorful image.It supports 8080 8-bit,9-bit,16-bit,18-bit parallel,3-wire,4-wire serial spi interface. FPC with zif connector is easily to assemble or remove.Lanscape mode is also available.
Of course, we wouldn"t just leave you with a datasheet and a "good luck!".Here is the link for 2.8"TFT Touch Shield with Libraries, Examples.Schematic Diagram for Arduino Due,Mega 2560 and Uno . For 8051 microcontroller user,we prepared the detailed tutorial such as interfacing, demo code and development kit at the bottom of this page.
Orange Pi 2G-IoT is a low cost ARM Linux board with 2G, and WiFi & Bluetooth connectivity, basically with the guts of a smartphone minus the display and battery. Shenzhen Xunlong has now released a 800×480 display with capacitive touch support for the board available in black or white, and selling for $9.98 plus shipping.
Software support is a mystery, and while I’m pretty sure it will work in Android, I don’t know if Linux distributions will support the display, at least at the beginning. The complete kit with the board and display would cost $20 plus shipping.
The best way to do this is to get the uBoot source code and and work from there, the uBoot actually does all the complicated low level stuff, like setting up the RAM and MMU, basic interrupts, serial ports, GPIO and other stuff necessary for Linux to boot later. It also has nice primitives to access all the flash memories, interfaces, set-up USB controller and even mount USB sticks and not to forget, a full network stack. Of course this is modular and you can use only what you need.
And, as I build, compile and load uBoot with Eclipse CDT, you should be also able to do it as well, if you want a nice friendly IDE, if you can live with compiling the code yourself, I strongly recommend Visual Studio Code for Linux, it"s absolute user friendly.
Pine64 UK is part of the Lilliput UK website family. We are proud to be the official distributor of Pine64 products in Europe and Pine64 UK operates alongside our main site lilliputdirect.com in order to bring you the latest Pine64 products.
Elsewhere in the blog I’ve referred to Tuya-Convert – which I have been running on the Raspberry Pi. Today Antonio (Mr Shark – based in Italy) and I took on the MINOR task of putting Tuya-Convert on an otherwise unused Orange Pi Zero.
Caviat: I should say at the start, that the process has been 90%+ successful (no utter failures) so far, with all the smart sockets we converted to Tasmota with Tuya-convert working first time but out of twelve ZemiSmart RGBCCW lamps, three failed to convert with Tuya-Convert – and I had to open them up and program them using wires (five including the ground, 3v3, GPIO0, rx and tx lines, conveniently brought out onto tiny PCB pads). The reason for the initial falures is not as yet totally clear. However in the end, all the ESP8266-based items we reprogrammed, worked in the end.
We originally started with a bare-bones Raspberry Pi 3 and a little NodeMCU ESP8266 board – and that worked fine but I felt guilty about tying up an RPi for this job, so then we tried a bare-bones Orange Pi Zero and the same NodeMCU-type ESP8266 board (i.e. any old ESP-12 board).
For the RPi version, start with an RPi2 or 3 with a fresh install of raspbian LITE, then create an empty “ssh” file in the boot partition (the fat32 one).
Login via ssh (on, say a PC) and run “sudo raspi-config”, go to localisation, “WiFi country” and BE SURE to select your country, otherwise “tuya-convert” will fail to bring up the wlan0 (WiFi) interface – this is important…
Alternatively as we have done now, use an Orange Pi Zero (OP0). Load“Armbian Buster” and install the microSD as per instructions on the Armbian website. The only thing to note is that Armbian-config does not set up any WIFI country on the OP0 so we had to do that by hand.
The last line when running Armbinan-config on a new OP0 will be “REGDOMAIN=” – that is NO GOOD for the OP0 – it MUST have a valid country – set that in the standard NANO editor to “REGDOMAIN=UK” without the quotes in the file shown above. On the Raspberry Pi an equivalent gets entered elsewhere by the initial setup when you set up the country and REGDOMAIN remains empty.
Start the flash process – on the OP0 as user ROOT (I arbitrarily added user Pi on initial setup of the OP0 but to avoid using SUDO, ultimately it was easier to simply use ROOT). On the RPI, user “pi” works just fine. In the tuya-convert folder you need to enter…
and follow instructions… assuming both the PI and the ESP8266 “donor” device are turned on and reasonably close, you’ll see the blinking LED on the DONOR device (in our case the NodeMCU board) turn solid blue once it connects to the vtrust-flash ssid, then you can put the hacking device (In our case, an ESP8266-based smartbulb or an ESP8266-based smart plug) in fast flashing mode and press ENTER in the Tuya console.
Below – with a little tidying up, Tuya-Convert on an Armbian-equipped Orange Pi Zero, boxed. My Raspberry Pi version needed a separate box for the USB-connected NodeMCU board and I can think of other uses for an RPi-3 whereas the OP0 was going to waste before this.