This is the final version of Mini Gateway for Automation and Security desgined for Renesas GR Peach Design Contest

Dependencies:   GR-PEACH_video GraphicsFramework HTTPServer R_BSP mbed-rpc mbed-rtos Socket lwip-eth lwip-sys lwip FATFileSystem

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ILI9486.cpp Source File

ILI9486.cpp

00001  /* mbed UniGraphic library - Device specific class
00002  * Copyright (c) 2015 Giuliano Dianda
00003  * Released under the MIT License: http://mbed.org/license/mit
00004  */
00005 #include "Protocols.h "
00006 #include "ILI9486.h"
00007 
00008 //////////////////////////////////////////////////////////////////////////////////
00009 // display settings ///////////////////////////////////////////////////////
00010 /////////////////////////////////////////////////////////////////////////
00011 
00012 // put in constructor
00013 //#define LCDSIZE_X       320 // display X pixels, TFTs are usually portrait view
00014 //#define LCDSIZE_Y       480  // display Y pixels
00015 
00016 
00017 
00018 ILI9486::ILI9486(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
00019     : TFT(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
00020 {
00021     hw_reset();
00022     BusEnable(true);
00023     identify(); // will collect tftID and set mipistd flag
00024     init();
00025     auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
00026     set_orientation(0);
00027  //   FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. ILI9486 does not, at least in par mode
00028     cls();
00029     locate(0,0); 
00030 }
00031 ILI9486::ILI9486(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name, unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
00032     : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name)
00033 {
00034     hw_reset(); //TFT class forwards to Protocol class
00035     BusEnable(true); //TFT class forwards to Protocol class
00036     identify(); // will collect tftID and set mipistd flag
00037     init(); // per display custom init cmd sequence, implemented here
00038     //auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
00039     set_orientation(0); //TFT class does for MIPI standard and some ILIxxx
00040  //   FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. ILI9486 does not, at least in par mode
00041     cls();
00042     locate(0,0); 
00043 }
00044 // reset and init the lcd controller
00045 void ILI9486::init()
00046 {
00047     /* Start Initial Sequence ----------------------------------------------------*/
00048     
00049     
00050     wr_cmd8(0x11);                     // sleep out
00051     wait_ms(150);
00052     
00053     
00054     wr_cmd8(0xF1);
00055     wr_data16(0x36);
00056     wr_data16(0x04);
00057     wr_data16(0x00);
00058     wr_data16(0x3C);
00059     wr_data16(0x0F);
00060     wr_data16(0x8F);
00061 
00062 
00063     wr_cmd8(0xF2);
00064     wr_data16(0x18);
00065     wr_data16(0xA3);
00066     wr_data16(0x12);
00067     wr_data16(0x02);
00068     wr_data16(0xb2);
00069     wr_data16(0x12);
00070     wr_data16(0xFF);
00071     wr_data16(0x10);
00072     wr_data16(0x00);
00073 
00074     wr_cmd8(0xF8);
00075     wr_data16(0x21);
00076     wr_data16(0x04);
00077 
00078     wr_cmd8(0xF9);
00079     wr_data16(0x00);
00080     wr_data16(0x08);  
00081 
00082     wr_cmd8(0xC0);
00083     wr_data16(0x0f); //13
00084     wr_data16(0x0f); //10
00085 
00086     wr_cmd8(0xC1);
00087     wr_data16(0x42); //43
00088 
00089     wr_cmd8(0xC2);
00090     wr_data16(0x22);
00091 
00092     wr_cmd8(0xC5);
00093     wr_data16(0x01); //00
00094     wr_data16(0x29); //4D
00095     wr_data16(0x80);
00096 
00097     wr_cmd8(0xB6);
00098     wr_data16(0x00);
00099     wr_data16(0x22); //42
00100     wr_data16(0x3b);
00101 
00102     wr_cmd8(0xB1);
00103     wr_data16(0xD0); //C0
00104     wr_data16(0x11);
00105 
00106     wr_cmd8(0xB4);
00107     wr_data16(0x02); //01
00108 
00109     wr_cmd8(0xE0);
00110     wr_data16(0x0F);
00111     wr_data16(0x18);
00112     wr_data16(0x15);
00113     wr_data16(0x09);
00114     wr_data16(0x0B);
00115     wr_data16(0x04);
00116     wr_data16(0x49);
00117     wr_data16(0x64);
00118     wr_data16(0x3D);
00119     wr_data16(0x08);
00120     wr_data16(0x15);
00121     wr_data16(0x06);
00122     wr_data16(0x12);
00123     wr_data16(0x07);
00124     wr_data16(0x00);
00125 
00126     wr_cmd8(0xE1);
00127     wr_data16(0x0F);
00128     wr_data16(0x38);
00129     wr_data16(0x35);
00130     wr_data16(0x0a);
00131     wr_data16(0x0c);
00132     wr_data16(0x03);
00133     wr_data16(0x4A);
00134     wr_data16(0x42);
00135     wr_data16(0x36);
00136     wr_data16(0x04);
00137     wr_data16(0x0F);
00138     wr_data16(0x03);
00139     wr_data16(0x1F);
00140     wr_data16(0x1B);
00141     wr_data16(0x00);
00142 
00143     wr_cmd8(0x20);                     // display inversion OFF
00144   
00145     wr_cmd8(0x36);      // MEMORY_ACCESS_CONTROL (orientation stuff)
00146     wr_data16(0x0A);
00147      
00148     wr_cmd8(0x3A);      // COLMOD_PIXEL_FORMAT_SET
00149     wr_data16(0x55);     // 16 bit pixel 
00150 
00151     wr_cmd8(0x13); // Nomal Displaymode
00152     
00153     
00154     
00155     
00156     
00157      
00158     wr_cmd8(0x29);                     // display on
00159     
00160    
00161     wait_ms(150);
00162 }