3.5 inch tft display distorts BMP images in Landscape view

I’m using a HiLetgo 320x480 3.5" TFT LCD from amazon (https://www.amazon.com/dp/B073R7Q8FF/ref=cm_sw_em_r_mt_dp_U_vsskEb4CCFHMZ) with an ILI9486 on an arduino mega 2560.
I’ve modified mcufriend and sdfat files for software spi (USES_16BIT_BUS).

AdafruitGFX - V.1.7.5
MCUFRIEND_kbv - V.2.9.8
SdFat - V1.1.0

I’ve loaded and had success with MCUFRIEND examples however when running showBMP_not_Uno.ino my images are distorted when drawing the full 320x480 image.
If I rotate the image using setRotation() part of my picture is drawn perfectly but is obviously cut off.
Am I missing a step in the setup routine for the ILI9486?

Also using kbv’s bitmaps on git only seem to load if I set PALETTEDEPTH to 8. setting it to 256 seems to stall the program and loads only 2 images before crashing.

Any help is appreciated - please excuse my ignorance if this has already been posted I’m fairly new to arduino programming.

Pictures.zip (254 KB)

Your Shield has a fully functional SD card on 50-53. i.e. hardware SPI with SD_CS on 53
There is no need to use SdFatSoftSpi() class.

You can use the regular showBMP_kbv_Uno example if you edit line #19 e.g.

#define SD_CS     53  //10

Since you have a Mega2560 you have plenty of SRAM. So you can use PALETTEDEPTH 8 if you want to display every Palette BMP. (8 means 256 colour Palette)

I provide some example BMPs. e.g. 16777216-colour, 65536-colour, 2-colour Palette, 16-colour Palette, 256-colour Palette.
Your BMP displays fine. Do my example BMPs work ?

If showBMP_kbv_Uno.ino displays “wrong” please tell me.

Most BMP files are 24-bit (16777216-colour). Few people use the other formats.


Edit. Just tried the not_Uno example with bit-bang. It worked slowly but ok.

SdFatSoftSpi<50, 51, 52> SD; //Bit-Bang on the hardware pins
#define SD_CS 53

Wow that sketch works much better, thank you!

After disabling SW SPI and setting PALETTEDEPTH 8 I can see my BMPs in landscape mode with no distortion.

I ran your BMPs and the color seems off (except for the 2 betty’s), almost like looking at the negatives of a photo. And on your test.bmp I notice the green square appears more yellow. Here is the output serial.

09:57:34.142 → Show BMP files on TFT with ID:0xD3D3
09:57:35.032 → /betty_1.bmp - 1122ms
09:57:41.218 → /betty_4.bmp - 1189ms
09:57:47.487 → /marily~1.bmp - 1722ms
09:57:54.252 → /miniwoof.bmp - 959ms
09:58:00.269 → /test.bmp - 3008ms
09:58:08.333 → /tiger.bmp - 2850ms
09:58:16.274 → /tiger_~1.bmp - 679ms
09:58:21.975 → /tiger_~2.bmp - 1883ms
09:58:28.951 → /tiger_~3.bmp - 2373ms
09:58:36.355 → /tiger16t.bmp - 2375ms
09:58:43.790 → /woof.bmp - 3002ms

Also I may be doing this wrong but I’m running LCD_ID_readreg.ino and am seeing odd data - does this sketch support my mega shield, do I need to modify the pin values in the sketch?

10:14:18.615 → reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, …
10:14:18.683 → reg(0x0004) 04 04 04 04 Manufacturer ID
10:14:18.716 → reg(0x0009) 09 09 09 09 09 Status Register
10:14:18.784 → reg(0x000A) 0A 0A Get Power Mode
10:14:18.817 → reg(0x000C) 0C 0C Get Pixel Format
10:14:18.851 → reg(0x0061) 61 61 RDID1 HX8347-G
10:14:18.885 → reg(0x0062) 62 62 RDID2 HX8347-G
10:14:18.920 → reg(0x0063) 63 63 RDID3 HX8347-G
10:14:18.953 → reg(0x0064) 64 64 RDID1 HX8347-A
10:14:18.987 → reg(0x0065) 65 65 RDID2 HX8347-A
10:14:19.022 → reg(0x0066) 66 66 RDID3 HX8347-A
10:14:19.058 → reg(0x0067) 67 67 RDID Himax HX8347-A
10:14:19.092 → reg(0x0070) 70 70 Panel Himax HX8347-A
10:14:19.127 → reg(0x00A1) A1 A1 A1 A1 A1 RD_DDB SSD1963
10:14:19.195 → reg(0x00B0) B0 B0 RGB Interface Signal Control
10:14:19.229 → reg(0x00B4) B4 B4 Inversion Control
10:14:19.262 → reg(0x00B6) B6 B6 B6 B6 B6 Display Control
10:14:19.329 → reg(0x00B7) B7 B7 Entry Mode Set
10:14:19.372 → reg(0x00BF) BF BF BF BF BF BF ILI9481, HX8357-B
10:14:19.407 → reg(0x00C0) C0 C0 C0 C0 C0 C0 C0 C0 C0 Panel Control
10:14:19.477 → reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 GAMMA
10:14:19.511 → reg(0x00CC) CC CC Panel Control
10:14:19.546 → reg(0x00D0) D0 D0 D0 Power Control
10:14:19.580 → reg(0x00D2) D2 D2 D2 D2 D2 NVM Read
10:14:19.648 → reg(0x00D3) D3 D3 D3 D3 ILI9341, ILI9488
10:14:19.682 → reg(0x00D4) D4 D4 D4 D4 Novatek ID
10:14:19.721 → reg(0x00DA) DA DA RDID1
10:14:19.755 → reg(0x00DB) DB DB RDID2
10:14:19.755 → reg(0x00DC) DC DC RDID3
10:14:19.789 → reg(0x00E0) E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 GAMMA-P
10:14:19.883 → reg(0x00E1) E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 GAMMA-N
10:14:19.930 → reg(0x00EF) EF EF EF EF EF EF ILI9327
10:14:19.963 → reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 Adjust Control 2
10:14:20.053 → reg(0x00F6) F6 F6 F6 F6 Interface Control


  1. run graphictest_kbv.ino Observe the colours in the Penguin screens. Report if wrong.

  2. your Shield is write-only. It is not possible to read ID or GRAM.

  3. most of my examples force the ID to 0x9481 if readID() returns 0xD3D3.

  4. you must force tft.begin(0x9486); instead.

  5. the correct ID is important. 0x9486 is different to 0x9481.

When you have run all the examples you will find any colour or direction problems. Please tell me.
Your TFT controller might be something other than Ilitek ILI9486.


Okay I ran graphics test with ID 0x9486 and everything looks good.
I forced the ID in showBMP_kbv_Uno and that also fixed the color! Everything is looks great and running smoothly.
I appreciate your help David!

The whole point of MCUFRIEND_kbv was to support the readable UNO shields that appear on Ebay with different controllers.

Your write-only Mega shield can not identify the controller. (you should never believe Ebay adverts)
I can test a few registers and make a guess. That is all.