juj / fbcp-ili9341

A blazing fast display driver for SPI-based LCD displays for Raspberry Pi A, B, 2, 3, 4 and Zero
MIT License
1.55k stars 258 forks source link

QVGA 2.2" ili9341 display #182

Open gthieleb opened 3 years ago

gthieleb commented 3 years ago

I stumbled about this project while trying to get a 2.2" inch display running on a RPI3 B+ using a recent raspbian release . The display is connected without a HAT using wires and the pinouts described in this older tutorial

Both MOSI and MISO are connected but the screen keeps blank.

Compilation is done using the following flags:

cmake -DILI9341=ON -DSPI_BUS_CLOCK_DIVISOR=6 -DGPIO_TFT_BACKLIGHT=18 -DGPIO_TFT_RESET_PIN=25 -DGPIO_TFT_DATA_CONTROL=24 ..

The binary starts with or without the display attached:

sudo ./fbcp-ili9341 
bcm_host_get_peripheral_address: 0x3f000000, bcm_host_get_peripheral_size: 16777216, bcm_host_get_sdram_address: 0xc0000000
BCM core speed: current: 250000000hz, max turbo: 400000000hz. SPI CDIV: 6, SPI max frequency: 66666667hz
Allocated DMA channel 7
Allocated DMA channel 1
Enabling DMA channels Tx:7 and Rx:1
DMA hardware register file is at ptr: 0x75af6000, using DMA TX channel: 7 and DMA RX channel: 1
DMA hardware TX channel register file is at ptr: 0x75af6700, DMA RX channel register file is at ptr: 0x75af6100
Resetting DMA channels for use
DMA all set up
Initializing display
Resetting display at reset GPIO pin 25
Creating SPI task thread
InitSPI done
DISPLAY_FLIP_ORIENTATION_IN_SOFTWARE: Swapping width/height to update display in portrait mode to minimize tearing.
Relevant source display area size with overscan cropped away: 240x320.
Source GPU display is 240x320. Output SPI display is 240x320 with a drawable area of 240x320. Applying scaling factor horiz=1.00x & vert=1.00x, xOffset: 0, yOffset: 0, scaledWidth: 240, scaledHeight: 320
Creating dispmanX resource of size 240x320 (aspect ratio=0.750000).
GPU grab rectangle is offset x=0,y=0, size w=240xh=320, aspect ratio=0.750000
All initialized, now running main loop...

How can the binary know that device was initialized/reset properly? How can I check if the display is connected properly and the communication is established?

juj commented 3 years ago

How can the binary know that device was initialized/reset properly?

Unfortunately it does not. Communication to the display is fully unidirectional, the driver only sends data, but never receives anything back. These types of SPI protocols do not have meaningful data lines established in them to have any kind of diagnostics of "is this thing initializing the display correctly". (some displays have a way to read some internal memory fields, but those are largely orthogonal/independent of the actual display pixel driving operation)

Try cross-referencing against the "official" driver or test program for the display, whatever that might be, to ensure that the communication is working out properly.