Library for TFT via SPI

Dependents:   mbed_projekt_tetris Ejemplo_TFT

Committer:
2018US_HarisSoljic
Date:
Mon Jun 18 20:01:55 2018 +0000
Revision:
0:b8956708b92f
revi?n;

Who changed what in which revision?

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