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
Diff: SPI_TFT.h
- Revision:
- 3:5be1edd3a543
- Parent:
- 2:0cc880f230ad
- Child:
- 4:e1e45f8a7664
diff -r 0cc880f230ad -r 5be1edd3a543 SPI_TFT.h --- a/SPI_TFT.h Wed Jul 13 08:35:20 2011 +0000 +++ b/SPI_TFT.h Wed Jul 13 08:53:24 2011 +0000 @@ -13,6 +13,37 @@ #ifndef MBED_SPI_TFT_H #define MBED_SPI_TFT_H + +#include "mbed.h" +#include "GraphicsDisplay.h" + +#define RGB(r,g,b) (((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3)) //5 red | 6 green | 5 blue + +#define SPI_START (0x70) /* Start byte for SPI transfer */ +#define SPI_RD (0x01) /* WR bit 1 within start */ +#define SPI_WR (0x00) /* WR bit 0 within start */ +#define SPI_DATA (0x02) /* RS bit 1 within start byte */ +#define SPI_INDEX (0x00) /* RS bit 0 within start byte */ + + +/* some RGB color definitions */ +#define Black 0x0000 /* 0, 0, 0 */ +#define Navy 0x000F /* 0, 0, 128 */ +#define DarkGreen 0x03E0 /* 0, 128, 0 */ +#define DarkCyan 0x03EF /* 0, 128, 128 */ +#define Maroon 0x7800 /* 128, 0, 0 */ +#define Purple 0x780F /* 128, 0, 128 */ +#define Olive 0x7BE0 /* 128, 128, 0 */ +#define LightGrey 0xC618 /* 192, 192, 192 */ +#define DarkGrey 0x7BEF /* 128, 128, 128 */ +#define Blue 0x001F /* 0, 0, 255 */ +#define Green 0x07E0 /* 0, 255, 0 */ +#define Cyan 0x07FF /* 0, 255, 255 */ +#define Red 0xF800 /* 255, 0, 0 */ +#define Magenta 0xF81F /* 255, 0, 255 */ +#define Yellow 0xFFE0 /* 255, 255, 0 */ +#define White 0xFFFF /* 255, 255, 255 */ + /** Display control class, based on GraphicsDisplay and TextDisplay * * Example: @@ -47,44 +78,8 @@ * } * @endcode */ - - -#include "mbed.h" -#include "GraphicsDisplay.h" - -#define RGB(r,g,b) (((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3)) //5 red | 6 green | 5 blue - -#define SPI_START (0x70) /* Start byte for SPI transfer */ -#define SPI_RD (0x01) /* WR bit 1 within start */ -#define SPI_WR (0x00) /* WR bit 0 within start */ -#define SPI_DATA (0x02) /* RS bit 1 within start byte */ -#define SPI_INDEX (0x00) /* RS bit 0 within start byte */ - - -/* some RGB color definitions */ -#define Black 0x0000 /* 0, 0, 0 */ -#define Navy 0x000F /* 0, 0, 128 */ -#define DarkGreen 0x03E0 /* 0, 128, 0 */ -#define DarkCyan 0x03EF /* 0, 128, 128 */ -#define Maroon 0x7800 /* 128, 0, 0 */ -#define Purple 0x780F /* 128, 0, 128 */ -#define Olive 0x7BE0 /* 128, 128, 0 */ -#define LightGrey 0xC618 /* 192, 192, 192 */ -#define DarkGrey 0x7BEF /* 128, 128, 128 */ -#define Blue 0x001F /* 0, 0, 255 */ -#define Green 0x07E0 /* 0, 255, 0 */ -#define Cyan 0x07FF /* 0, 255, 255 */ -#define Red 0xF800 /* 255, 0, 0 */ -#define Magenta 0xF81F /* 255, 0, 255 */ -#define Yellow 0xFFE0 /* 255, 255, 0 */ -#define White 0xFFFF /* 255, 255, 255 */ - - - - - -class SPI_TFT : public GraphicsDisplay { -public: + class SPI_TFT : public GraphicsDisplay { + public: /** Create a SPI_TFT object connected to SPI and two pins *