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/ILI932x.cpp@20:14daa48ffd4c, 2015-03-23 (annotated)
- Committer:
- Geremia
- Date:
- Mon Mar 23 14:08:04 2015 +0000
- Revision:
- 20:14daa48ffd4c
- Child:
- 21:ae0a4eedfc90
Add ILI 9320/9325/9328 custom TFT932x class, parallel/spi 8/16bit, with orientation, scroll, pixelread, fastwindow.; Par8 and 16 tested, SPI not at all, needs checking if the CS toggle is necessary (see SPI8.cpp SPI16.cpp).
Who changed what in which revision?
User | Revision | Line number | New 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 | 20:14daa48ffd4c | 27 | 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 | 28 | : TFT932x(displayproto, Hz, mosi, miso, sclk, CS, reset, LCDSIZE_X, LCDSIZE_Y, name) |
Geremia | 20:14daa48ffd4c | 29 | { |
Geremia | 20:14daa48ffd4c | 30 | hw_reset(); //TFT class forwards to Protocol class |
Geremia | 20:14daa48ffd4c | 31 | BusEnable(true); //set CS low, TFT932x class will toggle CS every transfer |
Geremia | 20:14daa48ffd4c | 32 | identify(); // will collect tftID |
Geremia | 20:14daa48ffd4c | 33 | if(tftID==0x9325) init9325(); |
Geremia | 20:14daa48ffd4c | 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 | 20:14daa48ffd4c | 35 | set_orientation(0); |
Geremia | 20:14daa48ffd4c | 36 | FastWindow(true); // most but not all controllers support this, even if datasheet tells they should. |
Geremia | 20:14daa48ffd4c | 37 | cls(); |
Geremia | 20:14daa48ffd4c | 38 | locate(0,0); |
Geremia | 20:14daa48ffd4c | 39 | } |
Geremia | 20:14daa48ffd4c | 40 | // reset and init the lcd controller |
Geremia | 20:14daa48ffd4c | 41 | |
Geremia | 20:14daa48ffd4c | 42 | void ILI932x::init9325() |
Geremia | 20:14daa48ffd4c | 43 | { |
Geremia | 20:14daa48ffd4c | 44 | /* Example for ILI9325 ----------------------------------------------------*/ |
Geremia | 20:14daa48ffd4c | 45 | |
Geremia | 20:14daa48ffd4c | 46 | reg_write(0x0001,0x0100); |
Geremia | 20:14daa48ffd4c | 47 | reg_write(0x0002,0x0700); |
Geremia | 20:14daa48ffd4c | 48 | reg_write(0x0003,0x1030); |
Geremia | 20:14daa48ffd4c | 49 | reg_write(0x0004,0x0000); |
Geremia | 20:14daa48ffd4c | 50 | reg_write(0x0008,0x0207); |
Geremia | 20:14daa48ffd4c | 51 | reg_write(0x0009,0x0000); |
Geremia | 20:14daa48ffd4c | 52 | reg_write(0x000A,0x0000); |
Geremia | 20:14daa48ffd4c | 53 | reg_write(0x000C,0x0000); |
Geremia | 20:14daa48ffd4c | 54 | reg_write(0x000D,0x0000); |
Geremia | 20:14daa48ffd4c | 55 | reg_write(0x000F,0x0000); |
Geremia | 20:14daa48ffd4c | 56 | //power on sequence VGHVGL |
Geremia | 20:14daa48ffd4c | 57 | reg_write(0x0010,0x0000); |
Geremia | 20:14daa48ffd4c | 58 | reg_write(0x0011,0x0007); |
Geremia | 20:14daa48ffd4c | 59 | reg_write(0x0012,0x0000); |
Geremia | 20:14daa48ffd4c | 60 | reg_write(0x0013,0x0000); |
Geremia | 20:14daa48ffd4c | 61 | reg_write(0x0007,0x0001); |
Geremia | 20:14daa48ffd4c | 62 | wait_ms(200); |
Geremia | 20:14daa48ffd4c | 63 | //vgh |
Geremia | 20:14daa48ffd4c | 64 | reg_write(0x0010,0x1290); |
Geremia | 20:14daa48ffd4c | 65 | reg_write(0x0011,0x0227); |
Geremia | 20:14daa48ffd4c | 66 | wait_ms(50); |
Geremia | 20:14daa48ffd4c | 67 | //vregiout |
Geremia | 20:14daa48ffd4c | 68 | reg_write(0x0012,0x001d); //0x001b |
Geremia | 20:14daa48ffd4c | 69 | wait_ms(50); |
Geremia | 20:14daa48ffd4c | 70 | //vom amplitude |
Geremia | 20:14daa48ffd4c | 71 | reg_write(0x0013,0x1500); |
Geremia | 20:14daa48ffd4c | 72 | wait_ms(50); |
Geremia | 20:14daa48ffd4c | 73 | //vom H |
Geremia | 20:14daa48ffd4c | 74 | reg_write(0x0029,0x0018); |
Geremia | 20:14daa48ffd4c | 75 | reg_write(0x002B,0x000D); |
Geremia | 20:14daa48ffd4c | 76 | wait_ms(50); |
Geremia | 20:14daa48ffd4c | 77 | //gamma |
Geremia | 20:14daa48ffd4c | 78 | reg_write(0x0030,0x0004); |
Geremia | 20:14daa48ffd4c | 79 | reg_write(0x0031,0x0307); |
Geremia | 20:14daa48ffd4c | 80 | reg_write(0x0032,0x0002);// 0006 |
Geremia | 20:14daa48ffd4c | 81 | reg_write(0x0035,0x0206); |
Geremia | 20:14daa48ffd4c | 82 | reg_write(0x0036,0x0408); |
Geremia | 20:14daa48ffd4c | 83 | reg_write(0x0037,0x0507); |
Geremia | 20:14daa48ffd4c | 84 | reg_write(0x0038,0x0204);//0200 |
Geremia | 20:14daa48ffd4c | 85 | reg_write(0x0039,0x0707); |
Geremia | 20:14daa48ffd4c | 86 | reg_write(0x003C,0x0405);// 0504 |
Geremia | 20:14daa48ffd4c | 87 | reg_write(0x003D,0x0F02); |
Geremia | 20:14daa48ffd4c | 88 | //ram |
Geremia | 20:14daa48ffd4c | 89 | reg_write(0x0050,0x0000); |
Geremia | 20:14daa48ffd4c | 90 | reg_write(0x0051,0x00EF); |
Geremia | 20:14daa48ffd4c | 91 | reg_write(0x0052,0x0000); |
Geremia | 20:14daa48ffd4c | 92 | reg_write(0x0053,0x013F); |
Geremia | 20:14daa48ffd4c | 93 | reg_write(0x0060,0xA700); |
Geremia | 20:14daa48ffd4c | 94 | reg_write(0x0061,0x0001); |
Geremia | 20:14daa48ffd4c | 95 | reg_write(0x006A,0x0000); |
Geremia | 20:14daa48ffd4c | 96 | // |
Geremia | 20:14daa48ffd4c | 97 | reg_write(0x0080,0x0000); |
Geremia | 20:14daa48ffd4c | 98 | reg_write(0x0081,0x0000); |
Geremia | 20:14daa48ffd4c | 99 | reg_write(0x0082,0x0000); |
Geremia | 20:14daa48ffd4c | 100 | reg_write(0x0083,0x0000); |
Geremia | 20:14daa48ffd4c | 101 | reg_write(0x0084,0x0000); |
Geremia | 20:14daa48ffd4c | 102 | reg_write(0x0085,0x0000); |
Geremia | 20:14daa48ffd4c | 103 | // |
Geremia | 20:14daa48ffd4c | 104 | reg_write(0x0090,0x0010); |
Geremia | 20:14daa48ffd4c | 105 | reg_write(0x0092,0x0600); |
Geremia | 20:14daa48ffd4c | 106 | reg_write(0x0093,0x0003); |
Geremia | 20:14daa48ffd4c | 107 | reg_write(0x0095,0x0110); |
Geremia | 20:14daa48ffd4c | 108 | reg_write(0x0097,0x0000); |
Geremia | 20:14daa48ffd4c | 109 | reg_write(0x0098,0x0000); |
Geremia | 20:14daa48ffd4c | 110 | |
Geremia | 20:14daa48ffd4c | 111 | reg_write(0x0007,0x0133); // display on |
Geremia | 20:14daa48ffd4c | 112 | |
Geremia | 20:14daa48ffd4c | 113 | } |