Added Discovery F429ZI 8 bit SPI support. Added helper methods to character based locate.

Fork of SPI_TFT_ILI9341 by Peter Drescher

Added Discovery F429ZI 8 bit SPI support to the original lib.

Committer:
vargham
Date:
Sat Feb 11 18:56:31 2017 +0000
Revision:
14:a1133923c034
Parent:
13:b2b3e5430f81
Child:
15:b7848705d2ab
Added Discovery F429ZI 8 bit SPI support.; Added helper methods to locate chars.

Who changed what in which revision?

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