LCD TFT for ssd0139 driver 8 bit mode
Dependents: receiver TFT_CJS_ssd0139 poster8x8_ranger
Fork of LCDTFT by
LCDTFT.h@5:d910bf3b7bb0, 2015-06-09 (annotated)
- Committer:
- cstevens
- Date:
- Tue Jun 09 10:29:06 2015 +0000
- Revision:
- 5:d910bf3b7bb0
- Parent:
- 4:2feb189748f7
Updated so example code now has correct definition fo the port; uses a single 8 bit busout command.; May need slight change if one wants to speed things up and use the portout version....
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Suky | 1:1085b6177f6e | 1 | /* |
Suky | 1:1085b6177f6e | 2 | @file LCDTFT.h |
Suky | 1:1085b6177f6e | 3 | @version: 1.0 |
Suky | 1:1085b6177f6e | 4 | |
Suky | 1:1085b6177f6e | 5 | @web www.micros-designs.com.ar |
Suky | 1:1085b6177f6e | 6 | @date 30/01/11 |
Suky | 1:1085b6177f6e | 7 | |
Suky | 1:1085b6177f6e | 8 | *- Version Log --------------------------------------------------------------* |
Suky | 1:1085b6177f6e | 9 | * Fecha Autor Comentarios * |
Suky | 1:1085b6177f6e | 10 | *----------------------------------------------------------------------------* |
Suky | 1:1085b6177f6e | 11 | * 30/01/11 Suky Original * |
Suky | 1:1085b6177f6e | 12 | *----------------------------------------------------------------------------*/ |
Suky | 1:1085b6177f6e | 13 | /////////////////////////////////////////////////////////////////////////// |
Suky | 1:1085b6177f6e | 14 | //// //// |
Suky | 1:1085b6177f6e | 15 | //// //// |
Suky | 1:1085b6177f6e | 16 | //// (C) Copyright 2011 www.micros-designs.com.ar //// |
cstevens | 2:ebedda77b33b | 17 | //// Este c�digo puede ser usado, modificado y distribuido libremente //// |
cstevens | 2:ebedda77b33b | 18 | //// sin eliminar esta cabecera y sin garant�a de ning�n tipo. //// |
Suky | 1:1085b6177f6e | 19 | //// //// |
Suky | 1:1085b6177f6e | 20 | //// //// |
Suky | 1:1085b6177f6e | 21 | /////////////////////////////////////////////////////////////////////////// |
Suky | 1:1085b6177f6e | 22 | |
cstevens | 5:d910bf3b7bb0 | 23 | /** Libreria para LCD TFT chip Himax HX8347-A |
cstevens | 5:d910bf3b7bb0 | 24 | * Library for 320x240 tft lcd |
Suky | 1:1085b6177f6e | 25 | * |
Suky | 1:1085b6177f6e | 26 | * |
Suky | 1:1085b6177f6e | 27 | * @code |
Suky | 1:1085b6177f6e | 28 | * #include "mbed.h" |
Suky | 1:1085b6177f6e | 29 | * #include "LCDTFT.h" |
Suky | 1:1085b6177f6e | 30 | * |
cstevens | 5:d910bf3b7bb0 | 31 | * |
cstevens | 5:d910bf3b7bb0 | 32 | * // pins for TFT - now using 8 bit mode |
cstevens | 5:d910bf3b7bb0 | 33 | * BusOut MyBus(PTA13,PTD5,PTD4,PTA12,PTA4,PTA5,PTC8,PTC9); // 8 bit bus on these dvices |
cstevens | 5:d910bf3b7bb0 | 34 | * LCDTFT MyLCD(PTB0,PTB1,PTB2,PTB3,PTC2,&MyBus);//LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, BusOut *BUSLCD); |
cstevens | 5:d910bf3b7bb0 | 35 | * |
Suky | 1:1085b6177f6e | 36 | * |
Suky | 1:1085b6177f6e | 37 | *int main(){ |
Suky | 1:1085b6177f6e | 38 | * MyLCD.vLCDTFTInit(); |
Suky | 1:1085b6177f6e | 39 | * MyLCD.vLCDTFTFillScreen(ColorWhite); |
Suky | 1:1085b6177f6e | 40 | * MyLCD.printf("Hola mbed!!!"); |
Suky | 1:1085b6177f6e | 41 | * |
Suky | 1:1085b6177f6e | 42 | * MyLCD.vDrawImageBMP24Bits("IMG0.BMP"); |
Suky | 1:1085b6177f6e | 43 | * |
Suky | 1:1085b6177f6e | 44 | * while(1){ |
Suky | 1:1085b6177f6e | 45 | * } |
Suky | 1:1085b6177f6e | 46 | *} |
Suky | 1:1085b6177f6e | 47 | * @endcode |
Suky | 1:1085b6177f6e | 48 | */ |
Suky | 1:1085b6177f6e | 49 | |
Suky | 1:1085b6177f6e | 50 | #include "mbed.h" |
Suky | 1:1085b6177f6e | 51 | #include "Fuentes.h" |
Suky | 1:1085b6177f6e | 52 | |
cstevens | 4:2feb189748f7 | 53 | #define Red 0xf800 |
cstevens | 4:2feb189748f7 | 54 | #define Green 0x400 |
cstevens | 4:2feb189748f7 | 55 | #define Blue 0x001f |
cstevens | 4:2feb189748f7 | 56 | #define Marron 0x8208 |
cstevens | 4:2feb189748f7 | 57 | #define Black 0x0 |
cstevens | 4:2feb189748f7 | 58 | #define White 0xffff |
cstevens | 4:2feb189748f7 | 59 | #define Maroon 0x8000 |
cstevens | 4:2feb189748f7 | 60 | #define Fuchsia 0xf81f |
cstevens | 4:2feb189748f7 | 61 | #define Violet 0x801f |
cstevens | 4:2feb189748f7 | 62 | #define SeaBlue 0x14 |
cstevens | 4:2feb189748f7 | 63 | #define Gray 0x8410 |
cstevens | 4:2feb189748f7 | 64 | #define Olive 0x8400 |
cstevens | 4:2feb189748f7 | 65 | #define Orange 0xfc08 |
cstevens | 4:2feb189748f7 | 66 | #define Yellow 0xffe0 |
cstevens | 4:2feb189748f7 | 67 | #define Cyan 0x87ff |
cstevens | 4:2feb189748f7 | 68 | #define Pink 0xf810 |
cstevens | 4:2feb189748f7 | 69 | #define Navy 0x10 |
cstevens | 4:2feb189748f7 | 70 | #define Purple 0x8010 |
cstevens | 4:2feb189748f7 | 71 | #define Teal 0x410 |
cstevens | 4:2feb189748f7 | 72 | #define Lime 0x7e0 |
cstevens | 4:2feb189748f7 | 73 | #define Aqua 0x7ff |
Suky | 1:1085b6177f6e | 74 | |
cstevens | 2:ebedda77b33b | 75 | #define LCD_X_MAX 240 // these swapped |
Suky | 1:1085b6177f6e | 76 | #define LCD_Y_MAX 320 |
Suky | 1:1085b6177f6e | 77 | |
Suky | 1:1085b6177f6e | 78 | class LCDTFT: public Stream { |
Suky | 1:1085b6177f6e | 79 | public: |
Suky | 1:1085b6177f6e | 80 | /** Crea LCDTFT interface |
Suky | 1:1085b6177f6e | 81 | * |
Suky | 1:1085b6177f6e | 82 | * @param RD |
Suky | 1:1085b6177f6e | 83 | * @param WR |
Suky | 1:1085b6177f6e | 84 | * @param RS |
Suky | 1:1085b6177f6e | 85 | * @param CS |
Suky | 1:1085b6177f6e | 86 | * @param RESET |
Suky | 1:1085b6177f6e | 87 | * @param BusLCD (16-bits) |
Suky | 1:1085b6177f6e | 88 | */ |
Suky | 1:1085b6177f6e | 89 | LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, BusOut *BUSLCD); |
Suky | 1:1085b6177f6e | 90 | /** Inicializa LCD |
cstevens | 2:ebedda77b33b | 91 | * format =0 portrait and 1 for landscape |
Suky | 1:1085b6177f6e | 92 | */ |
cstevens | 2:ebedda77b33b | 93 | void vLCDTFTInit(bool format); |
Suky | 1:1085b6177f6e | 94 | /** Fija parametros para escritura mediante printf |
Suky | 1:1085b6177f6e | 95 | * |
Suky | 1:1085b6177f6e | 96 | * @param Xo X inicial |
Suky | 1:1085b6177f6e | 97 | * @param Yo Y inicial |
Suky | 1:1085b6177f6e | 98 | * @param Xmin X minimo |
Suky | 1:1085b6177f6e | 99 | * @param Xmax X maximo |
Suky | 1:1085b6177f6e | 100 | * @param Alto Alto de letra (1,2,3..) |
Suky | 1:1085b6177f6e | 101 | * @param Color Color de letra 16-bits |
cstevens | 2:ebedda77b33b | 102 | * and the background color for clearing |
Suky | 1:1085b6177f6e | 103 | */ |
cstevens | 2:ebedda77b33b | 104 | void vLCDTFTSetParametersPrintf(unsigned short Xo,unsigned short Yo,unsigned short Xmin,unsigned short Xmax,unsigned char Alto, unsigned short Color, unsigned short BackColor); |
Suky | 1:1085b6177f6e | 105 | /** Pinta pantalla completa de color |
Suky | 1:1085b6177f6e | 106 | * @param Color Color de 16-bits |
Suky | 1:1085b6177f6e | 107 | */ |
Suky | 1:1085b6177f6e | 108 | void vLCDTFTFillScreen(unsigned short Color); |
Suky | 1:1085b6177f6e | 109 | /** Dibuja punto en pantalla |
Suky | 1:1085b6177f6e | 110 | * @param x Posicion x |
Suky | 1:1085b6177f6e | 111 | * @param y Posicion y |
Suky | 1:1085b6177f6e | 112 | * @param Color Color 16-bits |
Suky | 1:1085b6177f6e | 113 | */ |
Suky | 1:1085b6177f6e | 114 | void vLCDTFTPoint(unsigned short x,unsigned short y,unsigned short Color); |
Suky | 1:1085b6177f6e | 115 | /** Escribe string en LCD |
Suky | 1:1085b6177f6e | 116 | * @param x X inicial |
Suky | 1:1085b6177f6e | 117 | * @param y Y inicial |
Suky | 1:1085b6177f6e | 118 | * @param *PtrText Texto a escribir |
Suky | 1:1085b6177f6e | 119 | * @param *Fuente Fuente de letra a escribir (ARIAL) |
Suky | 1:1085b6177f6e | 120 | * @param Alto Alto de letra (1,2,3) |
Suky | 1:1085b6177f6e | 121 | * @param Color Color de 16-bits |
Suky | 1:1085b6177f6e | 122 | */ |
cstevens | 2:ebedda77b33b | 123 | void vLCDTFTText(unsigned short x,unsigned short y,const char *PtrText,const char (*Fuente)[5],unsigned char Alto,unsigned short Color,unsigned short BackColor); |
Suky | 1:1085b6177f6e | 124 | |
Suky | 1:1085b6177f6e | 125 | void vLCDTFTLine(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,unsigned short Color); |
Suky | 1:1085b6177f6e | 126 | void vLCDTFTRectangle(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,bool Filled,unsigned short Color); |
Suky | 1:1085b6177f6e | 127 | void vLCDTFTCircle(unsigned short x,unsigned short y,unsigned short Radius,bool Filled,unsigned short Color); |
Suky | 1:1085b6177f6e | 128 | /** Dibuja imagen ubicada en memoria de mbed (2Mbytes) centrada en patalla |
Suky | 1:1085b6177f6e | 129 | * @param NameImagen nombre de imagen (ejm: IMAGEN.BMP) |
Suky | 1:1085b6177f6e | 130 | */ |
Suky | 1:1085b6177f6e | 131 | void vDrawImageBMP24Bits(const char *NameImagen); |
Suky | 1:1085b6177f6e | 132 | void vLCDTFTDrawImage(unsigned short x,unsigned short y, unsigned short Width, unsigned short Heigh, unsigned int Lenght, const unsigned short *Imagen); |
Suky | 1:1085b6177f6e | 133 | #if DOXYGEN_ONLY |
Suky | 1:1085b6177f6e | 134 | /** Escribe un caracter en LCD |
Suky | 1:1085b6177f6e | 135 | * |
Suky | 1:1085b6177f6e | 136 | * @param c El caracter a escribir en LCD |
Suky | 1:1085b6177f6e | 137 | */ |
Suky | 1:1085b6177f6e | 138 | int putc(int c); |
Suky | 1:1085b6177f6e | 139 | |
Suky | 1:1085b6177f6e | 140 | /** Escribe un string formateado en LCD |
Suky | 1:1085b6177f6e | 141 | * |
Suky | 1:1085b6177f6e | 142 | * @param format A printf-style format string, followed by the |
Suky | 1:1085b6177f6e | 143 | * variables to use in formating the string. |
Suky | 1:1085b6177f6e | 144 | */ |
Suky | 1:1085b6177f6e | 145 | int printf(const char* format, ...); |
Suky | 1:1085b6177f6e | 146 | #endif |
Suky | 1:1085b6177f6e | 147 | |
Suky | 1:1085b6177f6e | 148 | private: |
Suky | 1:1085b6177f6e | 149 | DigitalOut LCD_PIN_RD,LCD_PIN_WR,LCD_PIN_RS,LCD_PIN_CS,LCD_PIN_RESET; |
Suky | 1:1085b6177f6e | 150 | BusOut *LCD_PORT; |
cstevens | 2:ebedda77b33b | 151 | unsigned short X,Y,X_min,X_max,_Alto,_Color,_Background; |
Suky | 1:1085b6177f6e | 152 | // Stream implementation functions |
Suky | 1:1085b6177f6e | 153 | virtual int _putc(int value); |
Suky | 1:1085b6177f6e | 154 | virtual int _getc(); |
Suky | 1:1085b6177f6e | 155 | |
Suky | 1:1085b6177f6e | 156 | virtual void vLCDTFTWriteCommand(unsigned short Data); |
Suky | 1:1085b6177f6e | 157 | virtual void vLCDTFTWriteData(unsigned short Data); |
Suky | 1:1085b6177f6e | 158 | virtual void vLCDTFTWriteCommandData(unsigned short CMD,unsigned short Data); |
Suky | 1:1085b6177f6e | 159 | virtual void vLCDTFTAddressSet(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2); |
Suky | 1:1085b6177f6e | 160 | virtual void vLCDTFTAddressSetPoint(unsigned short x,unsigned short y); |
Suky | 1:1085b6177f6e | 161 | }; |
Suky | 1:1085b6177f6e | 162 | // ************************************************************************************************************************************** |