Open Pin666 opened 8 years ago
I will take look in code, I don't have any ILI9340 around, now everyone sell only 9241 but the 2 chip are pretty similar.
Thanks so much for your support. I already checked the registers for 9340 and 9341 and they seem to be the same.
I was having the same problem as well using an Ebay version of the display. The fill screen and clear screen were not filling the entire screen. I final located the issue in the TFT_ILI93XX/_display/ILI9340_RED_PCB1.h file.
The code was
static const int16_t TFT_ILI93XX_TFTWIDTH = 240; static const int16_t TFT_ILI93XX_TFTHEIGHT = 320; static const uint32_t TFT_ILI93XX_CGRAM = TFT_ILI93XX_TFTWIDTH * TFT_ILI93XX_TFTHEIGHT;
which defined the size of the display and the total number of pixels in the display. The first two lines where correct for the display, but there was a type casting issue in the third line. The math should be 240 x 320 = 76800, but because the 240 and 330 are type int16_t the resulting math ends up with a value of 11264 because of the limit on the 16bit value. By correcting the type before the multiplication the problem is solved and the display works correctly. The following line change fixes the issue
static const uint32_t TFT_ILI93XX_CGRAM = uint32_t(TFT_ILI93XX_TFTWIDTH) * uint32_t(TFT_ILI93XX_TFTHEIGHT);
The correct line of code now sets the total pixel count to 76800 which allows the fill screen and clear screen code to fill the entire screen with the desired color.
I've been burred more than once by type casting issues. They can be a pain to locate!
Sumotoy, thanks for the fast code!
Unfortunately lib doesn't work with my ILI9340 Tft (Adafruit 2.2" TFT, https://www.adafruit.com/products/1480).
The following code produces the result in the attached picture.
Btw.: Orig. Adafruit lib works fine but too slow Regards![tft](https://cloud.githubusercontent.com/assets/20659753/17203336/28e6e228-549f-11e6-95ea-2411ce952741.JPG)