Display

Dependents:   Termocamera_ironblack

Committer:
Geremia
Date:
Tue Mar 31 21:14:48 2015 +0000
Revision:
21:ae0a4eedfc90
Parent:
20:14daa48ffd4c
Child:
30:87855d03d91a
Add BUS_8 and BUS_16 (slow as expected)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Geremia 20:14daa48ffd4c 1 /* mbed UniGraphic library - Device specific class
Geremia 20:14daa48ffd4c 2 * Copyright (c) 2015 Giuliano Dianda
Geremia 20:14daa48ffd4c 3 * Released under the MIT License: http://mbed.org/license/mit
Geremia 20:14daa48ffd4c 4 */
Geremia 20:14daa48ffd4c 5
Geremia 20:14daa48ffd4c 6 #include "Protocols.h"
Geremia 20:14daa48ffd4c 7 #include "ILI932x.h"
Geremia 20:14daa48ffd4c 8
Geremia 20:14daa48ffd4c 9 //////////////////////////////////////////////////////////////////////////////////
Geremia 20:14daa48ffd4c 10 // display settings ///////////////////////////////////////////////////////
Geremia 20:14daa48ffd4c 11 /////////////////////////////////////////////////////////////////////////
Geremia 20:14daa48ffd4c 12
Geremia 20:14daa48ffd4c 13
Geremia 20:14daa48ffd4c 14 ILI932x::ILI932x(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)
Geremia 20:14daa48ffd4c 15 : TFT932x(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
Geremia 20:14daa48ffd4c 16 {
Geremia 20:14daa48ffd4c 17 hw_reset();
Geremia 20:14daa48ffd4c 18 BusEnable(true); //set CS low, will stay low untill manually set high with BusEnable(false);
Geremia 20:14daa48ffd4c 19 identify(); // will collect tftID
Geremia 20:14daa48ffd4c 20 if(tftID==0x9325) init9325();
Geremia 20:14daa48ffd4c 21 auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
Geremia 20:14daa48ffd4c 22 set_orientation(0);
Geremia 20:14daa48ffd4c 23 FastWindow(true); // most but not all controllers support this, even if datasheet tells they should.
Geremia 20:14daa48ffd4c 24 cls();
Geremia 20:14daa48ffd4c 25 locate(0,0);
Geremia 20:14daa48ffd4c 26 }
Geremia 21:ae0a4eedfc90 27 ILI932x::ILI932x(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)
Geremia 21:ae0a4eedfc90 28 : TFT932x(displayproto, buspins, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name)
Geremia 21:ae0a4eedfc90 29 {
Geremia 21:ae0a4eedfc90 30 hw_reset();
Geremia 21:ae0a4eedfc90 31 BusEnable(true); //set CS low, will stay low untill manually set high with BusEnable(false);
Geremia 21:ae0a4eedfc90 32 identify(); // will collect tftID
Geremia 21:ae0a4eedfc90 33 if(tftID==0x9325) init9325();
Geremia 21:ae0a4eedfc90 34 auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
Geremia 21:ae0a4eedfc90 35 set_orientation(0);
Geremia 21:ae0a4eedfc90 36 FastWindow(true); // most but not all controllers support this, even if datasheet tells they should.
Geremia 21:ae0a4eedfc90 37 cls();
Geremia 21:ae0a4eedfc90 38 locate(0,0);
Geremia 21:ae0a4eedfc90 39 }
Geremia 20:14daa48ffd4c 40 ILI932x::ILI932x(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)
Geremia 20:14daa48ffd4c 41 : TFT932x(displayproto, Hz, mosi, miso, sclk, CS, reset, LCDSIZE_X, LCDSIZE_Y, name)
Geremia 20:14daa48ffd4c 42 {
Geremia 20:14daa48ffd4c 43 hw_reset(); //TFT class forwards to Protocol class
Geremia 20:14daa48ffd4c 44 BusEnable(true); //set CS low, TFT932x class will toggle CS every transfer
Geremia 20:14daa48ffd4c 45 identify(); // will collect tftID
Geremia 20:14daa48ffd4c 46 if(tftID==0x9325) init9325();
Geremia 20:14daa48ffd4c 47 auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly
Geremia 20:14daa48ffd4c 48 set_orientation(0);
Geremia 20:14daa48ffd4c 49 FastWindow(true); // most but not all controllers support this, even if datasheet tells they should.
Geremia 20:14daa48ffd4c 50 cls();
Geremia 20:14daa48ffd4c 51 locate(0,0);
Geremia 20:14daa48ffd4c 52 }
Geremia 20:14daa48ffd4c 53 // reset and init the lcd controller
Geremia 20:14daa48ffd4c 54
Geremia 20:14daa48ffd4c 55 void ILI932x::init9325()
Geremia 20:14daa48ffd4c 56 {
Geremia 20:14daa48ffd4c 57 /* Example for ILI9325 ----------------------------------------------------*/
Geremia 20:14daa48ffd4c 58
Geremia 20:14daa48ffd4c 59 reg_write(0x0001,0x0100);
Geremia 20:14daa48ffd4c 60 reg_write(0x0002,0x0700);
Geremia 20:14daa48ffd4c 61 reg_write(0x0003,0x1030);
Geremia 20:14daa48ffd4c 62 reg_write(0x0004,0x0000);
Geremia 20:14daa48ffd4c 63 reg_write(0x0008,0x0207);
Geremia 20:14daa48ffd4c 64 reg_write(0x0009,0x0000);
Geremia 20:14daa48ffd4c 65 reg_write(0x000A,0x0000);
Geremia 20:14daa48ffd4c 66 reg_write(0x000C,0x0000);
Geremia 20:14daa48ffd4c 67 reg_write(0x000D,0x0000);
Geremia 20:14daa48ffd4c 68 reg_write(0x000F,0x0000);
Geremia 20:14daa48ffd4c 69 //power on sequence VGHVGL
Geremia 20:14daa48ffd4c 70 reg_write(0x0010,0x0000);
Geremia 20:14daa48ffd4c 71 reg_write(0x0011,0x0007);
Geremia 20:14daa48ffd4c 72 reg_write(0x0012,0x0000);
Geremia 20:14daa48ffd4c 73 reg_write(0x0013,0x0000);
Geremia 20:14daa48ffd4c 74 reg_write(0x0007,0x0001);
Geremia 20:14daa48ffd4c 75 wait_ms(200);
Geremia 20:14daa48ffd4c 76 //vgh
Geremia 20:14daa48ffd4c 77 reg_write(0x0010,0x1290);
Geremia 20:14daa48ffd4c 78 reg_write(0x0011,0x0227);
Geremia 20:14daa48ffd4c 79 wait_ms(50);
Geremia 20:14daa48ffd4c 80 //vregiout
Geremia 20:14daa48ffd4c 81 reg_write(0x0012,0x001d); //0x001b
Geremia 20:14daa48ffd4c 82 wait_ms(50);
Geremia 20:14daa48ffd4c 83 //vom amplitude
Geremia 20:14daa48ffd4c 84 reg_write(0x0013,0x1500);
Geremia 20:14daa48ffd4c 85 wait_ms(50);
Geremia 20:14daa48ffd4c 86 //vom H
Geremia 20:14daa48ffd4c 87 reg_write(0x0029,0x0018);
Geremia 20:14daa48ffd4c 88 reg_write(0x002B,0x000D);
Geremia 20:14daa48ffd4c 89 wait_ms(50);
Geremia 20:14daa48ffd4c 90 //gamma
Geremia 20:14daa48ffd4c 91 reg_write(0x0030,0x0004);
Geremia 20:14daa48ffd4c 92 reg_write(0x0031,0x0307);
Geremia 20:14daa48ffd4c 93 reg_write(0x0032,0x0002);// 0006
Geremia 20:14daa48ffd4c 94 reg_write(0x0035,0x0206);
Geremia 20:14daa48ffd4c 95 reg_write(0x0036,0x0408);
Geremia 20:14daa48ffd4c 96 reg_write(0x0037,0x0507);
Geremia 20:14daa48ffd4c 97 reg_write(0x0038,0x0204);//0200
Geremia 20:14daa48ffd4c 98 reg_write(0x0039,0x0707);
Geremia 20:14daa48ffd4c 99 reg_write(0x003C,0x0405);// 0504
Geremia 20:14daa48ffd4c 100 reg_write(0x003D,0x0F02);
Geremia 20:14daa48ffd4c 101 //ram
Geremia 20:14daa48ffd4c 102 reg_write(0x0050,0x0000);
Geremia 20:14daa48ffd4c 103 reg_write(0x0051,0x00EF);
Geremia 20:14daa48ffd4c 104 reg_write(0x0052,0x0000);
Geremia 20:14daa48ffd4c 105 reg_write(0x0053,0x013F);
Geremia 20:14daa48ffd4c 106 reg_write(0x0060,0xA700);
Geremia 20:14daa48ffd4c 107 reg_write(0x0061,0x0001);
Geremia 20:14daa48ffd4c 108 reg_write(0x006A,0x0000);
Geremia 20:14daa48ffd4c 109 //
Geremia 20:14daa48ffd4c 110 reg_write(0x0080,0x0000);
Geremia 20:14daa48ffd4c 111 reg_write(0x0081,0x0000);
Geremia 20:14daa48ffd4c 112 reg_write(0x0082,0x0000);
Geremia 20:14daa48ffd4c 113 reg_write(0x0083,0x0000);
Geremia 20:14daa48ffd4c 114 reg_write(0x0084,0x0000);
Geremia 20:14daa48ffd4c 115 reg_write(0x0085,0x0000);
Geremia 20:14daa48ffd4c 116 //
Geremia 20:14daa48ffd4c 117 reg_write(0x0090,0x0010);
Geremia 20:14daa48ffd4c 118 reg_write(0x0092,0x0600);
Geremia 20:14daa48ffd4c 119 reg_write(0x0093,0x0003);
Geremia 20:14daa48ffd4c 120 reg_write(0x0095,0x0110);
Geremia 20:14daa48ffd4c 121 reg_write(0x0097,0x0000);
Geremia 20:14daa48ffd4c 122 reg_write(0x0098,0x0000);
Geremia 20:14daa48ffd4c 123
Geremia 20:14daa48ffd4c 124 reg_write(0x0007,0x0133); // display on
Geremia 20:14daa48ffd4c 125
Geremia 20:14daa48ffd4c 126 }