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

Committer:
dreschpe
Date:
Wed Aug 31 20:51:14 2011 +0000
Revision:
6:fc33e4a5713e
Parent:
5:2db1b8070d94
Child:
8:e1f5232d93a0
fix padding bug for bmp arrays

Who changed what in which revision?

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