Committer:
apm_litoral
Date:
Tue Apr 10 03:33:49 2012 +0000
Revision:
0:ea1b1135bb4e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apm_litoral 0:ea1b1135bb4e 1 #ifndef MBED_SPI_TFT_H
apm_litoral 0:ea1b1135bb4e 2 #define MBED_SPI_TFT_H
apm_litoral 0:ea1b1135bb4e 3
apm_litoral 0:ea1b1135bb4e 4
apm_litoral 0:ea1b1135bb4e 5 #include "mbed.h"
apm_litoral 0:ea1b1135bb4e 6 #include "GraphicsDisplay.h"
apm_litoral 0:ea1b1135bb4e 7
apm_litoral 0:ea1b1135bb4e 8 extern "C" void mbed_reset();
apm_litoral 0:ea1b1135bb4e 9
apm_litoral 0:ea1b1135bb4e 10 #define RGB(r,g,b) (((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3)) //5 red | 6 green | 5 blue
apm_litoral 0:ea1b1135bb4e 11
apm_litoral 0:ea1b1135bb4e 12 #define SPI_START (0x70) /* Start byte for SPI transfer */
apm_litoral 0:ea1b1135bb4e 13 #define SPI_RD (0x01) /* WR bit 1 within start */
apm_litoral 0:ea1b1135bb4e 14 #define SPI_WR (0x00) /* WR bit 0 within start */
apm_litoral 0:ea1b1135bb4e 15 #define SPI_DATA (0x02) /* RS bit 1 within start byte */
apm_litoral 0:ea1b1135bb4e 16 #define SPI_INDEX (0x00) /* RS bit 0 within start byte */
apm_litoral 0:ea1b1135bb4e 17
apm_litoral 0:ea1b1135bb4e 18
apm_litoral 0:ea1b1135bb4e 19 /* some RGB color definitions
apm_litoral 0:ea1b1135bb4e 20 # Define RGB565CONVERT NEGRO ( 0 , 0 , 0 )
apm_litoral 0:ea1b1135bb4e 21 # Define RGB565CONVERT BRIGHTBLUE ( 0 , 0 , 255 )
apm_litoral 0:ea1b1135bb4e 22 # Define RGB565CONVERT BRIGHTGREEN ( 0 , 255 , 0 )
apm_litoral 0:ea1b1135bb4e 23 # Define RGB565CONVERT BRIGHTCYAN ( 0 , 255 , 255 )
apm_litoral 0:ea1b1135bb4e 24 # Define RGB565CONVERT BRIGHTRED ( 255 , 0 , 0 )
apm_litoral 0:ea1b1135bb4e 25 # Define RGB565CONVERT BRIGHTMAGENTA ( 255 , 0 , 255 )
apm_litoral 0:ea1b1135bb4e 26 # Define RGB565CONVERT BRIGHTYELLOW ( 255 , 255 , 0 )
apm_litoral 0:ea1b1135bb4e 27 # Define RGB565CONVERT AZUL ( 0 , 0 , 128 )
apm_litoral 0:ea1b1135bb4e 28 # Define RGB565CONVERT VERDE ( 0 , 128 , 0 )
apm_litoral 0:ea1b1135bb4e 29 # Define RGB565CONVERT CIAN ( 0 , 128 , 128 )
apm_litoral 0:ea1b1135bb4e 30 # Define RGB565CONVERT ROJO ( 128 , 0 , 0 )
apm_litoral 0:ea1b1135bb4e 31 # Define MAGENTA RGB565CONVERT ( 128 , 0 , 128 )
apm_litoral 0:ea1b1135bb4e 32 # Define RGB565CONVERT BROWN ( 255 , 128 , 0 )
apm_litoral 0:ea1b1135bb4e 33 # Define RGB565CONVERT gris_claro ( 128 , 128 , 128 )
apm_litoral 0:ea1b1135bb4e 34 # Define RGB565CONVERT gris_oscuro ( 64 , 64 , 64 )
apm_litoral 0:ea1b1135bb4e 35 # Define RGB565CONVERT lightblue ( 128 , 128 , 255 )
apm_litoral 0:ea1b1135bb4e 36 # Define RGB565CONVERT verde claro ( 128 , 255 , 128 )
apm_litoral 0:ea1b1135bb4e 37 # Define RGB565CONVERT LIGHTCYAN ( 128 , 255 , 255 )
apm_litoral 0:ea1b1135bb4e 38 # Define RGB565CONVERT LIGHTRED ( 255 , 128 , 128 )
apm_litoral 0:ea1b1135bb4e 39 # Define RGB565CONVERT LIGHTMAGENTA ( 255 , 128 , 255 )
apm_litoral 0:ea1b1135bb4e 40 # Define RGB565CONVERT AMARILLO ( 255 , 255 , 128 )
apm_litoral 0:ea1b1135bb4e 41 # Define RGB565CONVERT BLANCO ( 255 , 255 , 255 )
apm_litoral 0:ea1b1135bb4e 42
apm_litoral 0:ea1b1135bb4e 43 # Define GRAY0 RGB565CONVERT ( 224 , 224 , 224 )
apm_litoral 0:ea1b1135bb4e 44 # Define GRAY1 RGB565CONVERT ( 192 , 192 , 192 )
apm_litoral 0:ea1b1135bb4e 45 # Define GRAY2 RGB565CONVERT ( 160 , 160 , 160 )
apm_litoral 0:ea1b1135bb4e 46 # Define GRAY3 RGB565CONVERT ( 128 , 128 , 128 )
apm_litoral 0:ea1b1135bb4e 47 # Define GRAY4 RGB565CONVERT ( 96 , 96 , 96 )
apm_litoral 0:ea1b1135bb4e 48 # Define GRAY5 RGB565CONVERT ( 64 , 64 , 64 )
apm_litoral 0:ea1b1135bb4e 49 # Define GRAY6 RGB565CONVERT ( 32 , 32 , 32 )
apm_litoral 0:ea1b1135bb4e 50
apm_litoral 0:ea1b1135bb4e 51 #define GRAY20 RGB565CONVERT(51, 51, 51)
apm_litoral 0:ea1b1135bb4e 52 #define GRAY40 RGB565CONVERT(102, 102, 102)
apm_litoral 0:ea1b1135bb4e 53 #define GRAY80 RGB565CONVERT(204, 204, 204)
apm_litoral 0:ea1b1135bb4e 54 #define GRAY90 RGB565CONVERT(229, 229, 229)
apm_litoral 0:ea1b1135bb4e 55 #define GRAY95 RGB565CONVERT(242, 242, 242)
apm_litoral 0:ea1b1135bb4e 56 #define RED4 RGB565CONVERT(139, 0, 0)
apm_litoral 0:ea1b1135bb4e 57 #define FIREBRICK1 RGB565CONVERT(255, 48, 48)
apm_litoral 0:ea1b1135bb4e 58 #define DARKGREEN RGB565CONVERT(0, 100, 0)
apm_litoral 0:ea1b1135bb4e 59 #define PALEGREEN RGB565CONVERT(152, 251, 152)
apm_litoral 0:ea1b1135bb4e 60 #define LIGHTYELLOW RGB565CONVERT(238, 221, 130)
apm_litoral 0:ea1b1135bb4e 61 #define GOLD RGB565CONVERT(255, 215, 0)
apm_litoral 0:ea1b1135bb4e 62 #define DARKORANGE RGB565CONVERT(255, 140, 0)
apm_litoral 0:ea1b1135bb4e 63 */
apm_litoral 0:ea1b1135bb4e 64 #define Black 0x0000 /* 0, 0, 0 */
apm_litoral 0:ea1b1135bb4e 65 #define Navy 0x000F /* 0, 0, 128 */
apm_litoral 0:ea1b1135bb4e 66 #define DarkGreen 0x03E0 /* 0, 128, 0 */
apm_litoral 0:ea1b1135bb4e 67 #define DarkCyan 0x03EF /* 0, 128, 128 */
apm_litoral 0:ea1b1135bb4e 68 #define Maroon 0x7800 /* 128, 0, 0 */
apm_litoral 0:ea1b1135bb4e 69 #define Purple 0x780F /* 128, 0, 128 */
apm_litoral 0:ea1b1135bb4e 70 #define Olive 0x7BE0 /* 128, 128, 0 */
apm_litoral 0:ea1b1135bb4e 71 #define LightGrey 0xC618 /* 192, 192, 192 */
apm_litoral 0:ea1b1135bb4e 72 #define DarkGrey 0x7BEF /* 128, 128, 128 */
apm_litoral 0:ea1b1135bb4e 73 #define Blue 0x001F /* 0, 0, 255 */////////////////////////// 32
apm_litoral 0:ea1b1135bb4e 74 #define Green 0x07E0 /* 0, 255, 0 */////////////////////////// 2016
apm_litoral 0:ea1b1135bb4e 75 #define Cyan 0x07FF /* 0, 255, 255 */
apm_litoral 0:ea1b1135bb4e 76 #define Red 0xF800 /* 255, 0, 0 */////////////////////////// 63488
apm_litoral 0:ea1b1135bb4e 77 #define Magenta 0xF81F /* 255, 0, 255 */
apm_litoral 0:ea1b1135bb4e 78 #define Yellow 0xFFE0 /* 255, 255, 0 */
apm_litoral 0:ea1b1135bb4e 79 #define White 0xFFFF /* 255, 255, 255 */
apm_litoral 0:ea1b1135bb4e 80 #define Orange 0xFD20 /* 255, 165, 0 */
apm_litoral 0:ea1b1135bb4e 81 #define GreenYellow 0xAFE5 /* 173, 255, 47 */
apm_litoral 0:ea1b1135bb4e 82
apm_litoral 0:ea1b1135bb4e 83
apm_litoral 0:ea1b1135bb4e 84 /** Display control class, based on GraphicsDisplay and TextDisplay
apm_litoral 0:ea1b1135bb4e 85 *
apm_litoral 0:ea1b1135bb4e 86 * Example:
apm_litoral 0:ea1b1135bb4e 87 * @code
apm_litoral 0:ea1b1135bb4e 88 * #include "stdio.h"
apm_litoral 0:ea1b1135bb4e 89 * #include "mbed.h"
apm_litoral 0:ea1b1135bb4e 90 * #include "SPI_TFT.h"
apm_litoral 0:ea1b1135bb4e 91 * #include "string"
apm_litoral 0:ea1b1135bb4e 92 * #include "Arial12x12.h"
apm_litoral 0:ea1b1135bb4e 93 * #include "Arial24x23.h"
apm_litoral 0:ea1b1135bb4e 94 *
apm_litoral 0:ea1b1135bb4e 95 *
apm_litoral 0:ea1b1135bb4e 96 *
apm_litoral 0:ea1b1135bb4e 97 * // the TFT is connected to SPI pin 5-7
apm_litoral 0:ea1b1135bb4e 98 * SPI_TFT TFT(p5, p6, p7, p8, p15,"TFT"); // mosi, miso, sclk, cs, reset
apm_litoral 0:ea1b1135bb4e 99 *
apm_litoral 0:ea1b1135bb4e 100 * int main() {
apm_litoral 0:ea1b1135bb4e 101 * TFT.claim(stdout); // send stdout to the TFT display
apm_litoral 0:ea1b1135bb4e 102 * //TFT.claim(stderr); // send stderr to the TFT display
apm_litoral 0:ea1b1135bb4e 103 *
apm_litoral 0:ea1b1135bb4e 104 * TFT.background(Black); // set background to black
apm_litoral 0:ea1b1135bb4e 105 * TFT.foreground(White); // set chars to white
apm_litoral 0:ea1b1135bb4e 106 * TFT.cls(); // clear the screen
apm_litoral 0:ea1b1135bb4e 107 * TFT.set_font((unsigned char*) Arial12x12); // select the font
apm_litoral 0:ea1b1135bb4e 108 *
apm_litoral 0:ea1b1135bb4e 109 * TFT.set_orientation(0);
apm_litoral 0:ea1b1135bb4e 110 * TFT.locate(0,0);
apm_litoral 0:ea1b1135bb4e 111 * printf(" Hello Mbed 0");
apm_litoral 0:ea1b1135bb4e 112 * TFT.set_font((unsigned char*) Arial24x23); // select font 2
apm_litoral 0:ea1b1135bb4e 113 * TFT.locate(48,115);
apm_litoral 0:ea1b1135bb4e 114 * TFT.printf("Bigger Font");
apm_litoral 0:ea1b1135bb4e 115 * }
apm_litoral 0:ea1b1135bb4e 116 * @endcode
apm_litoral 0:ea1b1135bb4e 117 */
apm_litoral 0:ea1b1135bb4e 118 class SPI_TFT : public GraphicsDisplay {
apm_litoral 0:ea1b1135bb4e 119 public:
apm_litoral 0:ea1b1135bb4e 120
apm_litoral 0:ea1b1135bb4e 121 /** Create a SPI_TFT object connected to SPI and two pins
apm_litoral 0:ea1b1135bb4e 122 *
apm_litoral 0:ea1b1135bb4e 123 * @param mosi,miso,sclk SPI
apm_litoral 0:ea1b1135bb4e 124 * @param cs pin connected to CS of display
apm_litoral 0:ea1b1135bb4e 125 * @param reset pin connected to RESET of display
apm_litoral 0:ea1b1135bb4e 126 *
apm_litoral 0:ea1b1135bb4e 127 */
apm_litoral 0:ea1b1135bb4e 128 SPI_TFT(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset, PinName bk,const char* name ="TFT");
apm_litoral 0:ea1b1135bb4e 129
apm_litoral 0:ea1b1135bb4e 130 /** Get the width of the screen in pixel
apm_litoral 0:ea1b1135bb4e 131 *
apm_litoral 0:ea1b1135bb4e 132 * @param
apm_litoral 0:ea1b1135bb4e 133 * @returns width of screen in pixel
apm_litoral 0:ea1b1135bb4e 134 *
apm_litoral 0:ea1b1135bb4e 135 */
apm_litoral 0:ea1b1135bb4e 136 virtual int width();
apm_litoral 0:ea1b1135bb4e 137
apm_litoral 0:ea1b1135bb4e 138 /** Get the height of the screen in pixel
apm_litoral 0:ea1b1135bb4e 139 *
apm_litoral 0:ea1b1135bb4e 140 * @returns height of screen in pixel
apm_litoral 0:ea1b1135bb4e 141 *
apm_litoral 0:ea1b1135bb4e 142 */
apm_litoral 0:ea1b1135bb4e 143 virtual int height();
apm_litoral 0:ea1b1135bb4e 144
apm_litoral 0:ea1b1135bb4e 145 /** Draw a pixel at x,y with color
apm_litoral 0:ea1b1135bb4e 146 *
apm_litoral 0:ea1b1135bb4e 147 * @param x horizontal position
apm_litoral 0:ea1b1135bb4e 148 * @param y vertical position
apm_litoral 0:ea1b1135bb4e 149 * @param color 16 bit pixel color
apm_litoral 0:ea1b1135bb4e 150 */
apm_litoral 0:ea1b1135bb4e 151 virtual void pixel(int x, int y, int colour);
apm_litoral 0:ea1b1135bb4e 152
apm_litoral 0:ea1b1135bb4e 153 /** draw a circle
apm_litoral 0:ea1b1135bb4e 154 *
apm_litoral 0:ea1b1135bb4e 155 * @param x0,y0 center
apm_litoral 0:ea1b1135bb4e 156 * @param r radius
apm_litoral 0:ea1b1135bb4e 157 * @param color 16 bit color *
apm_litoral 0:ea1b1135bb4e 158 *
apm_litoral 0:ea1b1135bb4e 159 */
apm_litoral 0:ea1b1135bb4e 160 void circle(int x, int y, int r, int colour);
apm_litoral 0:ea1b1135bb4e 161
apm_litoral 0:ea1b1135bb4e 162 /** draw a filled circle
apm_litoral 0:ea1b1135bb4e 163 *
apm_litoral 0:ea1b1135bb4e 164 * @param x0,y0 center
apm_litoral 0:ea1b1135bb4e 165 * @param r radius
apm_litoral 0:ea1b1135bb4e 166 * @param color 16 bit color *
apm_litoral 0:ea1b1135bb4e 167 *
apm_litoral 0:ea1b1135bb4e 168 * use circle with different radius,
apm_litoral 0:ea1b1135bb4e 169 * can miss some pixel
apm_litoral 0:ea1b1135bb4e 170 */
apm_litoral 0:ea1b1135bb4e 171 void fillcircle(int x, int y, int r, int colour);
apm_litoral 0:ea1b1135bb4e 172
apm_litoral 0:ea1b1135bb4e 173
apm_litoral 0:ea1b1135bb4e 174
apm_litoral 0:ea1b1135bb4e 175 /** draw a 1 pixel line
apm_litoral 0:ea1b1135bb4e 176 *
apm_litoral 0:ea1b1135bb4e 177 * @param x0,y0 start point
apm_litoral 0:ea1b1135bb4e 178 * @param x1,y1 stop point
apm_litoral 0:ea1b1135bb4e 179 * @param color 16 bit color
apm_litoral 0:ea1b1135bb4e 180 *
apm_litoral 0:ea1b1135bb4e 181 */
apm_litoral 0:ea1b1135bb4e 182 void line(int x0, int y0, int x1, int y1, int colour);
apm_litoral 0:ea1b1135bb4e 183
apm_litoral 0:ea1b1135bb4e 184 /** draw a rect
apm_litoral 0:ea1b1135bb4e 185 *
apm_litoral 0:ea1b1135bb4e 186 * @param x0,y0 top left corner
apm_litoral 0:ea1b1135bb4e 187 * @param x1,y1 down right corner
apm_litoral 0:ea1b1135bb4e 188 * @param color 16 bit color
apm_litoral 0:ea1b1135bb4e 189 * *
apm_litoral 0:ea1b1135bb4e 190 */
apm_litoral 0:ea1b1135bb4e 191 void rect(int x0, int y0, int x1, int y1, int colour);
apm_litoral 0:ea1b1135bb4e 192
apm_litoral 0:ea1b1135bb4e 193 /** draw a filled rect
apm_litoral 0:ea1b1135bb4e 194 *
apm_litoral 0:ea1b1135bb4e 195 * @param x0,y0 top left corner
apm_litoral 0:ea1b1135bb4e 196 * @param x1,y1 down right corner
apm_litoral 0:ea1b1135bb4e 197 * @param color 16 bit color
apm_litoral 0:ea1b1135bb4e 198 *
apm_litoral 0:ea1b1135bb4e 199 */
apm_litoral 0:ea1b1135bb4e 200 void fillrect(int x0, int y0, int x1, int y1, int colour);
apm_litoral 0:ea1b1135bb4e 201
apm_litoral 0:ea1b1135bb4e 202 /** setup cursor position
apm_litoral 0:ea1b1135bb4e 203 *
apm_litoral 0:ea1b1135bb4e 204 * @param x x-position (top left)
apm_litoral 0:ea1b1135bb4e 205 * @param y y-position
apm_litoral 0:ea1b1135bb4e 206 */
apm_litoral 0:ea1b1135bb4e 207
apm_litoral 0:ea1b1135bb4e 208 virtual void locate(int x, int y);
apm_litoral 0:ea1b1135bb4e 209
apm_litoral 0:ea1b1135bb4e 210 /** Fill the screen with _backgroun color
apm_litoral 0:ea1b1135bb4e 211 *
apm_litoral 0:ea1b1135bb4e 212 */
apm_litoral 0:ea1b1135bb4e 213
apm_litoral 0:ea1b1135bb4e 214 virtual void cls (void);
apm_litoral 0:ea1b1135bb4e 215
apm_litoral 0:ea1b1135bb4e 216 /** calculate the max number of char in a line
apm_litoral 0:ea1b1135bb4e 217 *
apm_litoral 0:ea1b1135bb4e 218 * @returns max columns
apm_litoral 0:ea1b1135bb4e 219 * depends on actual font size
apm_litoral 0:ea1b1135bb4e 220 *
apm_litoral 0:ea1b1135bb4e 221 */
apm_litoral 0:ea1b1135bb4e 222
apm_litoral 0:ea1b1135bb4e 223 virtual int columns(void);
apm_litoral 0:ea1b1135bb4e 224
apm_litoral 0:ea1b1135bb4e 225 /** calculate the max number of columns
apm_litoral 0:ea1b1135bb4e 226 *
apm_litoral 0:ea1b1135bb4e 227 * @returns max column
apm_litoral 0:ea1b1135bb4e 228 * depends on actual font size
apm_litoral 0:ea1b1135bb4e 229 *
apm_litoral 0:ea1b1135bb4e 230 */
apm_litoral 0:ea1b1135bb4e 231
apm_litoral 0:ea1b1135bb4e 232 virtual int rows(void);
apm_litoral 0:ea1b1135bb4e 233
apm_litoral 0:ea1b1135bb4e 234 /** put a char on the screen
apm_litoral 0:ea1b1135bb4e 235 *
apm_litoral 0:ea1b1135bb4e 236 * @param value char to print
apm_litoral 0:ea1b1135bb4e 237 * @returns printed char
apm_litoral 0:ea1b1135bb4e 238 *
apm_litoral 0:ea1b1135bb4e 239 */
apm_litoral 0:ea1b1135bb4e 240
apm_litoral 0:ea1b1135bb4e 241 virtual int _putc(int value);
apm_litoral 0:ea1b1135bb4e 242
apm_litoral 0:ea1b1135bb4e 243 /** draw a character on given position out of the active font to the TFT
apm_litoral 0:ea1b1135bb4e 244 *
apm_litoral 0:ea1b1135bb4e 245 * @param x x-position of char (top left)
apm_litoral 0:ea1b1135bb4e 246 * @param y y-position
apm_litoral 0:ea1b1135bb4e 247 * @param c char to print
apm_litoral 0:ea1b1135bb4e 248 *
apm_litoral 0:ea1b1135bb4e 249 */
apm_litoral 0:ea1b1135bb4e 250
apm_litoral 0:ea1b1135bb4e 251 virtual void character(int x, int y, int c);
apm_litoral 0:ea1b1135bb4e 252
apm_litoral 0:ea1b1135bb4e 253 /** paint a bitmap on the TFT
apm_litoral 0:ea1b1135bb4e 254 *
apm_litoral 0:ea1b1135bb4e 255 * @param x,y : upper left corner
apm_litoral 0:ea1b1135bb4e 256 * @param w width of bitmap
apm_litoral 0:ea1b1135bb4e 257 * @param h high of bitmap
apm_litoral 0:ea1b1135bb4e 258 * @param *bitmap pointer to the bitmap data
apm_litoral 0:ea1b1135bb4e 259 *
apm_litoral 0:ea1b1135bb4e 260 * bitmap format: 16 bit R5 G6 B5
apm_litoral 0:ea1b1135bb4e 261 *
apm_litoral 0:ea1b1135bb4e 262 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5
apm_litoral 0:ea1b1135bb4e 263 * use winhex to load this file and mark data stating at offset 0x46 to end
apm_litoral 0:ea1b1135bb4e 264 * use edit -> copy block -> C Source to export C array
apm_litoral 0:ea1b1135bb4e 265 * paste this array into your program
apm_litoral 0:ea1b1135bb4e 266 *
apm_litoral 0:ea1b1135bb4e 267 * define the array as static const unsigned char to put it into flash memory
apm_litoral 0:ea1b1135bb4e 268 * cast the pointer to (unsigned char *) :
apm_litoral 0:ea1b1135bb4e 269 * tft.Bitmap(10,40,309,50,(unsigned char *)scala);
apm_litoral 0:ea1b1135bb4e 270 */
apm_litoral 0:ea1b1135bb4e 271
apm_litoral 0:ea1b1135bb4e 272 void Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap);
apm_litoral 0:ea1b1135bb4e 273
apm_litoral 0:ea1b1135bb4e 274
apm_litoral 0:ea1b1135bb4e 275 /** paint a 16 bit BMP from local filesytem on the TFT (slow)
apm_litoral 0:ea1b1135bb4e 276 *
apm_litoral 0:ea1b1135bb4e 277 * @param x,y : upper left corner
apm_litoral 0:ea1b1135bb4e 278 * @param *Name_BMP name of the BMP file
apm_litoral 0:ea1b1135bb4e 279 * @returns 1 if bmp file was found and painted
apm_litoral 0:ea1b1135bb4e 280 * @returns -1 if bmp file was found not found
apm_litoral 0:ea1b1135bb4e 281 * @returns -2 if bmp file is not 16bit
apm_litoral 0:ea1b1135bb4e 282 * @returns -3 if bmp file is to big for screen
apm_litoral 0:ea1b1135bb4e 283 * @returns -4 if buffer malloc go wrong
apm_litoral 0:ea1b1135bb4e 284 *
apm_litoral 0:ea1b1135bb4e 285 * bitmap format: 16 bit R5 G6 B5
apm_litoral 0:ea1b1135bb4e 286 *
apm_litoral 0:ea1b1135bb4e 287 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5
apm_litoral 0:ea1b1135bb4e 288 * copy to internal file system
apm_litoral 0:ea1b1135bb4e 289 *
apm_litoral 0:ea1b1135bb4e 290 */
apm_litoral 0:ea1b1135bb4e 291
apm_litoral 0:ea1b1135bb4e 292 int BMP_16(unsigned int x, unsigned int y, const char *Name_BMP);
apm_litoral 0:ea1b1135bb4e 293
apm_litoral 0:ea1b1135bb4e 294
apm_litoral 0:ea1b1135bb4e 295 /** paint a 16 bit BMP from memory uSD Card on the TFT (slow)
apm_litoral 0:ea1b1135bb4e 296 *
apm_litoral 0:ea1b1135bb4e 297 * @param x,y : upper left corner
apm_litoral 0:ea1b1135bb4e 298 * @param *Name_BMP name of the BMP file
apm_litoral 0:ea1b1135bb4e 299 * @returns 1 if bmp file was found and painted
apm_litoral 0:ea1b1135bb4e 300 * @returns -1 if bmp file was found not found
apm_litoral 0:ea1b1135bb4e 301 * @returns -2 if bmp file is not 16bit
apm_litoral 0:ea1b1135bb4e 302 * @returns -3 if bmp file is to big for screen
apm_litoral 0:ea1b1135bb4e 303 * @returns -4 if buffer malloc go wrong
apm_litoral 0:ea1b1135bb4e 304 *
apm_litoral 0:ea1b1135bb4e 305 * bitmap format: 16 bit R5 G6 B5
apm_litoral 0:ea1b1135bb4e 306 *
apm_litoral 0:ea1b1135bb4e 307 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5
apm_litoral 0:ea1b1135bb4e 308 * copy to internal file system
apm_litoral 0:ea1b1135bb4e 309 *
apm_litoral 0:ea1b1135bb4e 310 */
apm_litoral 0:ea1b1135bb4e 311
apm_litoral 0:ea1b1135bb4e 312 int BMP_SD(unsigned int x_sd, unsigned int y_sd, const char *Name_BMP_SD);
apm_litoral 0:ea1b1135bb4e 313
apm_litoral 0:ea1b1135bb4e 314
apm_litoral 0:ea1b1135bb4e 315 /** select the font to use
apm_litoral 0:ea1b1135bb4e 316 *
apm_litoral 0:ea1b1135bb4e 317 * @param f pointer to font array
apm_litoral 0:ea1b1135bb4e 318 *
apm_litoral 0:ea1b1135bb4e 319 * font array can created with GLCD Font Creator from http://www.mikroe.com
apm_litoral 0:ea1b1135bb4e 320 * you have to add 4 parameter at the beginning of the font array to use:
apm_litoral 0:ea1b1135bb4e 321 * - the number of byte / char
apm_litoral 0:ea1b1135bb4e 322 * - the vertial size in pixel
apm_litoral 0:ea1b1135bb4e 323 * - the horizontal size in pixel
apm_litoral 0:ea1b1135bb4e 324 * - the number of byte per vertical line
apm_litoral 0:ea1b1135bb4e 325 * you also have to change the array to char[]
apm_litoral 0:ea1b1135bb4e 326 *
apm_litoral 0:ea1b1135bb4e 327 */
apm_litoral 0:ea1b1135bb4e 328
apm_litoral 0:ea1b1135bb4e 329 void set_font(unsigned char* f);
apm_litoral 0:ea1b1135bb4e 330
apm_litoral 0:ea1b1135bb4e 331 /** Set the orientation of the screen
apm_litoral 0:ea1b1135bb4e 332 * x,y: 0,0 is always top left
apm_litoral 0:ea1b1135bb4e 333 *
apm_litoral 0:ea1b1135bb4e 334 * @param o direction to use the screen (0-3) 90&#65533; Steps
apm_litoral 0:ea1b1135bb4e 335 *
apm_litoral 0:ea1b1135bb4e 336 */
apm_litoral 0:ea1b1135bb4e 337
apm_litoral 0:ea1b1135bb4e 338 void set_orientation(unsigned int o);
apm_litoral 0:ea1b1135bb4e 339
apm_litoral 0:ea1b1135bb4e 340 SPI _spi;
apm_litoral 0:ea1b1135bb4e 341 DigitalOut _cs;
apm_litoral 0:ea1b1135bb4e 342 DigitalOut _reset;
apm_litoral 0:ea1b1135bb4e 343 PwmOut _bk;
apm_litoral 0:ea1b1135bb4e 344 unsigned char* font;
apm_litoral 0:ea1b1135bb4e 345
apm_litoral 0:ea1b1135bb4e 346 /**Resetea mediante hardware el LFCD TFT a travez del pin RESET
apm_litoral 0:ea1b1135bb4e 347 */
apm_litoral 0:ea1b1135bb4e 348
apm_litoral 0:ea1b1135bb4e 349 void tft_rst_hw();
apm_litoral 0:ea1b1135bb4e 350
apm_litoral 0:ea1b1135bb4e 351 /**Enciende el Backligth del LCD TFT a travez de un pin PWM
apm_litoral 0:ea1b1135bb4e 352 */
apm_litoral 0:ea1b1135bb4e 353
apm_litoral 0:ea1b1135bb4e 354 void backlight(float intensity);
apm_litoral 0:ea1b1135bb4e 355
apm_litoral 0:ea1b1135bb4e 356 /**Modula el Backligth del LCD TFT a travez de un pin PWM
apm_litoral 0:ea1b1135bb4e 357 * minimo 0.01; maximo 1.0 ; paso para FOR 0.01, retardo 0.01
apm_litoral 0:ea1b1135bb4e 358 */
apm_litoral 0:ea1b1135bb4e 359
apm_litoral 0:ea1b1135bb4e 360 void contraste_pos(float min, float max, float steep, float delay);
apm_litoral 0:ea1b1135bb4e 361
apm_litoral 0:ea1b1135bb4e 362 /**Modula el Backligth del LCD TFT a travez de un pin PWM
apm_litoral 0:ea1b1135bb4e 363 * minimo 0.01; maximo 1.0 ; paso para FOR 0.01, retardo 0.01
apm_litoral 0:ea1b1135bb4e 364 */
apm_litoral 0:ea1b1135bb4e 365
apm_litoral 0:ea1b1135bb4e 366 void contraste_neg(float max, float min, float steep, float delay);
apm_litoral 0:ea1b1135bb4e 367
apm_litoral 0:ea1b1135bb4e 368 /* Genera una barra de carga para animar la congiguracion de un programa
apm_litoral 0:ea1b1135bb4e 369 * mientras este lee un archivo *.cfg de la raiz del sistema y configura las
apm_litoral 0:ea1b1135bb4e 370 * operaciones generales del programa segun indique el estado de su
apm_litoral 0:ea1b1135bb4e 371 * configuracion guardado la anterior vez en su memoria
apm_litoral 0:ea1b1135bb4e 372 */
apm_litoral 0:ea1b1135bb4e 373 void charge(int x0, int y0, int x1, int y1, int color_max, int color_min, float speed);
apm_litoral 0:ea1b1135bb4e 374
apm_litoral 0:ea1b1135bb4e 375 /* Animacion controlada por PWM para parpadeos de la pantalla, estipular el numero de parpadeos
apm_litoral 0:ea1b1135bb4e 376 * el maximo de intensidad, el minimo, la cantidad de incremento en steep, el retardo por cada uno
apm_litoral 0:ea1b1135bb4e 377 * el tiempo de parada entre cada uno y el brillo final que mantendra la LCD TFT al terminar la animacion
apm_litoral 0:ea1b1135bb4e 378 */
apm_litoral 0:ea1b1135bb4e 379
apm_litoral 0:ea1b1135bb4e 380 void parpadeo(int parpadeos, float max, float min, float steep, float delay,float stop, float brigthness);
apm_litoral 0:ea1b1135bb4e 381
apm_litoral 0:ea1b1135bb4e 382 /*
apm_litoral 0:ea1b1135bb4e 383 *
apm_litoral 0:ea1b1135bb4e 384 */
apm_litoral 0:ea1b1135bb4e 385 void Init_Kernel_Up(float brillo, int color, int orientation, unsigned char* letra,int x,int y,int delay);
apm_litoral 0:ea1b1135bb4e 386
apm_litoral 0:ea1b1135bb4e 387 /*
apm_litoral 0:ea1b1135bb4e 388 *
apm_litoral 0:ea1b1135bb4e 389 */
apm_litoral 0:ea1b1135bb4e 390 void Init_Kernel_Down(float brillo, int color, int orientation, unsigned char* letra,int x,int y,int delay);
apm_litoral 0:ea1b1135bb4e 391
apm_litoral 0:ea1b1135bb4e 392 /*
apm_litoral 0:ea1b1135bb4e 393 *
apm_litoral 0:ea1b1135bb4e 394 */
apm_litoral 0:ea1b1135bb4e 395
apm_litoral 0:ea1b1135bb4e 396 void init_tasking(float brillo, int color, int orientation, unsigned char* letra,int x,int y,int delay);
apm_litoral 0:ea1b1135bb4e 397
apm_litoral 0:ea1b1135bb4e 398 /*
apm_litoral 0:ea1b1135bb4e 399 *
apm_litoral 0:ea1b1135bb4e 400 */
apm_litoral 0:ea1b1135bb4e 401 void strcmp(float brillo, int color, int orientation, unsigned char* letra,int x,int y,int delay);
apm_litoral 0:ea1b1135bb4e 402
apm_litoral 0:ea1b1135bb4e 403 /*
apm_litoral 0:ea1b1135bb4e 404 *
apm_litoral 0:ea1b1135bb4e 405 */
apm_litoral 0:ea1b1135bb4e 406 void Loading(float bkt,int fondo, int color, unsigned char* letra,const char *titulo1,int x,int y,int fondo2, int color2,unsigned char* sam, const char *titulo2, int z,int w, int delay,int a,int b, int c, int d, int max, int min, float alfa_cromatic);
apm_litoral 0:ea1b1135bb4e 407
apm_litoral 0:ea1b1135bb4e 408
apm_litoral 0:ea1b1135bb4e 409 /*trae el codigo del LCD TFT para identificarlo mediante el registro 0x00h
apm_litoral 0:ea1b1135bb4e 410 *
apm_litoral 0:ea1b1135bb4e 411 */
apm_litoral 0:ea1b1135bb4e 412 int ID();
apm_litoral 0:ea1b1135bb4e 413
apm_litoral 0:ea1b1135bb4e 414 void binary_init(int a, int b, int c, int d, int delay);
apm_litoral 0:ea1b1135bb4e 415
apm_litoral 0:ea1b1135bb4e 416 /*permite definir el espacio maximo de desplazamiento para la pantalla
apm_litoral 0:ea1b1135bb4e 417 * top es TFA Top Fixed Area, button es BFA, button fixed area, y height es Height de Vertical Scroll Area
apm_litoral 0:ea1b1135bb4e 418 * top = 0, button= 0, height = 320, definen la pantalla maxima, top es el inicio y button es el resto, la suma de
apm_litoral 0:ea1b1135bb4e 419 * t+b+h = 320, si esto no se cumple el sroll no estaria bien definido.
apm_litoral 0:ea1b1135bb4e 420 * p es el puntero incremental o decremental que posicionara la imagen
apm_litoral 0:ea1b1135bb4e 421 * si pointer = 30, aparecera desplazado 30 pixeles
apm_litoral 0:ea1b1135bb4e 422 * speed es la velocidad a la que la imagen se desplaza
apm_litoral 0:ea1b1135bb4e 423 */
apm_litoral 0:ea1b1135bb4e 424 void sharepoint(unsigned int top, unsigned int button, unsigned int height, unsigned int pointer, unsigned int speed, unsigned repetitions);
apm_litoral 0:ea1b1135bb4e 425 void icon_ball(int x, int y, int state);
apm_litoral 0:ea1b1135bb4e 426
apm_litoral 0:ea1b1135bb4e 427 /*****************************************************************************************************/
apm_litoral 0:ea1b1135bb4e 428
apm_litoral 0:ea1b1135bb4e 429
apm_litoral 0:ea1b1135bb4e 430
apm_litoral 0:ea1b1135bb4e 431 //protected:
apm_litoral 0:ea1b1135bb4e 432 /** Init the HX8347D controller
apm_litoral 0:ea1b1135bb4e 433 *
apm_litoral 0:ea1b1135bb4e 434 */
apm_litoral 0:ea1b1135bb4e 435
apm_litoral 0:ea1b1135bb4e 436
apm_litoral 0:ea1b1135bb4e 437 void tft_init();
apm_litoral 0:ea1b1135bb4e 438
apm_litoral 0:ea1b1135bb4e 439 /** Set draw window region to whole screen
apm_litoral 0:ea1b1135bb4e 440 *
apm_litoral 0:ea1b1135bb4e 441 */
apm_litoral 0:ea1b1135bb4e 442
apm_litoral 0:ea1b1135bb4e 443 void WindowMax (void);
apm_litoral 0:ea1b1135bb4e 444
apm_litoral 0:ea1b1135bb4e 445
apm_litoral 0:ea1b1135bb4e 446 /** draw a horizontal line
apm_litoral 0:ea1b1135bb4e 447 *
apm_litoral 0:ea1b1135bb4e 448 * @param x0 horizontal start
apm_litoral 0:ea1b1135bb4e 449 * @param x1 horizontal stop
apm_litoral 0:ea1b1135bb4e 450 * @param y vertical position
apm_litoral 0:ea1b1135bb4e 451 * @param color 16 bit color
apm_litoral 0:ea1b1135bb4e 452 *
apm_litoral 0:ea1b1135bb4e 453 */
apm_litoral 0:ea1b1135bb4e 454
apm_litoral 0:ea1b1135bb4e 455 void hline(int x0, int x1, int y, int colour);
apm_litoral 0:ea1b1135bb4e 456
apm_litoral 0:ea1b1135bb4e 457 /** draw a vertical line
apm_litoral 0:ea1b1135bb4e 458 *
apm_litoral 0:ea1b1135bb4e 459 * @param x horizontal position
apm_litoral 0:ea1b1135bb4e 460 * @param y0 vertical start
apm_litoral 0:ea1b1135bb4e 461 * @param y1 vertical stop
apm_litoral 0:ea1b1135bb4e 462 * @param color 16 bit color
apm_litoral 0:ea1b1135bb4e 463 */
apm_litoral 0:ea1b1135bb4e 464
apm_litoral 0:ea1b1135bb4e 465 void vline(int y0, int y1, int x, int colour);
apm_litoral 0:ea1b1135bb4e 466
apm_litoral 0:ea1b1135bb4e 467 /** Set draw window region
apm_litoral 0:ea1b1135bb4e 468 *
apm_litoral 0:ea1b1135bb4e 469 * @param x horizontal position
apm_litoral 0:ea1b1135bb4e 470 * @param y vertical position
apm_litoral 0:ea1b1135bb4e 471 * @param w window width in pixel
apm_litoral 0:ea1b1135bb4e 472 * @param h window height in pixels
apm_litoral 0:ea1b1135bb4e 473 */
apm_litoral 0:ea1b1135bb4e 474
apm_litoral 0:ea1b1135bb4e 475 virtual void windows (unsigned int x, unsigned int y, unsigned int w, unsigned int h);
apm_litoral 0:ea1b1135bb4e 476
apm_litoral 0:ea1b1135bb4e 477
apm_litoral 0:ea1b1135bb4e 478
apm_litoral 0:ea1b1135bb4e 479
apm_litoral 0:ea1b1135bb4e 480
apm_litoral 0:ea1b1135bb4e 481 /** Write data to the LCD controller
apm_litoral 0:ea1b1135bb4e 482 *
apm_litoral 0:ea1b1135bb4e 483 * @param dat data written to LCD controller
apm_litoral 0:ea1b1135bb4e 484 *
apm_litoral 0:ea1b1135bb4e 485 */
apm_litoral 0:ea1b1135bb4e 486
apm_litoral 0:ea1b1135bb4e 487 void wr_dat(int value);
apm_litoral 0:ea1b1135bb4e 488
apm_litoral 0:ea1b1135bb4e 489 /** Write a command the LCD controller
apm_litoral 0:ea1b1135bb4e 490 *
apm_litoral 0:ea1b1135bb4e 491 * @param cmd: command to be written
apm_litoral 0:ea1b1135bb4e 492 *
apm_litoral 0:ea1b1135bb4e 493 */
apm_litoral 0:ea1b1135bb4e 494
apm_litoral 0:ea1b1135bb4e 495 void wr_cmd(int value);
apm_litoral 0:ea1b1135bb4e 496
apm_litoral 0:ea1b1135bb4e 497 /** Start data sequence to the LCD controller
apm_litoral 0:ea1b1135bb4e 498 *
apm_litoral 0:ea1b1135bb4e 499 */
apm_litoral 0:ea1b1135bb4e 500
apm_litoral 0:ea1b1135bb4e 501 void wr_dat_start();
apm_litoral 0:ea1b1135bb4e 502
apm_litoral 0:ea1b1135bb4e 503 /** Stop of data writing to the LCD controller
apm_litoral 0:ea1b1135bb4e 504 *
apm_litoral 0:ea1b1135bb4e 505 */
apm_litoral 0:ea1b1135bb4e 506
apm_litoral 0:ea1b1135bb4e 507 void wr_dat_stop();
apm_litoral 0:ea1b1135bb4e 508
apm_litoral 0:ea1b1135bb4e 509 /** write data to the LCD controller
apm_litoral 0:ea1b1135bb4e 510 *
apm_litoral 0:ea1b1135bb4e 511 * @param data to be written
apm_litoral 0:ea1b1135bb4e 512 * *
apm_litoral 0:ea1b1135bb4e 513 */
apm_litoral 0:ea1b1135bb4e 514
apm_litoral 0:ea1b1135bb4e 515 void wr_dat_only(unsigned short dat);
apm_litoral 0:ea1b1135bb4e 516
apm_litoral 0:ea1b1135bb4e 517 /** Read data from the LCD controller
apm_litoral 0:ea1b1135bb4e 518 *
apm_litoral 0:ea1b1135bb4e 519 * @returns data from LCD controller
apm_litoral 0:ea1b1135bb4e 520 *
apm_litoral 0:ea1b1135bb4e 521 */
apm_litoral 0:ea1b1135bb4e 522
apm_litoral 0:ea1b1135bb4e 523 unsigned short rd_dat(void);
apm_litoral 0:ea1b1135bb4e 524
apm_litoral 0:ea1b1135bb4e 525 /** Write a value to the to a LCD register
apm_litoral 0:ea1b1135bb4e 526 *
apm_litoral 0:ea1b1135bb4e 527 * @param reg register to be written
apm_litoral 0:ea1b1135bb4e 528 * @param val data to be written
apm_litoral 0:ea1b1135bb4e 529 */
apm_litoral 0:ea1b1135bb4e 530
apm_litoral 0:ea1b1135bb4e 531 void wr_reg (unsigned char reg, unsigned short val);
apm_litoral 0:ea1b1135bb4e 532
apm_litoral 0:ea1b1135bb4e 533 /** Read a LCD register
apm_litoral 0:ea1b1135bb4e 534 *
apm_litoral 0:ea1b1135bb4e 535 * @param reg register to be read
apm_litoral 0:ea1b1135bb4e 536 * @returns value of the register
apm_litoral 0:ea1b1135bb4e 537 */
apm_litoral 0:ea1b1135bb4e 538
apm_litoral 0:ea1b1135bb4e 539 unsigned short rd_reg (unsigned char reg);
apm_litoral 0:ea1b1135bb4e 540
apm_litoral 0:ea1b1135bb4e 541 unsigned int orientation;
apm_litoral 0:ea1b1135bb4e 542 unsigned int char_x;
apm_litoral 0:ea1b1135bb4e 543 unsigned int char_y;
apm_litoral 0:ea1b1135bb4e 544
apm_litoral 0:ea1b1135bb4e 545 protected:
apm_litoral 0:ea1b1135bb4e 546
apm_litoral 0:ea1b1135bb4e 547
apm_litoral 0:ea1b1135bb4e 548 };
apm_litoral 0:ea1b1135bb4e 549
apm_litoral 0:ea1b1135bb4e 550 #endif