Juan Loreto / Mbed 2 deprecated Nucleo-F411RE-LGDP4535_TFT_Demo

Dependencies:   mbed

Committer:
jloreto
Date:
Sun Aug 23 15:50:19 2015 +0000
Revision:
0:e67bf8f398ee
This program is to test MCU Friend shield based on LGDP4535 in Nucleo-F411RE board.; Libraries modified from Unigraphic Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jloreto 0:e67bf8f398ee 1 /* mbed library - custom TFT driver class, LGDP4535 specific
jloreto 0:e67bf8f398ee 2 * Based on Unigraphic library from Giuliano Dianda modified by Juan Loreto
jloreto 0:e67bf8f398ee 3 * Released under the MIT License: http://mbed.org/license/mit
jloreto 0:e67bf8f398ee 4 */
jloreto 0:e67bf8f398ee 5
jloreto 0:e67bf8f398ee 6 #include "Protocols.h"
jloreto 0:e67bf8f398ee 7 #include "LGDP4535.h"
jloreto 0:e67bf8f398ee 8
jloreto 0:e67bf8f398ee 9 //////////////////////////////////////////////////////////////////////////////////
jloreto 0:e67bf8f398ee 10 // display settings ///////////////////////////////////////////////////////
jloreto 0:e67bf8f398ee 11 /////////////////////////////////////////////////////////////////////////
jloreto 0:e67bf8f398ee 12
jloreto 0:e67bf8f398ee 13
jloreto 0:e67bf8f398ee 14 LGDP4535::LGDP4535(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)
jloreto 0:e67bf8f398ee 15 : TFT4535(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
jloreto 0:e67bf8f398ee 16 {
jloreto 0:e67bf8f398ee 17 hw_reset();
jloreto 0:e67bf8f398ee 18 BusEnable(true); //set CS low, will stay low untill manually set high with BusEnable(false);
jloreto 0:e67bf8f398ee 19 identify(); // will collect tftID
jloreto 0:e67bf8f398ee 20 init4535();
jloreto 0:e67bf8f398ee 21 auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
jloreto 0:e67bf8f398ee 22 set_orientation(0);
jloreto 0:e67bf8f398ee 23 FastWindow(true); // most but not all controllers support this, even if datasheet tells they should.
jloreto 0:e67bf8f398ee 24 cls();
jloreto 0:e67bf8f398ee 25 locate(0,0);
jloreto 0:e67bf8f398ee 26 }
jloreto 0:e67bf8f398ee 27 LGDP4535::LGDP4535(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)
jloreto 0:e67bf8f398ee 28 : TFT4535(displayproto, buspins, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
jloreto 0:e67bf8f398ee 29 {
jloreto 0:e67bf8f398ee 30 hw_reset();
jloreto 0:e67bf8f398ee 31 BusEnable(true); //set CS low, will stay low untill manually set high with BusEnable(false);
jloreto 0:e67bf8f398ee 32 identify(); // will collect tftID
jloreto 0:e67bf8f398ee 33 init4535();
jloreto 0:e67bf8f398ee 34 auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
jloreto 0:e67bf8f398ee 35 set_orientation(0);
jloreto 0:e67bf8f398ee 36 FastWindow(true); // most but not all controllers support this, even if datasheet tells they should.
jloreto 0:e67bf8f398ee 37 cls();
jloreto 0:e67bf8f398ee 38 locate(0,0);
jloreto 0:e67bf8f398ee 39 }
jloreto 0:e67bf8f398ee 40 LGDP4535::LGDP4535(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, const char *name, unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y)
jloreto 0:e67bf8f398ee 41 : TFT4535(displayproto, Hz, mosi, miso, sclk, CS, reset, LCDSIZE_X, LCDSIZE_Y, name)
jloreto 0:e67bf8f398ee 42 {
jloreto 0:e67bf8f398ee 43 hw_reset(); //TFT class forwards to Protocol class
jloreto 0:e67bf8f398ee 44 BusEnable(true); //set CS low, TFT932x class will toggle CS every transfer
jloreto 0:e67bf8f398ee 45 identify(); // will collect tftID
jloreto 0:e67bf8f398ee 46 init4535();
jloreto 0:e67bf8f398ee 47 auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
jloreto 0:e67bf8f398ee 48 set_orientation(0);
jloreto 0:e67bf8f398ee 49 FastWindow(true); // most but not all controllers support this, even if datasheet tells they should.
jloreto 0:e67bf8f398ee 50 cls();
jloreto 0:e67bf8f398ee 51 locate(0,0);
jloreto 0:e67bf8f398ee 52 }
jloreto 0:e67bf8f398ee 53 // reset and init the lcd controller
jloreto 0:e67bf8f398ee 54
jloreto 0:e67bf8f398ee 55 void LGDP4535::init4535()
jloreto 0:e67bf8f398ee 56 {
jloreto 0:e67bf8f398ee 57
jloreto 0:e67bf8f398ee 58 reg_write(0x0015,0x0030);
jloreto 0:e67bf8f398ee 59 reg_write(0x009A,0x0010);
jloreto 0:e67bf8f398ee 60 reg_write(0x0011,0x0020);
jloreto 0:e67bf8f398ee 61 reg_write(0x0010,0x3428);
jloreto 0:e67bf8f398ee 62 reg_write(0x0012,0x0002);
jloreto 0:e67bf8f398ee 63 reg_write(0x0013,0x1038);
jloreto 0:e67bf8f398ee 64 wait_ms(40);
jloreto 0:e67bf8f398ee 65 reg_write(0x0012,0x0012);
jloreto 0:e67bf8f398ee 66 wait_ms(40);
jloreto 0:e67bf8f398ee 67 reg_write(0x0010,0x3420);
jloreto 0:e67bf8f398ee 68 reg_write(0x0013,0x3045);
jloreto 0:e67bf8f398ee 69 wait_ms(70);
jloreto 0:e67bf8f398ee 70 reg_write(0x0030,0x0000);
jloreto 0:e67bf8f398ee 71 reg_write(0x0031,0x0402);
jloreto 0:e67bf8f398ee 72 reg_write(0x0032,0x0307);
jloreto 0:e67bf8f398ee 73 reg_write(0x0033,0x0304);
jloreto 0:e67bf8f398ee 74 reg_write(0x0034,0x0004);
jloreto 0:e67bf8f398ee 75 reg_write(0x0035,0x0401);
jloreto 0:e67bf8f398ee 76 reg_write(0x0036,0x0707);
jloreto 0:e67bf8f398ee 77 reg_write(0x0037,0x0305);
jloreto 0:e67bf8f398ee 78 reg_write(0x0038,0x0610);
jloreto 0:e67bf8f398ee 79 reg_write(0x0039,0x0610);
jloreto 0:e67bf8f398ee 80 reg_write(0x0001,0x0100);
jloreto 0:e67bf8f398ee 81 reg_write(0x0002,0x0300);
jloreto 0:e67bf8f398ee 82 reg_write(0x0003,0x1030);
jloreto 0:e67bf8f398ee 83 reg_write(0x0008,0x0808);
jloreto 0:e67bf8f398ee 84 reg_write(0x000A,0x0008);
jloreto 0:e67bf8f398ee 85 reg_write(0x0060,0x2700);
jloreto 0:e67bf8f398ee 86 reg_write(0x0061,0x0001);
jloreto 0:e67bf8f398ee 87 reg_write(0x0090,0x013E);
jloreto 0:e67bf8f398ee 88 reg_write(0x0092,0x0100);
jloreto 0:e67bf8f398ee 89 reg_write(0x0093,0x0100);
jloreto 0:e67bf8f398ee 90 reg_write(0x00A0,0x3000);
jloreto 0:e67bf8f398ee 91 reg_write(0x00A3,0x0010);
jloreto 0:e67bf8f398ee 92 reg_write(0x0007,0x0001);
jloreto 0:e67bf8f398ee 93 reg_write(0x0007,0x0021);
jloreto 0:e67bf8f398ee 94 reg_write(0x0007,0x0023);
jloreto 0:e67bf8f398ee 95 reg_write(0x0007,0x0033);
jloreto 0:e67bf8f398ee 96 reg_write(0x0007,0x0133);
jloreto 0:e67bf8f398ee 97
jloreto 0:e67bf8f398ee 98 }