fbcp-ili9341 icon indicating copy to clipboard operation
fbcp-ili9341 copied to clipboard

Waveshare 2" 320x240 compatibility?

Open regerohan opened this issue 4 years ago • 14 comments

Hi,

I recently saw this waveshare 2" IPS screen https://www.waveshare.com/2inch-lcd-module.htm

It looks very similar to the adafruit 2" IPS screen https://www.adafruit.com/product/4311 except that the waveshare module doesn't have the sdcard slot. Both have the same controller too: ST7789

Will the driver be compatible with the waveshare display? My plan is to use it with a rpi-zero-2 W

Thanks

regerohan avatar Nov 20 '21 12:11 regerohan

I am not aware of anyone having tried that display with the driver. There are several other ST7789-based displays that have been used though with a ST7789 driver backend, so it is possible that it can work.

juj avatar Nov 23 '21 10:11 juj

Hi, I just bought the Waveshare 2inch LCD Display.
On their wiki page about this display they offer a modified version of the fbcp-ili9341 library with predefined header files for the 2inch-waveshare display:

sudo apt-get install cmake -y
cd ~
wget https://www.waveshare.com/w/upload/8/8d/Waveshare_fbcp-main.7z
sudo apt-get install p7zip-full
7z x Waveshare_fbcp-main.7z
cd waveshare_fbcp-main
mkdir build
cd build
cmake cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DWAVESHARE_2INCH_LCD=ON -DBACKLIGHT_CONTROL=ON -DSTATISTICS=0 ..
make -j
sudo ./fbcp

It works on my Raspberry 3 with Raspberry Pi Desktop Bullseye. For me it was neccessary to disable the new graphic engine dtoverlay=vc4-kms-v3d in /boot/config.txt (see https://github.com/juj/fbcp-ili9341/issues/100#issuecomment-516426654) and change the DMA Ports as described here https://github.com/juj/fbcp-ili9341/issues/184#issuecomment-759343283

IMG_20211127_115108__01

@juj as one can see on the photo, the content on the display has some offset (starts in the middle and has overflow to the right). Any idea why that happens or how to fix this?

I allready tryed arround with offset values, but with no success... https://github.com/juj/fbcp-ili9341/blob/4aa3b97f4d295e3301651bd3dc3d314b25f2531e/gpu.cpp#L434

superjojo140 avatar Nov 28 '21 11:11 superjojo140

Hi guys, after hours of trial and error I have now managed to get the waveshare 2inch LCD display to run correctly on the Raspberry 3B with Raspberry OS Bullseye. In the end, I used the standard fbcp-ili9341 (this repo) (not the modified version of waveshare). However, some modifications were necessary:

install fbcp

sudo apt-get install cmake
cd ~
git clone https://github.com/juj/fbcp-ili9341.git
cd fbcp-ili9341

vc4-kms-v3d

For me it was necessary to disable the new graphics engine dtoverlay=vc4-kms-v3d in /boot/config.txt (see #100)

config.h

Customize config.h

#define GPIO_TFT_DATA_CONTROL 25
#define GPIO_TFT_BACKLIGHT 24
#define GPIO_TFT_RESET_PIN 27
#define DISPLAY_NATIVE_WIDTH 240
#define DISPLAY_NATIVE_HEIGHT 320

#define DMA_TX_CHANNEL 7 //Change the DMA ports to some free ports
#define DMA_RX_CHANNEL 5
#define STATISTICS=0 //Disable statistics overlay (optional)

st7735r.h

In st7735r.h I had to comment out line 19-20 to read the display size from config.h:

#if defined(ST7789) || defined(ST7789VW)
//#define DISPLAY_NATIVE_WIDTH 240
//#define DISPLAY_NATIVE_HEIGHT 240

st7735r.c

In st7735r.c I had to comment out line 95 to remove the offset at the top:

#ifdef ST7789
    // The ST7789 controller is actually a unit with a graphics memory area of 320x240, but only a part of 240x240
    // of it is displayed. So if we wanted to swap the above line address mode, writes in the Y=0...239 range would actually be in the
    // memory in the range of line addresses Y = 319-(0...239) = 319...80. To see this range, we have to scroll the view by +80 units in Y
    // direction so that the contents of Y=80...319 are displayed instead of Y=0...239.
    if ((madctl & MADCTL_ROW_ADDRESS_ORDER_SWAP))
      //SPI_TRANSFER(0x37/*VSCSAD: Vertical scroll start address of RAM*/, 0, 320 - DISPLAY_WIDTH);
#endif

Compile and execute:

mkdir build
cd build
cmake -DSPI_BUS_CLOCK_DIVISOR=20 -DST7789=ON ..
make -j
sudo ./fbcp-ili9341

superjojo140 avatar Nov 30 '21 14:11 superjojo140

Sorry, this is because I accidentally masked an initialization statement, Not long ago I discovered and fixed this problem

EngineerWill avatar Dec 17 '21 12:12 EngineerWill

bruh I cannot get this to work. . .I have followed every guide and rewired I dont know how many times configured vanilla fbcp repo and even tried the waveshare and im getting no life out of the display

Lizard-King101 avatar Aug 25 '22 02:08 Lizard-King101

bruh I cannot get this to work. . .I have followed every guide and rewired I dont know how many times configured vanilla fbcp repo and even tried the waveshare and im getting no life out of the display

hi bro Can you provide your hardware and connection diagram?

Have a nice day

EngineerWill avatar Aug 25 '22 03:08 EngineerWill