Library for MI0283QT-2 LCD
MI0283QTlib.h@0:7ad454fed160, 2012-05-23 (annotated)
- Committer:
- clemente
- Date:
- Wed May 23 06:25:31 2012 +0000
- Revision:
- 0:7ad454fed160
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
clemente | 0:7ad454fed160 | 1 | /* mbed Graphics LCD library. Library for MI0283QT-2 screen. |
clemente | 0:7ad454fed160 | 2 | |
clemente | 0:7ad454fed160 | 3 | Copyright (c) 2011 NXP 3803 |
clemente | 0:7ad454fed160 | 4 | |
clemente | 0:7ad454fed160 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
clemente | 0:7ad454fed160 | 6 | of this software and associated documentation files (the "Software"), to deal |
clemente | 0:7ad454fed160 | 7 | in the Software without restriction, including without limitation the rights |
clemente | 0:7ad454fed160 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
clemente | 0:7ad454fed160 | 9 | copies of the Software, and to permit persons to whom the Software is |
clemente | 0:7ad454fed160 | 10 | furnished to do so, subject to the following conditions: |
clemente | 0:7ad454fed160 | 11 | |
clemente | 0:7ad454fed160 | 12 | The above copyright notice and this permission notice shall be included in |
clemente | 0:7ad454fed160 | 13 | all copies or substantial portions of the Software. |
clemente | 0:7ad454fed160 | 14 | |
clemente | 0:7ad454fed160 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
clemente | 0:7ad454fed160 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
clemente | 0:7ad454fed160 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
clemente | 0:7ad454fed160 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
clemente | 0:7ad454fed160 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
clemente | 0:7ad454fed160 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
clemente | 0:7ad454fed160 | 21 | THE SOFTWARE. |
clemente | 0:7ad454fed160 | 22 | */ |
clemente | 0:7ad454fed160 | 23 | |
clemente | 0:7ad454fed160 | 24 | #ifndef __MBED_GLCDLIB_H |
clemente | 0:7ad454fed160 | 25 | #define __MBED_GLCDLIB_H |
clemente | 0:7ad454fed160 | 26 | |
clemente | 0:7ad454fed160 | 27 | // Comment out if file system functions are not used. |
clemente | 0:7ad454fed160 | 28 | #define _USE_FILE |
clemente | 0:7ad454fed160 | 29 | |
clemente | 0:7ad454fed160 | 30 | #ifdef _USE_FILE |
clemente | 0:7ad454fed160 | 31 | #define BUFFER_LINE 10 |
clemente | 0:7ad454fed160 | 32 | #endif |
clemente | 0:7ad454fed160 | 33 | |
clemente | 0:7ad454fed160 | 34 | // |
clemente | 0:7ad454fed160 | 35 | #define LCD_BLACK (0) |
clemente | 0:7ad454fed160 | 36 | #define LCD_WHITE ( (255<<16)|(255<<8)|(255<<0) ) |
clemente | 0:7ad454fed160 | 37 | #define LCD_RED ( (255<<16)|(0<<8)|(0<<0) ) |
clemente | 0:7ad454fed160 | 38 | #define LCD_GREEN ( (0<<16)|(255<<8)|(0<<0) ) |
clemente | 0:7ad454fed160 | 39 | #define LCD_BLUE ( (0<<16)|(0<<8)|(255<<0) ) |
clemente | 0:7ad454fed160 | 40 | // |
clemente | 0:7ad454fed160 | 41 | #define SCALE_320x240 1 |
clemente | 0:7ad454fed160 | 42 | #define SCALE_160x120 2 |
clemente | 0:7ad454fed160 | 43 | // |
clemente | 0:7ad454fed160 | 44 | #include "mbed.h" |
clemente | 0:7ad454fed160 | 45 | |
clemente | 0:7ad454fed160 | 46 | struct _FONTINFO { |
clemente | 0:7ad454fed160 | 47 | unsigned char *pText; |
clemente | 0:7ad454fed160 | 48 | unsigned int h_size; |
clemente | 0:7ad454fed160 | 49 | unsigned int v_size; |
clemente | 0:7ad454fed160 | 50 | unsigned int h_line; |
clemente | 0:7ad454fed160 | 51 | }; |
clemente | 0:7ad454fed160 | 52 | |
clemente | 0:7ad454fed160 | 53 | |
clemente | 0:7ad454fed160 | 54 | /** Graphic LCD Library for MI0283QT-2 LCD |
clemente | 0:7ad454fed160 | 55 | * |
clemente | 0:7ad454fed160 | 56 | * Image Format. |
clemente | 0:7ad454fed160 | 57 | * About image format, I choose the way to make the library capable to read the simple RGB format. |
clemente | 0:7ad454fed160 | 58 | * That's: a file with RGB bytes written. This format is very simple to obtain, using the convert.exe software. |
clemente | 0:7ad454fed160 | 59 | * This program is inside the "Imagemagick" installation software. You can download the portable versio for windows |
clemente | 0:7ad454fed160 | 60 | * at this link: http://www.imagemagick.org/download/binaries/ImageMagick-6.6.7-Q16-windows.zip |
clemente | 0:7ad454fed160 | 61 | * |
clemente | 0:7ad454fed160 | 62 | * Icone Format. |
clemente | 0:7ad454fed160 | 63 | * I use some free icons from Internet. I use the bin2h utility to convert this file to .h format. |
clemente | 0:7ad454fed160 | 64 | * (http://www.deadnode.org/sw/bin2h/) |
clemente | 0:7ad454fed160 | 65 | * |
clemente | 0:7ad454fed160 | 66 | * Example: |
clemente | 0:7ad454fed160 | 67 | * @code |
clemente | 0:7ad454fed160 | 68 | * // Init code... |
clemente | 0:7ad454fed160 | 69 | * #include "mbed.h" |
clemente | 0:7ad454fed160 | 70 | * #include "GLCDlib.h" |
clemente | 0:7ad454fed160 | 71 | * |
clemente | 0:7ad454fed160 | 72 | * // Configure the GLCD pin: |
clemente | 0:7ad454fed160 | 73 | * // mosi, miso, clk, cs, rst, bklgh |
clemente | 0:7ad454fed160 | 74 | * GLCD lcd( p11, p12, p13, p14, p17, p26); |
clemente | 0:7ad454fed160 | 75 | * |
clemente | 0:7ad454fed160 | 76 | * int main() { |
clemente | 0:7ad454fed160 | 77 | * |
clemente | 0:7ad454fed160 | 78 | * lcd.lcd_init(); |
clemente | 0:7ad454fed160 | 79 | * lcd.backlightoff(); |
clemente | 0:7ad454fed160 | 80 | * //... do somethings... |
clemente | 0:7ad454fed160 | 81 | * lcd.lcd_clear( LCD_WHITE); |
clemente | 0:7ad454fed160 | 82 | * lcd.backlighton(); |
clemente | 0:7ad454fed160 | 83 | * //... the LCD is ON |
clemente | 0:7ad454fed160 | 84 | * } |
clemente | 0:7ad454fed160 | 85 | * @endcode |
clemente | 0:7ad454fed160 | 86 | |
clemente | 0:7ad454fed160 | 87 | */ |
clemente | 0:7ad454fed160 | 88 | |
clemente | 0:7ad454fed160 | 89 | class GLCD { |
clemente | 0:7ad454fed160 | 90 | |
clemente | 0:7ad454fed160 | 91 | public: |
clemente | 0:7ad454fed160 | 92 | /** Create the GLCD Object and initlaize the I/O pins |
clemente | 0:7ad454fed160 | 93 | * |
clemente | 0:7ad454fed160 | 94 | * @param pin mosi, pin miso, pin sclk, pin cs, pin LCD_reset, pin LCD_backlight |
clemente | 0:7ad454fed160 | 95 | */ |
clemente | 0:7ad454fed160 | 96 | GLCD( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rst, PinName bklgh); |
clemente | 0:7ad454fed160 | 97 | |
clemente | 0:7ad454fed160 | 98 | /** Configure the SPI port with default parameters. |
clemente | 0:7ad454fed160 | 99 | * |
clemente | 0:7ad454fed160 | 100 | * @param none |
clemente | 0:7ad454fed160 | 101 | */ |
clemente | 0:7ad454fed160 | 102 | void lcd_init( void); |
clemente | 0:7ad454fed160 | 103 | |
clemente | 0:7ad454fed160 | 104 | /** Initialize the LCD with an optional SPI freq. Used as FastSpeed |
clemente | 0:7ad454fed160 | 105 | * |
clemente | 0:7ad454fed160 | 106 | * @param clock speed in Hz |
clemente | 0:7ad454fed160 | 107 | */ |
clemente | 0:7ad454fed160 | 108 | void lcd_init( unsigned speedf); |
clemente | 0:7ad454fed160 | 109 | |
clemente | 0:7ad454fed160 | 110 | /** Initialize the LCD with two optionals SPI freq: fast and slow speed. |
clemente | 0:7ad454fed160 | 111 | * |
clemente | 0:7ad454fed160 | 112 | * @param speedf The fast freq. used to drive the GLCD |
clemente | 0:7ad454fed160 | 113 | * @param speeds The freq. at wich the SPI is configured after the use. |
clemente | 0:7ad454fed160 | 114 | * |
clemente | 0:7ad454fed160 | 115 | */ |
clemente | 0:7ad454fed160 | 116 | void lcd_init( unsigned int speedf, unsigned int speeds); |
clemente | 0:7ad454fed160 | 117 | |
clemente | 0:7ad454fed160 | 118 | /** Clear the entire screen with color |
clemente | 0:7ad454fed160 | 119 | * |
clemente | 0:7ad454fed160 | 120 | * #param color The color we want to use to fill the screen |
clemente | 0:7ad454fed160 | 121 | */ |
clemente | 0:7ad454fed160 | 122 | void lcd_clear(unsigned int color); |
clemente | 0:7ad454fed160 | 123 | |
clemente | 0:7ad454fed160 | 124 | /** Clear a specified screen region. Like as a rectangle fill |
clemente | 0:7ad454fed160 | 125 | * @param x0 start x position |
clemente | 0:7ad454fed160 | 126 | * @param y0 start y position |
clemente | 0:7ad454fed160 | 127 | * @param w rectangle width |
clemente | 0:7ad454fed160 | 128 | * @param h rectangle hight |
clemente | 0:7ad454fed160 | 129 | * @param color The color we use to fill the area. |
clemente | 0:7ad454fed160 | 130 | * |
clemente | 0:7ad454fed160 | 131 | */ |
clemente | 0:7ad454fed160 | 132 | void lcd_clear(unsigned int x0, unsigned int y0, unsigned int w, unsigned int h, unsigned int color); |
clemente | 0:7ad454fed160 | 133 | |
clemente | 0:7ad454fed160 | 134 | #ifdef _USE_FILE |
clemente | 0:7ad454fed160 | 135 | /** Draw an RGB image file (320x240) starting at x=0, y=0 |
clemente | 0:7ad454fed160 | 136 | * The image is read byte per byte. So use this function if you don't care about speed |
clemente | 0:7ad454fed160 | 137 | * |
clemente | 0:7ad454fed160 | 138 | * @param fname The file name we want to display |
clemente | 0:7ad454fed160 | 139 | */ |
clemente | 0:7ad454fed160 | 140 | unsigned int lcd_drawimage(char *fname); |
clemente | 0:7ad454fed160 | 141 | |
clemente | 0:7ad454fed160 | 142 | /** Draw an RGB image file (320x240) starting at x=0, y=0 |
clemente | 0:7ad454fed160 | 143 | * The image is read using a buffer. You can set the buffer using the define: BUFFER_LINE |
clemente | 0:7ad454fed160 | 144 | * This procedure speedup the draw of the image. At the cost of more RAM. |
clemente | 0:7ad454fed160 | 145 | * The defaullt buffer size is: 320*BUFFER_LINE*3 |
clemente | 0:7ad454fed160 | 146 | * |
clemente | 0:7ad454fed160 | 147 | * @param fname The file name we want to display |
clemente | 0:7ad454fed160 | 148 | */ |
clemente | 0:7ad454fed160 | 149 | unsigned int lcd_drawimagebuff(char *fname); |
clemente | 0:7ad454fed160 | 150 | |
clemente | 0:7ad454fed160 | 151 | /** Draw an image file (320x240) staring at x=0, y=0 |
clemente | 0:7ad454fed160 | 152 | * The image is displayed line-by-line so the main program can do other jobs between the call. |
clemente | 0:7ad454fed160 | 153 | * The buffer size is equivalent to a LCD line, so must be: 320x3 bytes. |
clemente | 0:7ad454fed160 | 154 | * |
clemente | 0:7ad454fed160 | 155 | * @param buffer The pointer at the data to be displayed |
clemente | 0:7ad454fed160 | 156 | * @param lnum The number of the line to display. From 0 to 239. |
clemente | 0:7ad454fed160 | 157 | */ |
clemente | 0:7ad454fed160 | 158 | unsigned int lcd_drawimagebyline(unsigned char *buffer, unsigned int lnum); |
clemente | 0:7ad454fed160 | 159 | |
clemente | 0:7ad454fed160 | 160 | /** Draw an image file (less then 320x240) specifying the x and y position and the scale value. |
clemente | 0:7ad454fed160 | 161 | * The image is displayed line-by-line so the main program can do other job during the call. |
clemente | 0:7ad454fed160 | 162 | * It is possible to specify a x and y starting position and a scale value. |
clemente | 0:7ad454fed160 | 163 | * The buffer size is equivalent to a LCD line, so must be: 320x3 bytes. |
clemente | 0:7ad454fed160 | 164 | * |
clemente | 0:7ad454fed160 | 165 | * @param buffer The pointer at the data to be displayed |
clemente | 0:7ad454fed160 | 166 | * @param lnum The number of the line to display. From 0 to 239. |
clemente | 0:7ad454fed160 | 167 | * @param xstart x position |
clemente | 0:7ad454fed160 | 168 | * @param ystart y position |
clemente | 0:7ad454fed160 | 169 | * @param scale Scale factor value. There are two value defined: SCALE_320x240 and SCALE_160x120 |
clemente | 0:7ad454fed160 | 170 | * Using the second value it's possible to draw, from a 320x240 image, a 160x120 image. |
clemente | 0:7ad454fed160 | 171 | * at the xy specified. This is the only value supported for now. |
clemente | 0:7ad454fed160 | 172 | */ |
clemente | 0:7ad454fed160 | 173 | unsigned int lcd_drawimagebyline(unsigned char *buffer, unsigned int lnum, unsigned int xstart, unsigned int ystart, unsigned int scale); |
clemente | 0:7ad454fed160 | 174 | |
clemente | 0:7ad454fed160 | 175 | /** Play a movie file 80x60 pixel. |
clemente | 0:7ad454fed160 | 176 | * The file is a ready-made array of pictures extracted from a movie, resized to 80x60 and converted to RGB format. |
clemente | 0:7ad454fed160 | 177 | * I use this procedure in a Ubuntu Linux PC: |
clemente | 0:7ad454fed160 | 178 | * |
clemente | 0:7ad454fed160 | 179 | * @code |
clemente | 0:7ad454fed160 | 180 | * mplayer -endpos 10 -nosound -vo png:z=0 perla.avi |
clemente | 0:7ad454fed160 | 181 | * mogrify -resize 80x60 *.png |
clemente | 0:7ad454fed160 | 182 | * mogrify -format rgb *.png |
clemente | 0:7ad454fed160 | 183 | * cat *.rgb > unico_80x60.bin |
clemente | 0:7ad454fed160 | 184 | * @endcode |
clemente | 0:7ad454fed160 | 185 | * |
clemente | 0:7ad454fed160 | 186 | * First I convert 10 sec of my avi files with mplayer, then I use mogrify to resize the 150 images to 80x60 pixel. |
clemente | 0:7ad454fed160 | 187 | * The next step is to convert the PNG format to RGB. At this point I create a single file using a simple cat command. |
clemente | 0:7ad454fed160 | 188 | * With this little format there is enough speed to play the movie at 15fps. |
clemente | 0:7ad454fed160 | 189 | */ |
clemente | 0:7ad454fed160 | 190 | unsigned int lcd_drawmovie(char *fname, unsigned int x_start, unsigned int y_start); |
clemente | 0:7ad454fed160 | 191 | |
clemente | 0:7ad454fed160 | 192 | /** Play a 160x120 pixel ready made movie file. |
clemente | 0:7ad454fed160 | 193 | * The file is a ready-made array of pictures extracted from a movie, resized to 160x120 pixel and converted to RGB format. |
clemente | 0:7ad454fed160 | 194 | * I use this procedure in a Ubuntu Linux PC: |
clemente | 0:7ad454fed160 | 195 | * |
clemente | 0:7ad454fed160 | 196 | * @code |
clemente | 0:7ad454fed160 | 197 | * mplayer -endpos 10 -nosound -vo png:z=0 perla.avi |
clemente | 0:7ad454fed160 | 198 | * mogrify -resize 160x120 *.png |
clemente | 0:7ad454fed160 | 199 | * mogrify -format rgb *.png |
clemente | 0:7ad454fed160 | 200 | * cat *.rgb > unico_160x120.bin |
clemente | 0:7ad454fed160 | 201 | * RGBconv_tst unico_160x120.bin unico_160x120_lcd.bin |
clemente | 0:7ad454fed160 | 202 | * @endcode |
clemente | 0:7ad454fed160 | 203 | * |
clemente | 0:7ad454fed160 | 204 | * First I convert 10 sec of my avi files with mplayer, then I use mogrify to resize the 150 images generated to 160x120 pixel. |
clemente | 0:7ad454fed160 | 205 | * The next step is to convert the PNG format to RGB. At this point I create a single file using a simple cat command. |
clemente | 0:7ad454fed160 | 206 | * To speed up the playing procedure, I convert the RGB 24bit file to the LCD format RGB 565bit using a simple programm |
clemente | 0:7ad454fed160 | 207 | * I create. |
clemente | 0:7ad454fed160 | 208 | * The procedure use the USB and Ethernet memory area as a ping pong buffer. The buffer loaded from the SDCard is send to the LCD using the DMA. |
clemente | 0:7ad454fed160 | 209 | * During this time another buffer is read and stored to the second buffer. The single DMA transfer is too short for me and I use 3 linked list |
clemente | 0:7ad454fed160 | 210 | * to chain 3 buffer of memory and send simultaneously more then 12KB if data. |
clemente | 0:7ad454fed160 | 211 | * |
clemente | 0:7ad454fed160 | 212 | * @param fname the file name to display |
clemente | 0:7ad454fed160 | 213 | * @param x_start and y_start, the x and y position where to display the movie. |
clemente | 0:7ad454fed160 | 214 | */ |
clemente | 0:7ad454fed160 | 215 | unsigned int lcd_drawmoviebuff(char *fname, unsigned int x_start, unsigned int y_start); |
clemente | 0:7ad454fed160 | 216 | |
clemente | 0:7ad454fed160 | 217 | #endif // End of: #ifdef _USE_FILE |
clemente | 0:7ad454fed160 | 218 | |
clemente | 0:7ad454fed160 | 219 | /** Draw an RGB icon at x, y. The size is specified for width and hight. |
clemente | 0:7ad454fed160 | 220 | * |
clemente | 0:7ad454fed160 | 221 | * @param *icon pointer at the array with the RGB value in integer format. That is: 0x00RRGGBB |
clemente | 0:7ad454fed160 | 222 | * @param x x position |
clemente | 0:7ad454fed160 | 223 | * @param y y position |
clemente | 0:7ad454fed160 | 224 | * @param size the width and height |
clemente | 0:7ad454fed160 | 225 | */ |
clemente | 0:7ad454fed160 | 226 | void lcd_drawicon( const unsigned int *icon, unsigned int x, unsigned int y, unsigned int size); |
clemente | 0:7ad454fed160 | 227 | |
clemente | 0:7ad454fed160 | 228 | /** Draw an RGB icon at x, y. The size is specified for width and hight. |
clemente | 0:7ad454fed160 | 229 | * |
clemente | 0:7ad454fed160 | 230 | * @param *icon pointer at the array with the RGB value in byte format. That is: 0xRR, 0xGG, 0xBB |
clemente | 0:7ad454fed160 | 231 | * @param x x position |
clemente | 0:7ad454fed160 | 232 | * @param y y position |
clemente | 0:7ad454fed160 | 233 | * @param size the width and height |
clemente | 0:7ad454fed160 | 234 | */ |
clemente | 0:7ad454fed160 | 235 | void lcd_drawicon( const unsigned char *icon, unsigned int x, unsigned int y, unsigned int size); |
clemente | 0:7ad454fed160 | 236 | |
clemente | 0:7ad454fed160 | 237 | /** Draw an RGB icon at x, y. The size is specified for width and hight. |
clemente | 0:7ad454fed160 | 238 | * |
clemente | 0:7ad454fed160 | 239 | * @param *icon pointer at the array with the RGB value in byte format. That is: 0xRR, 0xGG, 0xBB |
clemente | 0:7ad454fed160 | 240 | * @param x x position |
clemente | 0:7ad454fed160 | 241 | * @param y y position |
clemente | 0:7ad454fed160 | 242 | * @param xsize the width |
clemente | 0:7ad454fed160 | 243 | * @param ysize the height |
clemente | 0:7ad454fed160 | 244 | */ |
clemente | 0:7ad454fed160 | 245 | void lcd_drawicon( const unsigned char *icon, unsigned int x, unsigned int y, unsigned int xsize, unsigned int ysize); |
clemente | 0:7ad454fed160 | 246 | |
clemente | 0:7ad454fed160 | 247 | /** Draw a color line from xy to xy |
clemente | 0:7ad454fed160 | 248 | * |
clemente | 0:7ad454fed160 | 249 | * @param x0 x position |
clemente | 0:7ad454fed160 | 250 | * @param y0 y position |
clemente | 0:7ad454fed160 | 251 | * @param x1 x position |
clemente | 0:7ad454fed160 | 252 | * @param y1 y position |
clemente | 0:7ad454fed160 | 253 | * @param color color to use |
clemente | 0:7ad454fed160 | 254 | */ |
clemente | 0:7ad454fed160 | 255 | void lcd_drawline(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, unsigned int color); |
clemente | 0:7ad454fed160 | 256 | |
clemente | 0:7ad454fed160 | 257 | /** Draw a single pixel |
clemente | 0:7ad454fed160 | 258 | * |
clemente | 0:7ad454fed160 | 259 | * @param x0 x position |
clemente | 0:7ad454fed160 | 260 | * @param y0 y position |
clemente | 0:7ad454fed160 | 261 | * @param color color to use |
clemente | 0:7ad454fed160 | 262 | */ |
clemente | 0:7ad454fed160 | 263 | void lcd_drawpixel(unsigned int x0, unsigned int y0, unsigned int color); |
clemente | 0:7ad454fed160 | 264 | |
clemente | 0:7ad454fed160 | 265 | /** Draw a character at xy position. |
clemente | 0:7ad454fed160 | 266 | * |
clemente | 0:7ad454fed160 | 267 | * @param ch the character to draw |
clemente | 0:7ad454fed160 | 268 | * @param xpos x position |
clemente | 0:7ad454fed160 | 269 | * @param ypos y position |
clemente | 0:7ad454fed160 | 270 | * @param color the color to use |
clemente | 0:7ad454fed160 | 271 | */ |
clemente | 0:7ad454fed160 | 272 | void lcd_drawch( unsigned ch, unsigned int xpos, unsigned int ypos, unsigned int color); |
clemente | 0:7ad454fed160 | 273 | |
clemente | 0:7ad454fed160 | 274 | /** Draw a string at xy position |
clemente | 0:7ad454fed160 | 275 | * |
clemente | 0:7ad454fed160 | 276 | * @param *putstr the string to draw |
clemente | 0:7ad454fed160 | 277 | * @param xpos x position |
clemente | 0:7ad454fed160 | 278 | * @param ypos y position |
clemente | 0:7ad454fed160 | 279 | * @param color the color to use |
clemente | 0:7ad454fed160 | 280 | */ |
clemente | 0:7ad454fed160 | 281 | void lcd_drawstr(char *__putstr, unsigned int xpos, unsigned int ypos, unsigned int color); |
clemente | 0:7ad454fed160 | 282 | |
clemente | 0:7ad454fed160 | 283 | /** Set the font type to small: 12x6 |
clemente | 0:7ad454fed160 | 284 | */ |
clemente | 0:7ad454fed160 | 285 | void lcd_setfontsmall( void); |
clemente | 0:7ad454fed160 | 286 | |
clemente | 0:7ad454fed160 | 287 | /** Set the font type to big: 24x12 |
clemente | 0:7ad454fed160 | 288 | */ |
clemente | 0:7ad454fed160 | 289 | void lcd_setfontbig( void); |
clemente | 0:7ad454fed160 | 290 | |
clemente | 0:7ad454fed160 | 291 | /** Return the color value use by the LCD. There are two form: 666 and 565 |
clemente | 0:7ad454fed160 | 292 | * |
clemente | 0:7ad454fed160 | 293 | * @param color the color in the format: 0x00RRGGBB |
clemente | 0:7ad454fed160 | 294 | * @return the color in the format: 666 or 565 |
clemente | 0:7ad454fed160 | 295 | */ |
clemente | 0:7ad454fed160 | 296 | unsigned int lcd_RGB( unsigned int color); |
clemente | 0:7ad454fed160 | 297 | |
clemente | 0:7ad454fed160 | 298 | /** Return the color value use by the LCD. There are two form: 666 and 565 |
clemente | 0:7ad454fed160 | 299 | * |
clemente | 0:7ad454fed160 | 300 | * @param r the Red color value |
clemente | 0:7ad454fed160 | 301 | * @param g the Green color value |
clemente | 0:7ad454fed160 | 302 | * @param b the Blue color value |
clemente | 0:7ad454fed160 | 303 | * @return the color in the format: 666 or 565 |
clemente | 0:7ad454fed160 | 304 | */ |
clemente | 0:7ad454fed160 | 305 | unsigned int lcd_RGB( unsigned int r, unsigned int g, unsigned int b); |
clemente | 0:7ad454fed160 | 306 | |
clemente | 0:7ad454fed160 | 307 | /** Set the background color |
clemente | 0:7ad454fed160 | 308 | * |
clemente | 0:7ad454fed160 | 309 | * @param color the color of the background |
clemente | 0:7ad454fed160 | 310 | */ |
clemente | 0:7ad454fed160 | 311 | void lcd_setbackgroundcolor( unsigned int color); |
clemente | 0:7ad454fed160 | 312 | |
clemente | 0:7ad454fed160 | 313 | /** Function to start the automated scroll of the screen |
clemente | 0:7ad454fed160 | 314 | */ |
clemente | 0:7ad454fed160 | 315 | void lcd_setverticalarea( unsigned int topf, unsigned int height, unsigned int butf); |
clemente | 0:7ad454fed160 | 316 | void lcd_scrollstartadd( unsigned int ssa); |
clemente | 0:7ad454fed160 | 317 | void lcd_scrollstart( void); |
clemente | 0:7ad454fed160 | 318 | void lcd_scrollstop( void); |
clemente | 0:7ad454fed160 | 319 | |
clemente | 0:7ad454fed160 | 320 | /** Set the backlight ON |
clemente | 0:7ad454fed160 | 321 | * |
clemente | 0:7ad454fed160 | 322 | */ |
clemente | 0:7ad454fed160 | 323 | void backlighton( void); |
clemente | 0:7ad454fed160 | 324 | |
clemente | 0:7ad454fed160 | 325 | /** Set the backlight OFF |
clemente | 0:7ad454fed160 | 326 | * |
clemente | 0:7ad454fed160 | 327 | */ |
clemente | 0:7ad454fed160 | 328 | void backlightoff( void); |
clemente | 0:7ad454fed160 | 329 | |
clemente | 0:7ad454fed160 | 330 | /** Set the backlight at a particular value. |
clemente | 0:7ad454fed160 | 331 | * |
clemente | 0:7ad454fed160 | 332 | * @param val backlight value to set. |
clemente | 0:7ad454fed160 | 333 | */ |
clemente | 0:7ad454fed160 | 334 | void backlightset( double val); |
clemente | 0:7ad454fed160 | 335 | |
clemente | 0:7ad454fed160 | 336 | protected: |
clemente | 0:7ad454fed160 | 337 | void lcd_draw(unsigned int color); |
clemente | 0:7ad454fed160 | 338 | void lcd_drawstop(void); |
clemente | 0:7ad454fed160 | 339 | void lcd_drawstart(void); |
clemente | 0:7ad454fed160 | 340 | void lcd_cmd(unsigned int reg, unsigned int param); |
clemente | 0:7ad454fed160 | 341 | void lcd_data(unsigned int c); |
clemente | 0:7ad454fed160 | 342 | void lcd_area(unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1); |
clemente | 0:7ad454fed160 | 343 | void lcd_reset(void); |
clemente | 0:7ad454fed160 | 344 | |
clemente | 0:7ad454fed160 | 345 | // default value for SPIClock speed, SPI mode and backlight freq. |
clemente | 0:7ad454fed160 | 346 | unsigned int SPIClkSpeed; |
clemente | 0:7ad454fed160 | 347 | unsigned int SPISlowClkSpeed; |
clemente | 0:7ad454fed160 | 348 | unsigned int SPIMode; |
clemente | 0:7ad454fed160 | 349 | double LCDBkLight; |
clemente | 0:7ad454fed160 | 350 | // default value for background color |
clemente | 0:7ad454fed160 | 351 | unsigned int BackGroundColor; |
clemente | 0:7ad454fed160 | 352 | // |
clemente | 0:7ad454fed160 | 353 | unsigned char FontIdx; |
clemente | 0:7ad454fed160 | 354 | _FONTINFO FontInfo[2]; |
clemente | 0:7ad454fed160 | 355 | |
clemente | 0:7ad454fed160 | 356 | SPI _spi; |
clemente | 0:7ad454fed160 | 357 | DigitalOut _cs; |
clemente | 0:7ad454fed160 | 358 | DigitalOut _rst; |
clemente | 0:7ad454fed160 | 359 | PwmOut _bklgh; |
clemente | 0:7ad454fed160 | 360 | |
clemente | 0:7ad454fed160 | 361 | }; |
clemente | 0:7ad454fed160 | 362 | |
clemente | 0:7ad454fed160 | 363 | #endif |