Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

Interfacing (DSI, CSI, I2C, etc.) • Re: Small TFT based on ILI9341 ST7789 - how to use

$
0
0
Hi all,

for the last few days, I've been extensively reading this, and
viewtopic.php?t=358240&hilit=Ili9341#p2165638 for a clear solution for the 4.0 inch TFT-LC320*480 RGB touch, with part number ZJY400S110TTG01-ST7796. it looks similar to this, but with a blue PCB, and no pins for the SD reader. (see https://www.okaphone.com/artikelen.xhtml?id=4)
I've gotten this display running. But it's very glitchy with all the solutions I tried in this forum. Plus I have the problem that all information I need to pool together is scattered all over. So I caved, and dare to post here. I hope I'm not a bother, and I hope it helps others with this display find all info in one place, to make it a little easier.

So, I've read enough to understand that I need a device tree, the init sequence, convert those with https://github.com/notro/panel-mipi-dbi and the correct lines in /boot/firmware/config.txt.

The most glitch free solution I've had so far, with the only problem it mirroring the image on the display, came from the pitft-fbcp.sh script included in https://github.com/adafruit/Raspberry-P ... er-Scripts. This uses an unknown device tree that I can't seem to locate, pitft35-resistive. These lines makes the display work, but mirrored.

Code:

dtoverlay=pitft35-resistive,rotate=270,speed=32000000,fps=60display_rotate=0hdmi_force_hotplug=1hdmi_group=2hdmi_mode=87hdmi_cvt=480 320 60 1 0 0 0
step 1: find the appropriate device tree
This is where I'm running into trouble. the ST7796 seems hard to find.
seems relevant: https://docs.zephyrproject.org/latest/b ... 7796s.html,
https://github.com/Sergey1560/fb_st7796 ... me-ov-file,


step 2: turn this into a usable .txt file
https://www.lcdwiki.com/res/MSP3525_MSP ... 6_Init.txt

Code:

void LCD_Init(void){ LCD_RESET(); //LCD 复位//*************3.5 ST7796S IPS初始化**********//LCD_WR_REG(0x11);     delay_ms(120);                //Delay 120msLCD_WR_REG(0x36);     // Memory Data Access Control MY,MX~~LCD_WR_DATA(0x48);   LCD_WR_REG(0x3A);     LCD_WR_DATA(0x55);   LCD_WR_REG(0xF0);     // Command Set ControlLCD_WR_DATA(0xC3);   LCD_WR_REG(0xF0);     LCD_WR_DATA(0x96);   LCD_WR_REG(0xB4);     LCD_WR_DATA(0x02);   LCD_WR_REG(0xB7);     LCD_WR_DATA(0xC6);   LCD_WR_REG(0xC0);     LCD_WR_DATA(0xC0);   LCD_WR_DATA(0x00);   LCD_WR_REG(0xC1);     LCD_WR_DATA(0x13);   LCD_WR_REG(0xC2);     LCD_WR_DATA(0xA7);   LCD_WR_REG(0xC5);     LCD_WR_DATA(0x21);   LCD_WR_REG(0xE8);     LCD_WR_DATA(0x40);   LCD_WR_DATA(0x8A);   LCD_WR_DATA(0x1B);   LCD_WR_DATA(0x1B);   LCD_WR_DATA(0x23);   LCD_WR_DATA(0x0A);   LCD_WR_DATA(0xAC);   LCD_WR_DATA(0x33);   LCD_WR_REG(0xE0);     LCD_WR_DATA(0xD2);   LCD_WR_DATA(0x05);   LCD_WR_DATA(0x08);   LCD_WR_DATA(0x06);   LCD_WR_DATA(0x05);   LCD_WR_DATA(0x02);   LCD_WR_DATA(0x2A);   LCD_WR_DATA(0x44);   LCD_WR_DATA(0x46);   LCD_WR_DATA(0x39);   LCD_WR_DATA(0x15);   LCD_WR_DATA(0x15);   LCD_WR_DATA(0x2D);   LCD_WR_DATA(0x32);   LCD_WR_REG(0xE1);     LCD_WR_DATA(0x96);   LCD_WR_DATA(0x08);   LCD_WR_DATA(0x0C);   LCD_WR_DATA(0x09);   LCD_WR_DATA(0x09);   LCD_WR_DATA(0x25);   LCD_WR_DATA(0x2E);   LCD_WR_DATA(0x43);   LCD_WR_DATA(0x42);   LCD_WR_DATA(0x35);   LCD_WR_DATA(0x11);   LCD_WR_DATA(0x11);   LCD_WR_DATA(0x28);   LCD_WR_DATA(0x2E);   LCD_WR_REG(0xF0);     LCD_WR_DATA(0x3C);   LCD_WR_REG(0xF0);     LCD_WR_DATA(0x69);  delay_ms(120);                LCD_WR_REG(0x21);     LCD_WR_REG(0x29);     LCD_direction(USE_HORIZONTAL);//设置LCD显示方向 }
according to the wiki yields

Code:

delay 120command 0x01delay 120command 0x11delay 120command 0xF0 0xC3command 0xF0 0x96command 0x36 0x48command 0x3A 0x55command 0xB4 0x01command 0xB6 0x80 0x02 0x3Bcommand 0xE8 0x40 0x8A 0x00 0x00 0x29 0x19 0xA5 0x33command 0xC1 0x06command 0xC2 0xA7command 0xC5 0x18delay 120command 0xE0 0xF0 0x09 0x0b 0x06 0x04 0x15 0x2F 0x54 0x42 0x3C 0x17 0x14 0x18 0x1Bcommand 0xE1 0xE0 0x09 0x0B 0x06 0x04 0x03 0x2B 0x43 0x42 0x3B 0x16 0x14 0x17 0x1Bdelay 120command 0xF0 0x3Ccommand 0xF0 0x69delay 120command 0x29
run 'notro's' python script (https://github.com/notro/panel-mipi-dbi)

Code:

python mipi-dbi-cmd ST7796.bin ST7796.txt
Step 4: copy it over

Code:

sudo cp 4in.bin /lib/firmware
step 5: add lines in /boot/firmware/config.txt (these seem to work, since mirroring was a driver issue accoring to a post I read but can't locate)

Code:

dtoverlay=pitft35-resistive,rotate=270,speed=32000000,fps=60display_rotate=0hdmi_force_hotplug=1hdmi_group=2hdmi_mode=87hdmi_cvt=480 320 60 1 0 0 0
Most of these steps seem straightforward enough (although I am having a little trouble with converting the initialisation method to my own text file, since there seem to be some extra commands at the start of the wiki's file? I also tried with the waveshare file suitable for the ST7796, but had no success.

In any case, I'd appreciate any clues that anyone can offer. I think I'm very close to fully understanding what makes it work, but I think I need the proper device tree first. I've found this (https://ali-nasrolahi.github.io/posts/r ... m-overlay/), but it's not a ready-made solution that I'm able to utilise yet. So maybe with some help I'll get there. Thanks in advance for your extra eyes, and all the work that you've already put in.

pin connections (GPIO##):

Code:

CLK11MOS10RES24DC25BLK23MIS9"CS18CS2 7PENNC

Statistics: Posted by dikkedimi — Thu Jan 08, 2026 12:03 pm



Viewing all articles
Browse latest Browse all 8609

Trending Articles