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.
Dependents: afero_poc15_180216 afero_poc15_180223 afero_poc15_180302 afero_poc15_180403R ... more
Fork of UniGraphic by
UniGraphic for La Suno Version.
To go with La Suno, WatchDog Reset functions were added in ILI9341.
Inits/TFT_MIPI.cpp@10:668cf78ff93a, 2015-02-19 (annotated)
- Committer:
- Geremia
- Date:
- Thu Feb 19 00:33:27 2015 +0000
- Revision:
- 10:668cf78ff93a
- Parent:
- 9:1749ae993cfe
- Child:
- 11:b842b8e332cb
Added FastWindow for TFT (truncated set page/column cmds), which increases speed when plotting single pixels (around 20-25% faster?!?!)
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 "TFT_MIPI.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 | TFT_MIPI::TFT_MIPI(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, set mipistd flag |
Geremia | 4:12ba0ecc2c1f | 24 | init(); |
Geremia | 7:bb0383b91104 | 25 | // scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it, for ili9481 is set automatically in identify() |
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. Give a try |
Geremia | 4:12ba0ecc2c1f | 28 | cls(); |
Geremia | 4:12ba0ecc2c1f | 29 | locate(0,0); |
Geremia | 4:12ba0ecc2c1f | 30 | } |
dreschpe | 9:1749ae993cfe | 31 | TFT_MIPI::TFT_MIPI(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 | 7:bb0383b91104 | 38 | // scrollbugfix=1; // when scrolling 1 line, the last line disappears, set to 1 to fix it, for ili9481 is set automatically in identify() |
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. Give a try |
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 TFT_MIPI::init() |
Geremia | 4:12ba0ecc2c1f | 46 | { |
Geremia | 4:12ba0ecc2c1f | 47 | /* Start Initial Sequence ----------------------------------------------------*/ |
Geremia | 4:12ba0ecc2c1f | 48 | |
Geremia | 4:12ba0ecc2c1f | 49 | /* Start Initial Sequence ----------------------------------------------------*/ |
Geremia | 4:12ba0ecc2c1f | 50 | wr_cmd8(0xD0); // POWER SETTING |
Geremia | 4:12ba0ecc2c1f | 51 | wr_data8(0x07); |
Geremia | 4:12ba0ecc2c1f | 52 | wr_data8(0x42); |
Geremia | 4:12ba0ecc2c1f | 53 | wr_data8(0x18); |
Geremia | 4:12ba0ecc2c1f | 54 | |
Geremia | 4:12ba0ecc2c1f | 55 | wr_cmd8(0xD1); // VCOM control |
Geremia | 4:12ba0ecc2c1f | 56 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 57 | wr_data8(0x07); |
Geremia | 4:12ba0ecc2c1f | 58 | wr_data8(0x10); |
Geremia | 4:12ba0ecc2c1f | 59 | |
Geremia | 4:12ba0ecc2c1f | 60 | wr_cmd8(0xD2); // Power_Setting for Normal Mode |
Geremia | 4:12ba0ecc2c1f | 61 | wr_data8(0x01); // LCD power supply current |
Geremia | 4:12ba0ecc2c1f | 62 | wr_data8(0x02); // charge pumps |
Geremia | 4:12ba0ecc2c1f | 63 | |
Geremia | 4:12ba0ecc2c1f | 64 | wr_cmd8(0xC0); // Panel Driving Setting |
Geremia | 4:12ba0ecc2c1f | 65 | wr_data8(0x10); // 10 orig |
Geremia | 4:12ba0ecc2c1f | 66 | wr_data8(0x3B); //number of lines+1 *8 |
Geremia | 4:12ba0ecc2c1f | 67 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 68 | wr_data8(0x02); |
Geremia | 4:12ba0ecc2c1f | 69 | wr_data8(0x11); |
Geremia | 4:12ba0ecc2c1f | 70 | |
Geremia | 4:12ba0ecc2c1f | 71 | // C1 missing? Display_Timing_Setting for Normal Mode |
Geremia | 4:12ba0ecc2c1f | 72 | |
Geremia | 4:12ba0ecc2c1f | 73 | //renesas does not have this |
Geremia | 4:12ba0ecc2c1f | 74 | // wr_cmd8(0xC5); // Frame Rate and Inversion Control |
Geremia | 4:12ba0ecc2c1f | 75 | // wr_data8(0x03); // 72hz, datashet tells default 02=85hz |
Geremia | 4:12ba0ecc2c1f | 76 | |
Geremia | 4:12ba0ecc2c1f | 77 | wr_cmd8(0xC8); // Gamma settings |
Geremia | 4:12ba0ecc2c1f | 78 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 79 | wr_data8(0x32); |
Geremia | 4:12ba0ecc2c1f | 80 | wr_data8(0x36); |
Geremia | 4:12ba0ecc2c1f | 81 | wr_data8(0x45); |
Geremia | 4:12ba0ecc2c1f | 82 | wr_data8(0x06); |
Geremia | 4:12ba0ecc2c1f | 83 | wr_data8(0x16); |
Geremia | 4:12ba0ecc2c1f | 84 | wr_data8(0x37); |
Geremia | 4:12ba0ecc2c1f | 85 | wr_data8(0x75); |
Geremia | 4:12ba0ecc2c1f | 86 | wr_data8(0x77); |
Geremia | 4:12ba0ecc2c1f | 87 | wr_data8(0x54); |
Geremia | 4:12ba0ecc2c1f | 88 | wr_data8(0x0C); |
Geremia | 4:12ba0ecc2c1f | 89 | wr_data8(0x00); |
Geremia | 4:12ba0ecc2c1f | 90 | |
Geremia | 4:12ba0ecc2c1f | 91 | |
Geremia | 4:12ba0ecc2c1f | 92 | |
Geremia | 4:12ba0ecc2c1f | 93 | wr_cmd8(0x36); // MEMORY_ACCESS_CONTROL (orientation stuff) |
Geremia | 4:12ba0ecc2c1f | 94 | wr_data8(0x0A); // 0A as per chinese example (vertical flipped) |
Geremia | 4:12ba0ecc2c1f | 95 | |
Geremia | 4:12ba0ecc2c1f | 96 | wr_cmd8(0x3A); // COLMOD_PIXEL_FORMAT_SET, not present in AN |
Geremia | 4:12ba0ecc2c1f | 97 | wr_data8(0x55); // 16 bit pixel |
Geremia | 4:12ba0ecc2c1f | 98 | |
Geremia | 4:12ba0ecc2c1f | 99 | wr_cmd8(0x13); // Nomal Displaymode |
Geremia | 4:12ba0ecc2c1f | 100 | |
Geremia | 4:12ba0ecc2c1f | 101 | wr_cmd8(0x11); // sleep out |
Geremia | 4:12ba0ecc2c1f | 102 | wait_ms(150); |
Geremia | 4:12ba0ecc2c1f | 103 | |
Geremia | 4:12ba0ecc2c1f | 104 | wr_cmd8(0x29); // display on |
Geremia | 4:12ba0ecc2c1f | 105 | wait_ms(150); |
Geremia | 4:12ba0ecc2c1f | 106 | |
Geremia | 4:12ba0ecc2c1f | 107 | } |