Pages

Wednesday, November 28, 2018

A simple arduino tft library for R61503 based touchscreen

Recently i got hold of a TFT  lcd module which is listed as "2.0" 3.3V TFT LCD Display Touch Screen With Touch Pen Breakout Board For Arduino" in ebay and  Aliexpress. They are very inexpensive for hobby projects. They use an 8 bit parallel interface to communicate and needs 13+ gpio pins for proper operation. Pretty good for small and shiny user interfaces as they also have a resistive touch sensor.

TFT touchscreen with R61503 controller
The trouble with ebay purchases are often they list totally wrong information about the controllers. This one i bought was advertised as using ST7775 driver,Resolution: 176x220, 16-bit (262,000) color,Operating voltage: 3.3V (REMEBER TO USE A 3.3Volt micro/level shifter)



When i got it i realized that the controller is not the one listed and no libraries are available or at least i couldn't get this working.  All i got is WHITE SCREEN.  I tried using Adafruit libraries ( available here) which use to work with most of these modules and the excellent library from David (MCUFRIEND). All gave white screen.


The good thing is the above libraries and the touch screen information sketch (Here) reported that the module is having identifier 0x1503 and then a closer look at the shield also showed R61503 indicating the controller is different here. 

Closer look at the pin details and driver information


So hunted for the datasheet and after setting up the correct initialization,  gave a nice working TFT



Arduino Library for R61503 

Arduino library can be downloaded from the github link here.  Click on download as zip file and unzip and copy the folder to arduino/libraries folder and restart the ide. Choose the examples to test it.

Initialisation code for R61503  



static const uint16_t R61503_RIYAS[] PROGMEM = { //from DEM 240320C TMH-PW-N
            0x00, 0x0000,
            0x00, 0x0000,
            TFTLCD_DELAY, 100,
            0x00, 0x0000,
            0x00, 0x0000,
            0x00, 0x0000,
            0x00, 0x0000,
            0xA4, 0x0001,
            TFTLCD_DELAY, 100,
            /* Power On Sequanece */
   0x07,0x0001,
   0x18,0x0001,
   0x10,0x11b0,
   0x11,0x0110,
   0x12,0x0036,
   0x13,0x8c18,
   0x12,0x0036,
   0x14,0x8000,
   0x01,0x0100,
   0x02,0x0700,
   0x03,0x1030,

   0x04,0x0000,
   0x08,0x0808,
   0x09,0x0000,
   0x20,0x0000,
   0x21,0x0000,
   /* Gamma */
     
   0x30,0x0400,
   0x31,0x0506,
   0x32,0x0003,
   0x33,0x0202,
   0x34,0x0104,
   0x35,0x0004,
   0x36,0x0707,
   0x37,0x0303,
   0x38,0x0005,
   0x39,0x0500,
   0x3A,0x0E00,
   /* Other */  
   0x70,0x1b00,
   TFTLCD_DELAY, 30,
   0x71,0x0001,
   TFTLCD_DELAY, 30,
     
   0x7a,0x0000,
   TFTLCD_DELAY, 30, 
   0x85,0x0000,
   0x90,0x0008,
   0x91,0x0100,
   0x92,0x0001,
   /* Display On Sequance */  
   0x07,0x0001,
   0x07,0x0021,
   0x12,0x1138,
   0x07,0x0233,
        };



1 comment: