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 S6D04D1.cpp Source File

S6D04D1.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 "S6D04D1.h"
00007 
00008 //////////////////////////////////////////////////////////////////////////////////
00009 // display settings ///////////////////////////////////////////////////////
00010 /////////////////////////////////////////////////////////////////////////
00011 
00012 // put in constructor
00013 //#define LCDSIZE_X       240 // display X pixels, TFTs are usually portrait view
00014 //#define LCDSIZE_Y       400  // display Y pixels
00015 
00016 
00017 
00018 S6D04D1::S6D04D1(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, 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 //    scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it, for ili9481 is set automatically in identify()
00027     set_orientation(0);
00028     FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. Give a try
00029     cls();
00030     locate(0,0); 
00031 }
00032 S6D04D1::S6D04D1(proto_t displayproto, PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned  int LCDSIZE_Y)
00033     : TFT(displayproto, buspins, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
00034 {
00035     hw_reset();
00036     BusEnable(true);
00037     identify(); // will collect tftID, set mipistd flag
00038     init();
00039     auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
00040 //    scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it, for ili9481 is set automatically in identify()
00041     set_orientation(0);
00042     FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. Give a try
00043     cls();
00044     locate(0,0); 
00045 }
00046 S6D04D1::S6D04D1(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 )
00047     : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name)
00048 {
00049     hw_reset(); //TFT class forwards to Protocol class
00050     BusEnable(true); //TFT class forwards to Protocol class
00051     identify(); // will collect tftID and set mipistd flag
00052     init(); // per display custom init cmd sequence, implemented here
00053     auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
00054  //   scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it, for ili9481 is set automatically in identify()
00055     set_orientation(0); //TFT class does for MIPI standard and some ILIxxx
00056     FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. Give a try
00057     cls();
00058     locate(0,0); 
00059 }
00060 // reset and init the lcd controller
00061 void S6D04D1::init()
00062 {
00063     /**********************************************
00064         TFT1P CODE Initialization of Truly 
00065        
00066      ************************************************        
00067          Panel:3.0 240400 
00068          Driver IC:S6D04D1X21-BAF8
00069      
00070      ************************************************/
00071 wr_cmd8(0xE0); 
00072 wr_data8(0x01); 
00073 
00074 wr_cmd8(0x11); 
00075 wait_ms(150); 
00076 
00077 wr_cmd8(0xF3); 
00078 wr_data8(0x01); 
00079 wr_data8(0x00); 
00080 wr_data8(0x00); 
00081 wr_data8(0x0C);//Do not set any higher VCI1 level than VCI -0.15V. 0C 0A 
00082 wr_data8(0x03);//VGH和VGL 01 02VGH=6VCI1,VGL=-4VCI1. 
00083 wr_data8(0x75); 
00084 wr_data8(0x75); 
00085 wr_data8(0x30); 
00086 
00087 wr_cmd8(0xF4); 
00088 wr_data8(0x4C); 
00089 wr_data8(0x4C); 
00090 wr_data8(0x44); 
00091 wr_data8(0x44); 
00092 wr_data8(0x22); 
00093 
00094 wr_cmd8(0xF5); 
00095 wr_data8(0x10); 
00096 wr_data8(0x22); 
00097 wr_data8(0x05); 
00098 wr_data8(0xF0); 
00099 wr_data8(0x70); 
00100 wr_data8(0x1F); 
00101 wait_ms(30); 
00102 
00103 wr_cmd8(0xF3); 
00104 wr_data8(0x03); 
00105 wait_ms(30); 
00106 wr_cmd8(0xF3); 
00107 wr_data8(0x07); 
00108 wait_ms(30); 
00109 wr_cmd8(0xF3); 
00110 wr_data8(0x0F); 
00111 wait_ms(30); 
00112 wr_cmd8(0xF3); 
00113 wr_data8(0x1F); 
00114 wait_ms(30); 
00115 wr_cmd8(0xF3); 
00116 wr_data8(0x7F); 
00117 wait_ms(30); 
00118 
00119 
00120 wr_cmd8(0xF7); 
00121 wr_data8(0x80); 
00122 wr_data8(0x00); 
00123 wr_data8(0x00); 
00124 wr_data8(0x05); 
00125 wr_data8(0x0D); 
00126 wr_data8(0x1F); 
00127 wr_data8(0x26); 
00128 wr_data8(0x2D); 
00129 wr_data8(0x14); 
00130 wr_data8(0x15); 
00131 wr_data8(0x26); 
00132 wr_data8(0x20); 
00133 wr_data8(0x01); 
00134 wr_data8(0x22); 
00135 wr_data8(0x22); 
00136 
00137 wr_cmd8(0xF8); 
00138 wr_data8(0x80); 
00139 wr_data8(0x00); 
00140 wr_data8(0x00); 
00141 wr_data8(0x00); 
00142 wr_data8(0x07); 
00143 wr_data8(0x1E); 
00144 wr_data8(0x2A); 
00145 wr_data8(0x32); 
00146 wr_data8(0x10); 
00147 wr_data8(0x16); 
00148 wr_data8(0x36); 
00149 wr_data8(0x3C); 
00150 wr_data8(0x3B); 
00151 wr_data8(0x22); 
00152 wr_data8(0x22); 
00153 
00154 wr_cmd8(0xF9); 
00155 wr_data8(0x80); 
00156 wr_data8(0x00); 
00157 wr_data8(0x00); 
00158 wr_data8(0x05); 
00159 wr_data8(0x0D); 
00160 wr_data8(0x1F); 
00161 wr_data8(0x26); 
00162 wr_data8(0x2D); 
00163 wr_data8(0x14); 
00164 wr_data8(0x15); 
00165 wr_data8(0x26); 
00166 wr_data8(0x20); 
00167 wr_data8(0x01); 
00168 wr_data8(0x22); 
00169 wr_data8(0x22); 
00170 
00171 
00172 wr_cmd8(0xFA); 
00173 wr_data8(0x80); 
00174 wr_data8(0x00); 
00175 wr_data8(0x00); 
00176 wr_data8(0x00); 
00177 wr_data8(0x07); 
00178 wr_data8(0x1E); 
00179 wr_data8(0x2A); 
00180 wr_data8(0x32); 
00181 wr_data8(0x10); 
00182 wr_data8(0x16); 
00183 wr_data8(0x36); 
00184 wr_data8(0x3C); 
00185 wr_data8(0x3B); 
00186 wr_data8(0x22); 
00187 wr_data8(0x22); 
00188 
00189 
00190 wr_cmd8(0xFB); 
00191 wr_data8(0x80); 
00192 wr_data8(0x00); 
00193 wr_data8(0x00); 
00194 wr_data8(0x05); 
00195 wr_data8(0x0D); 
00196 wr_data8(0x1F); 
00197 wr_data8(0x26); 
00198 wr_data8(0x2D); 
00199 wr_data8(0x14); 
00200 wr_data8(0x15); 
00201 wr_data8(0x26); 
00202 wr_data8(0x20); 
00203 wr_data8(0x01); 
00204 wr_data8(0x22); 
00205 wr_data8(0x22); 
00206 
00207 wr_cmd8(0xFC); 
00208 wr_data8(0x80); 
00209 wr_data8(0x00); 
00210 wr_data8(0x00); 
00211 wr_data8(0x00); 
00212 wr_data8(0x07); 
00213 wr_data8(0x1E); 
00214 wr_data8(0x2A); 
00215 wr_data8(0x32); 
00216 wr_data8(0x10); 
00217 wr_data8(0x16); 
00218 wr_data8(0x36); 
00219 wr_data8(0x3C); 
00220 wr_data8(0x3B); 
00221 wr_data8(0x22); 
00222 wr_data8(0x22); 
00223 
00224 //wr_cmd8(0x35); 
00225 wr_cmd8(0x34); // tearing effect line off
00226 
00227 wr_cmd8(0x36); 
00228 wr_data8(0x48);//08 
00229 
00230 wr_cmd8(0x3A); 
00231 wr_data8(0x05); 
00232 
00233 wr_cmd8(0xF2); 
00234 wr_data8(0x17); 
00235 wr_data8(0x17); 
00236 wr_data8(0x0F); 
00237 wr_data8(0x08); 
00238 wr_data8(0x08); 
00239 wr_data8(0x00); 
00240 wr_data8(0x00); 
00241 wr_data8(0x00); 
00242 wr_data8(0x00); 
00243 wr_data8(0x13); 
00244 wr_data8(0x00); 
00245 
00246 wr_cmd8(0xF6); 
00247 wr_data8(0x00); 
00248 wr_data8(0x08); 
00249 wr_data8(0x00); 
00250 wr_data8(0x00); 
00251 
00252 wr_cmd8(0xFD); 
00253 wr_data8(0x02); 
00254 wr_data8(0x01);//240*400 
00255  
00256 wait_ms(20); 
00257 wr_cmd8(0x29); // display on
00258 wait_ms(20); 
00259     
00260 }