notro / fbtft

Linux Framebuffer drivers for small TFT LCD display modules. Development has moved to https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/fbtft?h=staging-testing
1.84k stars 495 forks source link

Waveshare 4inch TFT Touch Shield SPI #547

Closed gilphilbert closed 2 years ago

gilphilbert commented 4 years ago

This display is actually designed for the Arduino (pay more attention when purchasing...) but after some digging in the schematics, I discovered that, other than a 5V power supply, the logic is all 3.3v and since it's SPI I thought I'd give it a go.

It's based on the ili9486 controller and after much trial-and-error, I now have the display mostly working, using the following:

sudo modprobe fbtft_device speed=16000000 custom name=fb_ili9486 gpios=reset:23,dc:24,led:22 width=320 height=480 buswidth=8 regwidth=8

This initializes the display and I can move the console (con2fbmap 1 1) and see the content.

However, the colors are all wrong. I tried setting bgr=1 but that doesn't make the colors better, just different. Red comes out blue. Yellow comes out cyan.

Digging through the Arduino code (https://github.com/ImpulseAdventure/Waveshare_ILI9486/blob/master/src/LCD_Driver.cpp), it appears there's an initialization string that doesn't match the one in the ili9486 driver. I'm unsure of how to convert it though, can I literally take the sections and convert them? The initialization code seems very different, so I suspect only elements of it need changing but I'm no expert here and I'm hoping someone can help.

This is the initialization code I've mangled from the Arduino file (I would put this all on one line):

-1,0XF9,0x00,0x08,
-1,0xC0,0x19,0x1a,
-1,0xC1,0x45,0x00,
-1,0xC2,0x33,
-1,0XC5,0x00,0x28,
-1,0xB1,0xA0,0x11,
-1,0xB4,0x02,
-1,0xB6,0x00,0x42,0x3B,
-1,0xB7,0x07,
-1,0xE0,0x1F,0x25,0x22,0x0B,0x06,0x0A,0x4E,0xC6,0x39,0x00,0x00,0x00,0x00,0x00,0x00,
-1,0XE1,0x1F,0x3F,0x3F,0x0F,0x1F,0x0F,0x46,0x49,0x31,0x05,0x09,0x03,0x1C,0x1A,0x00,
-1,0XF1,0x36,0x04,0x00,0x3C,0x0F,0x0F,0xA4,0x02,
-1,0XF2,0x18,0xA3,0x12,0x02,0x32,0x12,0xFF,0x32,0x00,
-1,0XF4,0x40,0x00,0x08,0x91,0x04,
-1,0XF8,0x21,0x04,
-1,0X3A,0x55,
-1,0xB6,0X00,0x22,
-1,0x36,0x08,
-2,200,
-1,0x11,
-2,120,
-1,0x29,
-3

Edit: Tried that and it didn't work, which doesn't surprise me.

notro commented 4 years ago

You can use the init sequence from the driver and try the gamma values from the Arduino code: https://elixir.bootlin.com/linux/latest/source/drivers/staging/fbtft/fb_ili9486.c#L20

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.