Reading TFT screen datasheet ILI9341

Thread Starter

camerart

Joined Feb 25, 2013
3,830
Hi,
A thread on ETO is trying to program TFT 240X320 ILI9341 screens. We've got some results, but I am unable to read the ILI9341 data sheet, with much understanding.
Has anyone figured out how to program these screens?
I use Oshonsoft BASIC, and at the moment 18F46K20 PICs.
Any suggestions, please?
C
 

geekoftheweek

Joined Oct 6, 2013
1,429
I had pretty good luck using the Adafruit library as a reference. https://github.com/adafruit/Adafruit_ILI9341 I won't lie it wasn't the easiest to get working, but I would have never made it work otherwise.

Edit -- after checking out the link in #2 this looks to be basically the same thing, but the link in #2 looks a bit easier to follow along.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,830
I had pretty good luck using the Adafruit library as a reference. https://github.com/adafruit/Adafruit_ILI9341 I won't lie it wasn't the easiest to get working, but I would have never made it work otherwise.

Edit -- after checking out the link in #2 this looks to be basically the same thing, but the link in #2 looks a bit easier to follow along.
Hi G,
I followed both links, but they lead to 'C' programming, which I can get the idea, but not the detail. I'm stuck in time as I can only (poorly) prgram in BASIC.

I have the D/S and have been able to change some settings, but not many of them and it takes a while to get to grips with D/S.
C
 
Last edited:

geekoftheweek

Joined Oct 6, 2013
1,429
Code:
static const uint8_t PROGMEM initcmd[] = {
  0xEF, 3, 0x03, 0x80, 0x02,
  0xCF, 3, 0x00, 0xC1, 0x30,
  0xED, 4, 0x64, 0x03, 0x12, 0x81,
  0xE8, 3, 0x85, 0x00, 0x78,
  0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02,
  0xF7, 1, 0x20,
  0xEA, 2, 0x00, 0x00,
  ILI9341_PWCTR1  , 1, 0x23,             // Power control VRH[5:0]
  ILI9341_PWCTR2  , 1, 0x10,             // Power control SAP[2:0];BT[3:0]
  ILI9341_VMCTR1  , 2, 0x3e, 0x28,       // VCM control
  ILI9341_VMCTR2  , 1, 0x86,             // VCM control2
  ILI9341_MADCTL  , 1, 0x48,             // Memory Access Control
  ILI9341_VSCRSADD, 1, 0x00,             // Vertical scroll zero
  ILI9341_PIXFMT  , 1, 0x55,
  ILI9341_FRMCTR1 , 2, 0x00, 0x18,
  ILI9341_DFUNCTR , 3, 0x08, 0x82, 0x27, // Display Function Control
  0xF2, 1, 0x00,                         // 3Gamma Function Disable
  ILI9341_GAMMASET , 1, 0x01,             // Gamma curve selected
  ILI9341_GMCTRP1 , 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, // Set Gamma
    0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00,
  ILI9341_GMCTRN1 , 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, // Set Gamma
    0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F,
  ILI9341_SLPOUT  , 0x80,                // Exit Sleep
  ILI9341_DISPON  , 0x80,                // Display on
  0x00                                   // End of list
};
This is the initial set up data. The first byte in the line is the command byte, the second is the number of remaining bytes in that command, and the final bytes of the line are the data associated with the command. There are a few commands at the beginning that aren't in the datasheet for whatever reason.
The exit sleep and display on don't quite follow the format, but they are single byte commands with a delay afterwards.

After that you would use the "Page Address Set" and "Column Address Set" commands to define the rectangle of pixels you wish to alter. Next you would use a "Memory Write" command to draw the pixels in the rectangle. This library uses the 16 bit format (5 red, 6 green, 5 blue) for each pixel.

It's been a while since I messed with it myself and this is a pretty general description based on some quick looking through what I did previously.

As always post some code if you run in to trouble and we'll see what we can do.
 
Top