Library to control a QVGA TFT connected to SPI. You can use printf to print text The lib can handle different fonts, draw lines, circles, rect and bmp

Dependents:   TFT_Test1 SourceCodePro31-SB Mandelbrot Mindwave-screen ... more

See http://mbed.org/cookbook/SPI-driven-QVGA-TFT for details.

Committer:
dreschpe
Date:
Mon Sep 10 19:23:26 2012 +0000
Revision:
0:de9d1462a835
Child:
1:17e12e4e149f
[mbed] converted /TFT/SPI_TFT

Who changed what in which revision?

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