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:
Fri Oct 12 10:03:42 2012 +0000
Revision:
7:e753bb62eeb9
Parent:
1:17e12e4e149f
Child:
8:65a4de035c3c
Fix SPI1 connection.; Thanks to Hans Bergles

Who changed what in which revision?

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