Displays a large title and some small text with a blue rectangle Constantly refreshes 3 variable values on the screen. NO TOUCH SUPPORT AS OF YET

Dependencies:   mbed

Committer:
EmbeddedSam
Date:
Sat Dec 05 23:41:01 2015 +0000
Revision:
0:38cf064697d7
First commit, working with displaying messages; no touch support as of yet

Who changed what in which revision?

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