.
SPI_TFT_ILI9341.h@0:1b3481785d59, 2019-06-16 (annotated)
- Committer:
- 2018US_EminaTahirovi
- Date:
- Sun Jun 16 20:26:22 2019 +0000
- Revision:
- 0:1b3481785d59
.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
2018US_EminaTahirovi | 0:1b3481785d59 | 1 | /* mbed library for 240*320 pixel display TFT based on ILI9341 LCD Controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 2 | * Copyright (c) 2013 Peter Drescher - DC2PD |
2018US_EminaTahirovi | 0:1b3481785d59 | 3 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 4 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
2018US_EminaTahirovi | 0:1b3481785d59 | 5 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
2018US_EminaTahirovi | 0:1b3481785d59 | 6 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
2018US_EminaTahirovi | 0:1b3481785d59 | 7 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
2018US_EminaTahirovi | 0:1b3481785d59 | 8 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
2018US_EminaTahirovi | 0:1b3481785d59 | 9 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
2018US_EminaTahirovi | 0:1b3481785d59 | 10 | * THE SOFTWARE. |
2018US_EminaTahirovi | 0:1b3481785d59 | 11 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 12 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 13 | /* change the char position handling |
2018US_EminaTahirovi | 0:1b3481785d59 | 14 | * use pixel (x,y) instadt of colum row */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 15 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 16 | #ifndef MBED_SPI_TFT_ILI9341_H |
2018US_EminaTahirovi | 0:1b3481785d59 | 17 | #define MBED_SPI_TFT_ILI9341_H |
2018US_EminaTahirovi | 0:1b3481785d59 | 18 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 19 | #include "mbed.h" |
2018US_EminaTahirovi | 0:1b3481785d59 | 20 | #include "GraphicsDisplay.h" |
2018US_EminaTahirovi | 0:1b3481785d59 | 21 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 22 | #define RGB(r,g,b) (((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3)) //5 red | 6 green | 5 blue |
2018US_EminaTahirovi | 0:1b3481785d59 | 23 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 24 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 25 | /* some RGB color definitions */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 26 | #define Black 0x0000 /* 0, 0, 0 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 27 | #define Navy 0x000F /* 0, 0, 128 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 28 | #define DarkGreen 0x03E0 /* 0, 128, 0 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 29 | #define DarkCyan 0x03EF /* 0, 128, 128 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 30 | #define Maroon 0x7800 /* 128, 0, 0 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 31 | #define Purple 0x780F /* 128, 0, 128 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 32 | #define Olive 0x7BE0 /* 128, 128, 0 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 33 | #define LightGrey 0xC618 /* 192, 192, 192 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 34 | #define DarkGrey 0x7BEF /* 128, 128, 128 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 35 | #define Blue 0x001F /* 0, 0, 255 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 36 | #define Green 0x07E0 /* 0, 255, 0 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 37 | #define Cyan 0x07FF /* 0, 255, 255 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 38 | #define Red 0xF800 /* 255, 0, 0 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 39 | #define Magenta 0xF81F /* 255, 0, 255 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 40 | #define Yellow 0xFFE0 /* 255, 255, 0 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 41 | #define White 0xFFFF /* 255, 255, 255 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 42 | #define Orange 0xFD20 /* 255, 165, 0 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 43 | #define GreenYellow 0xAFE5 /* 173, 255, 47 */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 44 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 45 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 46 | /** Display control class, based on GraphicsDisplay and TextDisplay |
2018US_EminaTahirovi | 0:1b3481785d59 | 47 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 48 | * Example: |
2018US_EminaTahirovi | 0:1b3481785d59 | 49 | * @code |
2018US_EminaTahirovi | 0:1b3481785d59 | 50 | * #include "stdio.h" |
2018US_EminaTahirovi | 0:1b3481785d59 | 51 | * #include "mbed.h" |
2018US_EminaTahirovi | 0:1b3481785d59 | 52 | * #include "SPI_TFT_ILI9341.h" |
2018US_EminaTahirovi | 0:1b3481785d59 | 53 | * #include "string" |
2018US_EminaTahirovi | 0:1b3481785d59 | 54 | * #include "Arial12x12.h" |
2018US_EminaTahirovi | 0:1b3481785d59 | 55 | * #include "Arial24x23.h" |
2018US_EminaTahirovi | 0:1b3481785d59 | 56 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 57 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 58 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 59 | * // the TFT is connected to SPI pin 5-7 and IO's 8-10 |
2018US_EminaTahirovi | 0:1b3481785d59 | 60 | * SPI_TFT_ILI9341 TFT(p5, p6, p7, p8, p9, p10,"TFT"); // mosi, miso, sclk, cs, reset, dc |
2018US_EminaTahirovi | 0:1b3481785d59 | 61 | * If your display need a signal for switch the backlight use a aditional IO pin in your program |
2018US_EminaTahirovi | 0:1b3481785d59 | 62 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 63 | * int main() { |
2018US_EminaTahirovi | 0:1b3481785d59 | 64 | * TFT.claim(stdout); // send stdout to the TFT display |
2018US_EminaTahirovi | 0:1b3481785d59 | 65 | * //TFT.claim(stderr); // send stderr to the TFT display |
2018US_EminaTahirovi | 0:1b3481785d59 | 66 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 67 | * TFT.background(Black); // set background to black |
2018US_EminaTahirovi | 0:1b3481785d59 | 68 | * TFT.foreground(White); // set chars to white |
2018US_EminaTahirovi | 0:1b3481785d59 | 69 | * TFT.cls(); // clear the screen |
2018US_EminaTahirovi | 0:1b3481785d59 | 70 | * TFT.set_font((unsigned char*) Arial12x12); // select the font |
2018US_EminaTahirovi | 0:1b3481785d59 | 71 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 72 | * TFT.set_orientation(0); |
2018US_EminaTahirovi | 0:1b3481785d59 | 73 | * printf(" Hello Mbed 0"); |
2018US_EminaTahirovi | 0:1b3481785d59 | 74 | * TFT.set_font((unsigned char*) Arial24x23); // select font 2 |
2018US_EminaTahirovi | 0:1b3481785d59 | 75 | * TFT.locate(48,115); |
2018US_EminaTahirovi | 0:1b3481785d59 | 76 | * TFT.printf("Bigger Font"); |
2018US_EminaTahirovi | 0:1b3481785d59 | 77 | * } |
2018US_EminaTahirovi | 0:1b3481785d59 | 78 | * @endcode |
2018US_EminaTahirovi | 0:1b3481785d59 | 79 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 80 | class SPI_TFT_ILI9341 : public GraphicsDisplay , public SPI { |
2018US_EminaTahirovi | 0:1b3481785d59 | 81 | public: |
2018US_EminaTahirovi | 0:1b3481785d59 | 82 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 83 | /** Create a SPI_TFT object connected to SPI and three pins |
2018US_EminaTahirovi | 0:1b3481785d59 | 84 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 85 | * @param mosi pin connected to SDO of display |
2018US_EminaTahirovi | 0:1b3481785d59 | 86 | * @param miso pin connected to SDI of display |
2018US_EminaTahirovi | 0:1b3481785d59 | 87 | * @param sclk pin connected to RS of display |
2018US_EminaTahirovi | 0:1b3481785d59 | 88 | * @param cs pin connected to CS of display |
2018US_EminaTahirovi | 0:1b3481785d59 | 89 | * @param reset pin connected to RESET of display |
2018US_EminaTahirovi | 0:1b3481785d59 | 90 | * @param dc pin connected to WR of display |
2018US_EminaTahirovi | 0:1b3481785d59 | 91 | * the IM pins have to be set to 1110 (3-0) |
2018US_EminaTahirovi | 0:1b3481785d59 | 92 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 93 | SPI_TFT_ILI9341(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset, PinName dc, const char* name ="TFT"); |
2018US_EminaTahirovi | 0:1b3481785d59 | 94 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 95 | /** Get the width of the screen in pixel |
2018US_EminaTahirovi | 0:1b3481785d59 | 96 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 97 | * @returns width of screen in pixel |
2018US_EminaTahirovi | 0:1b3481785d59 | 98 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 99 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 100 | virtual int width(); |
2018US_EminaTahirovi | 0:1b3481785d59 | 101 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 102 | /** Get the height of the screen in pixel |
2018US_EminaTahirovi | 0:1b3481785d59 | 103 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 104 | * @returns height of screen in pixel |
2018US_EminaTahirovi | 0:1b3481785d59 | 105 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 106 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 107 | virtual int height(); |
2018US_EminaTahirovi | 0:1b3481785d59 | 108 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 109 | /** Draw a pixel at x,y with color |
2018US_EminaTahirovi | 0:1b3481785d59 | 110 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 111 | * @param x horizontal position |
2018US_EminaTahirovi | 0:1b3481785d59 | 112 | * @param y vertical position |
2018US_EminaTahirovi | 0:1b3481785d59 | 113 | * @param color 16 bit pixel color |
2018US_EminaTahirovi | 0:1b3481785d59 | 114 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 115 | virtual void pixel(int x, int y,int colour); |
2018US_EminaTahirovi | 0:1b3481785d59 | 116 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 117 | /** draw a circle |
2018US_EminaTahirovi | 0:1b3481785d59 | 118 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 119 | * @param x0,y0 center |
2018US_EminaTahirovi | 0:1b3481785d59 | 120 | * @param r radius |
2018US_EminaTahirovi | 0:1b3481785d59 | 121 | * @param color 16 bit color * |
2018US_EminaTahirovi | 0:1b3481785d59 | 122 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 123 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 124 | void circle(int x, int y, int r, int colour); |
2018US_EminaTahirovi | 0:1b3481785d59 | 125 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 126 | /** draw a filled circle |
2018US_EminaTahirovi | 0:1b3481785d59 | 127 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 128 | * @param x0,y0 center |
2018US_EminaTahirovi | 0:1b3481785d59 | 129 | * @param r radius |
2018US_EminaTahirovi | 0:1b3481785d59 | 130 | * @param color 16 bit color * |
2018US_EminaTahirovi | 0:1b3481785d59 | 131 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 132 | void fillcircle(int x, int y, int r, int colour); |
2018US_EminaTahirovi | 0:1b3481785d59 | 133 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 134 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 135 | /** draw a 1 pixel line |
2018US_EminaTahirovi | 0:1b3481785d59 | 136 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 137 | * @param x0,y0 start point |
2018US_EminaTahirovi | 0:1b3481785d59 | 138 | * @param x1,y1 stop point |
2018US_EminaTahirovi | 0:1b3481785d59 | 139 | * @param color 16 bit color |
2018US_EminaTahirovi | 0:1b3481785d59 | 140 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 141 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 142 | void line(int x0, int y0, int x1, int y1, int colour); |
2018US_EminaTahirovi | 0:1b3481785d59 | 143 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 144 | /** draw a rect |
2018US_EminaTahirovi | 0:1b3481785d59 | 145 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 146 | * @param x0,y0 top left corner |
2018US_EminaTahirovi | 0:1b3481785d59 | 147 | * @param x1,y1 down right corner |
2018US_EminaTahirovi | 0:1b3481785d59 | 148 | * @param color 16 bit color |
2018US_EminaTahirovi | 0:1b3481785d59 | 149 | * * |
2018US_EminaTahirovi | 0:1b3481785d59 | 150 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 151 | void rect(int x0, int y0, int x1, int y1, int colour); |
2018US_EminaTahirovi | 0:1b3481785d59 | 152 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 153 | /** draw a filled rect |
2018US_EminaTahirovi | 0:1b3481785d59 | 154 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 155 | * @param x0,y0 top left corner |
2018US_EminaTahirovi | 0:1b3481785d59 | 156 | * @param x1,y1 down right corner |
2018US_EminaTahirovi | 0:1b3481785d59 | 157 | * @param color 16 bit color |
2018US_EminaTahirovi | 0:1b3481785d59 | 158 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 159 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 160 | void fillrect(int x0, int y0, int x1, int y1, int colour); |
2018US_EminaTahirovi | 0:1b3481785d59 | 161 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 162 | /** setup cursor position |
2018US_EminaTahirovi | 0:1b3481785d59 | 163 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 164 | * @param x x-position (top left) |
2018US_EminaTahirovi | 0:1b3481785d59 | 165 | * @param y y-position |
2018US_EminaTahirovi | 0:1b3481785d59 | 166 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 167 | virtual void locate(int x, int y); |
2018US_EminaTahirovi | 0:1b3481785d59 | 168 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 169 | /** Fill the screen with _backgroun color |
2018US_EminaTahirovi | 0:1b3481785d59 | 170 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 171 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 172 | virtual void cls (void); |
2018US_EminaTahirovi | 0:1b3481785d59 | 173 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 174 | /** calculate the max number of char in a line |
2018US_EminaTahirovi | 0:1b3481785d59 | 175 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 176 | * @returns max columns |
2018US_EminaTahirovi | 0:1b3481785d59 | 177 | * depends on actual font size |
2018US_EminaTahirovi | 0:1b3481785d59 | 178 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 179 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 180 | virtual int columns(void); |
2018US_EminaTahirovi | 0:1b3481785d59 | 181 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 182 | /** calculate the max number of columns |
2018US_EminaTahirovi | 0:1b3481785d59 | 183 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 184 | * @returns max column |
2018US_EminaTahirovi | 0:1b3481785d59 | 185 | * depends on actual font size |
2018US_EminaTahirovi | 0:1b3481785d59 | 186 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 187 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 188 | virtual int rows(void); |
2018US_EminaTahirovi | 0:1b3481785d59 | 189 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 190 | /** put a char on the screen |
2018US_EminaTahirovi | 0:1b3481785d59 | 191 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 192 | * @param value char to print |
2018US_EminaTahirovi | 0:1b3481785d59 | 193 | * @returns printed char |
2018US_EminaTahirovi | 0:1b3481785d59 | 194 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 195 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 196 | virtual int _putc(int value); |
2018US_EminaTahirovi | 0:1b3481785d59 | 197 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 198 | /** draw a character on given position out of the active font to the TFT |
2018US_EminaTahirovi | 0:1b3481785d59 | 199 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 200 | * @param x x-position of char (top left) |
2018US_EminaTahirovi | 0:1b3481785d59 | 201 | * @param y y-position |
2018US_EminaTahirovi | 0:1b3481785d59 | 202 | * @param c char to print |
2018US_EminaTahirovi | 0:1b3481785d59 | 203 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 204 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 205 | virtual void character(int x, int y, int c); |
2018US_EminaTahirovi | 0:1b3481785d59 | 206 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 207 | /** paint a bitmap on the TFT |
2018US_EminaTahirovi | 0:1b3481785d59 | 208 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 209 | * @param x,y : upper left corner |
2018US_EminaTahirovi | 0:1b3481785d59 | 210 | * @param w width of bitmap |
2018US_EminaTahirovi | 0:1b3481785d59 | 211 | * @param h high of bitmap |
2018US_EminaTahirovi | 0:1b3481785d59 | 212 | * @param *bitmap pointer to the bitmap data |
2018US_EminaTahirovi | 0:1b3481785d59 | 213 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 214 | * bitmap format: 16 bit R5 G6 B5 |
2018US_EminaTahirovi | 0:1b3481785d59 | 215 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 216 | * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 |
2018US_EminaTahirovi | 0:1b3481785d59 | 217 | * use winhex to load this file and mark data stating at offset 0x46 to end |
2018US_EminaTahirovi | 0:1b3481785d59 | 218 | * use edit -> copy block -> C Source to export C array |
2018US_EminaTahirovi | 0:1b3481785d59 | 219 | * paste this array into your program |
2018US_EminaTahirovi | 0:1b3481785d59 | 220 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 221 | * define the array as static const unsigned char to put it into flash memory |
2018US_EminaTahirovi | 0:1b3481785d59 | 222 | * cast the pointer to (unsigned char *) : |
2018US_EminaTahirovi | 0:1b3481785d59 | 223 | * tft.Bitmap(10,40,309,50,(unsigned char *)scala); |
2018US_EminaTahirovi | 0:1b3481785d59 | 224 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 225 | void Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap); |
2018US_EminaTahirovi | 0:1b3481785d59 | 226 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 227 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 228 | /** paint a 16 bit BMP from filesytem on the TFT (slow) |
2018US_EminaTahirovi | 0:1b3481785d59 | 229 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 230 | * @param x,y : position of upper left corner |
2018US_EminaTahirovi | 0:1b3481785d59 | 231 | * @param *Name_BMP name of the BMP file with drive: "/local/test.bmp" |
2018US_EminaTahirovi | 0:1b3481785d59 | 232 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 233 | * @returns 1 if bmp file was found and painted |
2018US_EminaTahirovi | 0:1b3481785d59 | 234 | * @returns 0 if bmp file was found not found |
2018US_EminaTahirovi | 0:1b3481785d59 | 235 | * @returns -1 if file is no bmp |
2018US_EminaTahirovi | 0:1b3481785d59 | 236 | * @returns -2 if bmp file is no 16 bit bmp |
2018US_EminaTahirovi | 0:1b3481785d59 | 237 | * @returns -3 if bmp file is to big for screen |
2018US_EminaTahirovi | 0:1b3481785d59 | 238 | * @returns -4 if buffer malloc go wrong |
2018US_EminaTahirovi | 0:1b3481785d59 | 239 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 240 | * bitmap format: 16 bit R5 G6 B5 |
2018US_EminaTahirovi | 0:1b3481785d59 | 241 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 242 | * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 |
2018US_EminaTahirovi | 0:1b3481785d59 | 243 | * copy to internal file system or SD card |
2018US_EminaTahirovi | 0:1b3481785d59 | 244 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 245 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 246 | int BMP_16(unsigned int x, unsigned int y, const char *Name_BMP); |
2018US_EminaTahirovi | 0:1b3481785d59 | 247 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 248 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 249 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 250 | /** select the font to use |
2018US_EminaTahirovi | 0:1b3481785d59 | 251 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 252 | * @param f pointer to font array |
2018US_EminaTahirovi | 0:1b3481785d59 | 253 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 254 | * font array can created with GLCD Font Creator from http://www.mikroe.com |
2018US_EminaTahirovi | 0:1b3481785d59 | 255 | * you have to add 4 parameter at the beginning of the font array to use: |
2018US_EminaTahirovi | 0:1b3481785d59 | 256 | * - the number of byte / char |
2018US_EminaTahirovi | 0:1b3481785d59 | 257 | * - the vertial size in pixel |
2018US_EminaTahirovi | 0:1b3481785d59 | 258 | * - the horizontal size in pixel |
2018US_EminaTahirovi | 0:1b3481785d59 | 259 | * - the number of byte per vertical line |
2018US_EminaTahirovi | 0:1b3481785d59 | 260 | * you also have to change the array to char[] |
2018US_EminaTahirovi | 0:1b3481785d59 | 261 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 262 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 263 | void set_font(unsigned char* f); |
2018US_EminaTahirovi | 0:1b3481785d59 | 264 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 265 | /** Set the orientation of the screen |
2018US_EminaTahirovi | 0:1b3481785d59 | 266 | * x,y: 0,0 is always top left |
2018US_EminaTahirovi | 0:1b3481785d59 | 267 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 268 | * @param o direction to use the screen (0-3) |
2018US_EminaTahirovi | 0:1b3481785d59 | 269 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 270 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 271 | void set_orientation(unsigned int o); |
2018US_EminaTahirovi | 0:1b3481785d59 | 272 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 273 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 274 | /** read out the manufacturer ID of the LCD |
2018US_EminaTahirovi | 0:1b3481785d59 | 275 | * can used for checking the connection to the display |
2018US_EminaTahirovi | 0:1b3481785d59 | 276 | * @returns ID |
2018US_EminaTahirovi | 0:1b3481785d59 | 277 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 278 | int Read_ID(void); |
2018US_EminaTahirovi | 0:1b3481785d59 | 279 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 280 | DigitalOut _cs; |
2018US_EminaTahirovi | 0:1b3481785d59 | 281 | DigitalOut _reset; |
2018US_EminaTahirovi | 0:1b3481785d59 | 282 | DigitalOut _dc; |
2018US_EminaTahirovi | 0:1b3481785d59 | 283 | unsigned char* font; |
2018US_EminaTahirovi | 0:1b3481785d59 | 284 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 285 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 286 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 287 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 288 | protected: |
2018US_EminaTahirovi | 0:1b3481785d59 | 289 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 290 | /** Set draw window region to whole screen |
2018US_EminaTahirovi | 0:1b3481785d59 | 291 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 292 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 293 | void WindowMax (void); |
2018US_EminaTahirovi | 0:1b3481785d59 | 294 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 295 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 296 | /** draw a horizontal line |
2018US_EminaTahirovi | 0:1b3481785d59 | 297 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 298 | * @param x0 horizontal start |
2018US_EminaTahirovi | 0:1b3481785d59 | 299 | * @param x1 horizontal stop |
2018US_EminaTahirovi | 0:1b3481785d59 | 300 | * @param y vertical position |
2018US_EminaTahirovi | 0:1b3481785d59 | 301 | * @param color 16 bit color |
2018US_EminaTahirovi | 0:1b3481785d59 | 302 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 303 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 304 | void hline(int x0, int x1, int y, int colour); |
2018US_EminaTahirovi | 0:1b3481785d59 | 305 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 306 | /** draw a vertical line |
2018US_EminaTahirovi | 0:1b3481785d59 | 307 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 308 | * @param x horizontal position |
2018US_EminaTahirovi | 0:1b3481785d59 | 309 | * @param y0 vertical start |
2018US_EminaTahirovi | 0:1b3481785d59 | 310 | * @param y1 vertical stop |
2018US_EminaTahirovi | 0:1b3481785d59 | 311 | * @param color 16 bit color |
2018US_EminaTahirovi | 0:1b3481785d59 | 312 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 313 | void vline(int y0, int y1, int x, int colour); |
2018US_EminaTahirovi | 0:1b3481785d59 | 314 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 315 | /** Set draw window region |
2018US_EminaTahirovi | 0:1b3481785d59 | 316 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 317 | * @param x horizontal position |
2018US_EminaTahirovi | 0:1b3481785d59 | 318 | * @param y vertical position |
2018US_EminaTahirovi | 0:1b3481785d59 | 319 | * @param w window width in pixel |
2018US_EminaTahirovi | 0:1b3481785d59 | 320 | * @param h window height in pixels |
2018US_EminaTahirovi | 0:1b3481785d59 | 321 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 322 | virtual void window (unsigned int x,unsigned int y, unsigned int w, unsigned int h); |
2018US_EminaTahirovi | 0:1b3481785d59 | 323 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 324 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 325 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 326 | /** Init the ILI9341 controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 327 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 328 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 329 | void tft_reset(); |
2018US_EminaTahirovi | 0:1b3481785d59 | 330 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 331 | /** Write data to the LCD controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 332 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 333 | * @param dat data written to LCD controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 334 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 335 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 336 | //void wr_dat(unsigned int value); |
2018US_EminaTahirovi | 0:1b3481785d59 | 337 | void wr_dat(unsigned char value); |
2018US_EminaTahirovi | 0:1b3481785d59 | 338 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 339 | /** Write a command the LCD controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 340 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 341 | * @param cmd: command to be written |
2018US_EminaTahirovi | 0:1b3481785d59 | 342 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 343 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 344 | void wr_cmd(unsigned char value); |
2018US_EminaTahirovi | 0:1b3481785d59 | 345 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 346 | /** Start data sequence to the LCD controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 347 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 348 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 349 | //void wr_dat_start(); |
2018US_EminaTahirovi | 0:1b3481785d59 | 350 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 351 | /** Stop of data writing to the LCD controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 352 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 353 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 354 | //void wr_dat_stop(); |
2018US_EminaTahirovi | 0:1b3481785d59 | 355 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 356 | /** write data to the LCD controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 357 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 358 | * @param data to be written |
2018US_EminaTahirovi | 0:1b3481785d59 | 359 | * * |
2018US_EminaTahirovi | 0:1b3481785d59 | 360 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 361 | //void wr_dat_only(unsigned short dat); |
2018US_EminaTahirovi | 0:1b3481785d59 | 362 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 363 | /** Read byte from the LCD controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 364 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 365 | * @param cmd comand to controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 366 | * @returns data from LCD controller |
2018US_EminaTahirovi | 0:1b3481785d59 | 367 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 368 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 369 | char rd_byte(unsigned char cmd); |
2018US_EminaTahirovi | 0:1b3481785d59 | 370 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 371 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 372 | int rd_32(unsigned char cmd); |
2018US_EminaTahirovi | 0:1b3481785d59 | 373 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 374 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 375 | /** Write a value to the to a LCD register |
2018US_EminaTahirovi | 0:1b3481785d59 | 376 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 377 | * @param reg register to be written |
2018US_EminaTahirovi | 0:1b3481785d59 | 378 | * @param val data to be written |
2018US_EminaTahirovi | 0:1b3481785d59 | 379 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 380 | //void wr_reg (unsigned char reg, unsigned char val); |
2018US_EminaTahirovi | 0:1b3481785d59 | 381 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 382 | /** Read a LCD register |
2018US_EminaTahirovi | 0:1b3481785d59 | 383 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 384 | * @param reg register to be read |
2018US_EminaTahirovi | 0:1b3481785d59 | 385 | * @returns value of the register |
2018US_EminaTahirovi | 0:1b3481785d59 | 386 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 387 | //unsigned short rd_reg (unsigned char reg); |
2018US_EminaTahirovi | 0:1b3481785d59 | 388 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 389 | #if defined TARGET_NUCLEO_L152RE || defined TARGET_NUCLEO_F103RB || defined TARGET_LPC1768 |
2018US_EminaTahirovi | 0:1b3481785d59 | 390 | /** fast SPI write function for optimized versions |
2018US_EminaTahirovi | 0:1b3481785d59 | 391 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 392 | * @param data data written to SPI |
2018US_EminaTahirovi | 0:1b3481785d59 | 393 | * |
2018US_EminaTahirovi | 0:1b3481785d59 | 394 | */ |
2018US_EminaTahirovi | 0:1b3481785d59 | 395 | virtual void f_write(int data); |
2018US_EminaTahirovi | 0:1b3481785d59 | 396 | virtual void spi_bsy(void); |
2018US_EminaTahirovi | 0:1b3481785d59 | 397 | virtual void spi_16(bool s); |
2018US_EminaTahirovi | 0:1b3481785d59 | 398 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 399 | #endif |
2018US_EminaTahirovi | 0:1b3481785d59 | 400 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 401 | unsigned char spi_port; |
2018US_EminaTahirovi | 0:1b3481785d59 | 402 | unsigned int orientation; |
2018US_EminaTahirovi | 0:1b3481785d59 | 403 | unsigned int char_x; |
2018US_EminaTahirovi | 0:1b3481785d59 | 404 | unsigned int char_y; |
2018US_EminaTahirovi | 0:1b3481785d59 | 405 | unsigned char spi_num; |
2018US_EminaTahirovi | 0:1b3481785d59 | 406 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 407 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 408 | }; |
2018US_EminaTahirovi | 0:1b3481785d59 | 409 | |
2018US_EminaTahirovi | 0:1b3481785d59 | 410 | #endif |