Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.
Inits/ILI9486.cpp@34:67b3634507da, 2022-01-07 (annotated)
- Committer:
- dswood
- Date:
- Fri Jan 07 12:05:27 2022 +0000
- Revision:
- 34:67b3634507da
- Parent:
- 11:b842b8e332cb
The libraries used would not output %. I tried escaping it but nothing worked. So I changed the & in the font and used that. Not cleaver I know. I don't recommend this to anyone.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Geremia | 4:12ba0ecc2c1f | 1 | /* mbed UniGraphic library - Device specific class |
Geremia | 4:12ba0ecc2c1f | 2 | * Copyright (c) 2015 Giuliano Dianda |
Geremia | 4:12ba0ecc2c1f | 3 | * Released under the MIT License: http://mbed.org/license/mit |
Geremia | 4:12ba0ecc2c1f | 4 | */ |
Geremia | 4:12ba0ecc2c1f | 5 | #include "Protocols.h" |
Geremia | 4:12ba0ecc2c1f | 6 | #include "ILI9486.h" |
Geremia | 4:12ba0ecc2c1f | 7 | |
Geremia | 4:12ba0ecc2c1f | 8 | ////////////////////////////////////////////////////////////////////////////////// |
Geremia | 4:12ba0ecc2c1f | 9 | // display settings /////////////////////////////////////////////////////// |
Geremia | 4:12ba0ecc2c1f | 10 | ///////////////////////////////////////////////////////////////////////// |
Geremia | 4:12ba0ecc2c1f | 11 | |
dreschpe | 9:1749ae993cfe | 12 | // put in constructor |
dreschpe | 9:1749ae993cfe | 13 | //#define LCDSIZE_X 320 // display X pixels, TFTs are usually portrait view |
dreschpe | 9:1749ae993cfe | 14 | //#define LCDSIZE_Y 480 // display Y pixels |
Geremia | 4:12ba0ecc2c1f | 15 | |
Geremia | 4:12ba0ecc2c1f | 16 | |
Geremia | 4:12ba0ecc2c1f | 17 | |
dreschpe | 9:1749ae993cfe | 18 | 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) |
Geremia | 4:12ba0ecc2c1f | 19 | : TFT(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, name) |
Geremia | 4:12ba0ecc2c1f | 20 | { |
Geremia | 4:12ba0ecc2c1f | 21 | hw_reset(); |
Geremia | 4:12ba0ecc2c1f | 22 | BusEnable(true); |
Geremia | 7:bb0383b91104 | 23 | identify(); // will collect tftID and set mipistd flag |
Geremia | 4:12ba0ecc2c1f | 24 | init(); |
Geremia | 11:b842b8e332cb | 25 | auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly |
Geremia | 4:12ba0ecc2c1f | 26 | set_orientation(0); |
Geremia | 10:668cf78ff93a | 27 | // FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. ILI9486 does not, at least in par mode |
Geremia | 4:12ba0ecc2c1f | 28 | cls(); |
Geremia | 4:12ba0ecc2c1f | 29 | locate(0,0); |
Geremia | 4:12ba0ecc2c1f | 30 | } |
dreschpe | 9:1749ae993cfe | 31 | 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) |
Geremia | 4:12ba0ecc2c1f | 32 | : TFT(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, name) |
Geremia | 4:12ba0ecc2c1f | 33 | { |
Geremia | 4:12ba0ecc2c1f | 34 | hw_reset(); //TFT class forwards to Protocol class |
Geremia | 4:12ba0ecc2c1f | 35 | BusEnable(true); //TFT class forwards to Protocol class |
Geremia | 7:bb0383b91104 | 36 | identify(); // will collect tftID and set mipistd flag |
Geremia | 4:12ba0ecc2c1f | 37 | init(); // per display custom init cmd sequence, implemented here |
Geremia | 11:b842b8e332cb | 38 | auto_gram_read_format();// try to get read gram pixel format, could be 16bit or 18bit, RGB or BGR. Will set flags accordingly |
Geremia | 4:12ba0ecc2c1f | 39 | set_orientation(0); //TFT class does for MIPI standard and some ILIxxx |
Geremia | 10:668cf78ff93a | 40 | // FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. ILI9486 does not, at least in par mode |
Geremia | 4:12ba0ecc2c1f | 41 | cls(); |
Geremia | 4:12ba0ecc2c1f | 42 | locate(0,0); |
Geremia | 4:12ba0ecc2c1f | 43 | } |
Geremia | 4:12ba0ecc2c1f | 44 | // reset and init the lcd controller |
Geremia | 4:12ba0ecc2c1f | 45 | void ILI9486::init() |
Geremia | 4:12ba0ecc2c1f | 46 | { |
Geremia | 4:12ba0ecc2c1f | 47 | /* Start Initial Sequence ----------------------------------------------------*/ |
Geremia | 4:12ba0ecc2c1f | 48 | |
Geremia | 4:12ba0ecc2c1f | 49 | wr_cmd8(0xF1); |
Geremia | 4:12ba0ecc2c1f | 50 | wr_data8(0x36); |
Geremia | 4:12ba0ecc2c1f | 51 | wr_data8(0x04); |
Geremia | 4:12ba0ecc2c1f | 52 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 53 | wr_data8(0x3C); |
Geremia | 4:12ba0ecc2c1f | 54 | wr_data8(0x0F); |
Geremia | 4:12ba0ecc2c1f | 55 | wr_data8(0x8F); |
Geremia | 4:12ba0ecc2c1f | 56 | |
Geremia | 4:12ba0ecc2c1f | 57 | |
Geremia | 4:12ba0ecc2c1f | 58 | wr_cmd8(0xF2); |
Geremia | 4:12ba0ecc2c1f | 59 | wr_data8(0x18); |
Geremia | 4:12ba0ecc2c1f | 60 | wr_data8(0xA3); |
Geremia | 4:12ba0ecc2c1f | 61 | wr_data8(0x12); |
Geremia | 4:12ba0ecc2c1f | 62 | wr_data8(0x02); |
Geremia | 4:12ba0ecc2c1f | 63 | wr_data8(0xb2); |
Geremia | 4:12ba0ecc2c1f | 64 | wr_data8(0x12); |
Geremia | 4:12ba0ecc2c1f | 65 | wr_data8(0xFF); |
Geremia | 4:12ba0ecc2c1f | 66 | wr_data8(0x10); |
Geremia | 4:12ba0ecc2c1f | 67 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 68 | |
Geremia | 4:12ba0ecc2c1f | 69 | wr_cmd8(0xF8); |
Geremia | 4:12ba0ecc2c1f | 70 | wr_data8(0x21); |
Geremia | 4:12ba0ecc2c1f | 71 | wr_data8(0x04); |
Geremia | 4:12ba0ecc2c1f | 72 | |
Geremia | 4:12ba0ecc2c1f | 73 | wr_cmd8(0xF9); |
Geremia | 4:12ba0ecc2c1f | 74 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 75 | wr_data8(0x08); |
Geremia | 4:12ba0ecc2c1f | 76 | |
Geremia | 4:12ba0ecc2c1f | 77 | wr_cmd8(0xC0); |
Geremia | 4:12ba0ecc2c1f | 78 | wr_data8(0x0f); //13 |
Geremia | 4:12ba0ecc2c1f | 79 | wr_data8(0x0f); //10 |
Geremia | 4:12ba0ecc2c1f | 80 | |
Geremia | 4:12ba0ecc2c1f | 81 | wr_cmd8(0xC1); |
Geremia | 4:12ba0ecc2c1f | 82 | wr_data8(0x42); //43 |
Geremia | 4:12ba0ecc2c1f | 83 | |
Geremia | 4:12ba0ecc2c1f | 84 | wr_cmd8(0xC2); |
Geremia | 4:12ba0ecc2c1f | 85 | wr_data8(0x22); |
Geremia | 4:12ba0ecc2c1f | 86 | |
Geremia | 4:12ba0ecc2c1f | 87 | wr_cmd8(0xC5); |
Geremia | 4:12ba0ecc2c1f | 88 | wr_data8(0x01); //00 |
Geremia | 4:12ba0ecc2c1f | 89 | wr_data8(0x29); //4D |
Geremia | 4:12ba0ecc2c1f | 90 | wr_data8(0x80); |
Geremia | 4:12ba0ecc2c1f | 91 | |
Geremia | 4:12ba0ecc2c1f | 92 | wr_cmd8(0xB6); |
Geremia | 4:12ba0ecc2c1f | 93 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 94 | wr_data8(0x02); //42 |
Geremia | 4:12ba0ecc2c1f | 95 | wr_data8(0x3b); |
Geremia | 4:12ba0ecc2c1f | 96 | |
Geremia | 4:12ba0ecc2c1f | 97 | wr_cmd8(0xB1); |
Geremia | 4:12ba0ecc2c1f | 98 | wr_data8(0xB0); //C0 |
Geremia | 4:12ba0ecc2c1f | 99 | wr_data8(0x11); |
Geremia | 4:12ba0ecc2c1f | 100 | |
Geremia | 4:12ba0ecc2c1f | 101 | wr_cmd8(0xB4); |
Geremia | 4:12ba0ecc2c1f | 102 | wr_data8(0x02); //01 |
Geremia | 4:12ba0ecc2c1f | 103 | |
Geremia | 4:12ba0ecc2c1f | 104 | wr_cmd8(0xE0); |
Geremia | 4:12ba0ecc2c1f | 105 | wr_data8(0x0F); |
Geremia | 4:12ba0ecc2c1f | 106 | wr_data8(0x18); |
Geremia | 4:12ba0ecc2c1f | 107 | wr_data8(0x15); |
Geremia | 4:12ba0ecc2c1f | 108 | wr_data8(0x09); |
Geremia | 4:12ba0ecc2c1f | 109 | wr_data8(0x0B); |
Geremia | 4:12ba0ecc2c1f | 110 | wr_data8(0x04); |
Geremia | 4:12ba0ecc2c1f | 111 | wr_data8(0x49); |
Geremia | 4:12ba0ecc2c1f | 112 | wr_data8(0x64); |
Geremia | 4:12ba0ecc2c1f | 113 | wr_data8(0x3D); |
Geremia | 4:12ba0ecc2c1f | 114 | wr_data8(0x08); |
Geremia | 4:12ba0ecc2c1f | 115 | wr_data8(0x15); |
Geremia | 4:12ba0ecc2c1f | 116 | wr_data8(0x06); |
Geremia | 4:12ba0ecc2c1f | 117 | wr_data8(0x12); |
Geremia | 4:12ba0ecc2c1f | 118 | wr_data8(0x07); |
Geremia | 4:12ba0ecc2c1f | 119 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 120 | |
Geremia | 4:12ba0ecc2c1f | 121 | wr_cmd8(0xE1); |
Geremia | 4:12ba0ecc2c1f | 122 | wr_data8(0x0F); |
Geremia | 4:12ba0ecc2c1f | 123 | wr_data8(0x38); |
Geremia | 4:12ba0ecc2c1f | 124 | wr_data8(0x35); |
Geremia | 4:12ba0ecc2c1f | 125 | wr_data8(0x0a); |
Geremia | 4:12ba0ecc2c1f | 126 | wr_data8(0x0c); |
Geremia | 4:12ba0ecc2c1f | 127 | wr_data8(0x03); |
Geremia | 4:12ba0ecc2c1f | 128 | wr_data8(0x4A); |
Geremia | 4:12ba0ecc2c1f | 129 | wr_data8(0x42); |
Geremia | 4:12ba0ecc2c1f | 130 | wr_data8(0x36); |
Geremia | 4:12ba0ecc2c1f | 131 | wr_data8(0x04); |
Geremia | 4:12ba0ecc2c1f | 132 | wr_data8(0x0F); |
Geremia | 4:12ba0ecc2c1f | 133 | wr_data8(0x03); |
Geremia | 4:12ba0ecc2c1f | 134 | wr_data8(0x1F); |
Geremia | 4:12ba0ecc2c1f | 135 | wr_data8(0x1B); |
Geremia | 4:12ba0ecc2c1f | 136 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 137 | |
Geremia | 4:12ba0ecc2c1f | 138 | wr_cmd8(0x20); // display inversion OFF |
Geremia | 4:12ba0ecc2c1f | 139 | |
Geremia | 4:12ba0ecc2c1f | 140 | wr_cmd8(0x36); // MEMORY_ACCESS_CONTROL (orientation stuff) |
Geremia | 4:12ba0ecc2c1f | 141 | wr_data8(0x48); |
Geremia | 4:12ba0ecc2c1f | 142 | |
Geremia | 4:12ba0ecc2c1f | 143 | wr_cmd8(0x3A); // COLMOD_PIXEL_FORMAT_SET |
Geremia | 4:12ba0ecc2c1f | 144 | wr_data8(0x55); // 16 bit pixel |
Geremia | 4:12ba0ecc2c1f | 145 | |
Geremia | 4:12ba0ecc2c1f | 146 | wr_cmd8(0x13); // Nomal Displaymode |
Geremia | 4:12ba0ecc2c1f | 147 | |
Geremia | 4:12ba0ecc2c1f | 148 | wr_cmd8(0x11); // sleep out |
Geremia | 4:12ba0ecc2c1f | 149 | wait_ms(150); |
Geremia | 4:12ba0ecc2c1f | 150 | |
Geremia | 4:12ba0ecc2c1f | 151 | wr_cmd8(0x29); // display on |
Geremia | 4:12ba0ecc2c1f | 152 | wait_ms(150); |
Geremia | 4:12ba0ecc2c1f | 153 | } |