LCD TFT for ssd0139 driver 8 bit mode - using portout for max speed
Dependents: TFT_CJS_ssd01399_portver_prettyfont TFT_CJS_ssd01399_portver_prettyfont snake_main_game ServerLatest
Fork of LCDTFT_ssd01399 by
LCDTFT.h@4:1c2f9e3b9b12, 2015-06-10 (annotated)
- Committer:
- cstevens
- Date:
- Wed Jun 10 15:47:22 2015 +0000
- Revision:
- 4:1c2f9e3b9b12
- Parent:
- 2:ebedda77b33b
- Child:
- 6:b5ecdc15f1a3
changed to make it use port instead of bus
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cstevens | 4:1c2f9e3b9b12 | 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 | *----------------------------------------------------------------------------* |
cstevens | 4:1c2f9e3b9b12 | 11 | * 30/01/11 Suky Original * |
cstevens | 4:1c2f9e3b9b12 | 12 | * june / 2015 Chris Stevens Update |
Suky | 1:1085b6177f6e | 13 | *----------------------------------------------------------------------------*/ |
Suky | 1:1085b6177f6e | 14 | /////////////////////////////////////////////////////////////////////////// |
Suky | 1:1085b6177f6e | 15 | //// //// |
Suky | 1:1085b6177f6e | 16 | //// //// |
Suky | 1:1085b6177f6e | 17 | //// (C) Copyright 2011 www.micros-designs.com.ar //// |
cstevens | 2:ebedda77b33b | 18 | //// Este c�digo puede ser usado, modificado y distribuido libremente //// |
cstevens | 2:ebedda77b33b | 19 | //// sin eliminar esta cabecera y sin garant�a de ning�n tipo. //// |
Suky | 1:1085b6177f6e | 20 | //// //// |
Suky | 1:1085b6177f6e | 21 | //// //// |
Suky | 1:1085b6177f6e | 22 | /////////////////////////////////////////////////////////////////////////// |
Suky | 1:1085b6177f6e | 23 | |
cstevens | 4:1c2f9e3b9b12 | 24 | /** Library for SSD01399 controller using port rather than bus to speed up screen updates |
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 | 4:1c2f9e3b9b12 | 31 | *PortOut MyPort(p13,p14,p15,p16,p17,p18,p19,p20,p30,p29,p28,p27,p26,p25,p24,p23); |
cstevens | 4:1c2f9e3b9b12 | 32 | *LCDTFT MyLCD(p5,p6,p7,p22,p21,&MyPort); |
Suky | 1:1085b6177f6e | 33 | * |
Suky | 1:1085b6177f6e | 34 | *int main(){ |
Suky | 1:1085b6177f6e | 35 | * MyLCD.vLCDTFTInit(); |
Suky | 1:1085b6177f6e | 36 | * MyLCD.vLCDTFTFillScreen(ColorWhite); |
Suky | 1:1085b6177f6e | 37 | * MyLCD.printf("Hola mbed!!!"); |
Suky | 1:1085b6177f6e | 38 | * |
Suky | 1:1085b6177f6e | 39 | * MyLCD.vDrawImageBMP24Bits("IMG0.BMP"); |
Suky | 1:1085b6177f6e | 40 | * |
Suky | 1:1085b6177f6e | 41 | * while(1){ |
Suky | 1:1085b6177f6e | 42 | * } |
Suky | 1:1085b6177f6e | 43 | *} |
Suky | 1:1085b6177f6e | 44 | * @endcode |
Suky | 1:1085b6177f6e | 45 | */ |
Suky | 1:1085b6177f6e | 46 | |
Suky | 1:1085b6177f6e | 47 | #include "mbed.h" |
Suky | 1:1085b6177f6e | 48 | #include "Fuentes.h" |
Suky | 1:1085b6177f6e | 49 | |
Suky | 1:1085b6177f6e | 50 | #define ColorRed 0xf800 |
Suky | 1:1085b6177f6e | 51 | #define ColorGreen 0x400 |
Suky | 1:1085b6177f6e | 52 | #define ColorBlue 0x001f |
Suky | 1:1085b6177f6e | 53 | #define ColorMarron 0x8208 |
Suky | 1:1085b6177f6e | 54 | #define ColorBlack 0x0 |
Suky | 1:1085b6177f6e | 55 | #define ColorWhite 0xffff |
Suky | 1:1085b6177f6e | 56 | #define ColorMaroon 0x8000 |
Suky | 1:1085b6177f6e | 57 | #define ColorFuchsia 0xf81f |
Suky | 1:1085b6177f6e | 58 | #define ColorVioleta 0x801f |
Suky | 1:1085b6177f6e | 59 | #define ColorAzulMarino 0x14 |
Suky | 1:1085b6177f6e | 60 | #define ColorGray 0x8410 |
Suky | 1:1085b6177f6e | 61 | #define ColorOlive 0x8400 |
Suky | 1:1085b6177f6e | 62 | #define ColorNaranja 0xfc08 |
Suky | 1:1085b6177f6e | 63 | #define ColorYellow 0xffe0 |
Suky | 1:1085b6177f6e | 64 | #define ColorCian 0x87ff |
Suky | 1:1085b6177f6e | 65 | #define ColorRosado 0xf810 |
Suky | 1:1085b6177f6e | 66 | #define ColorNavy 0x10 |
Suky | 1:1085b6177f6e | 67 | #define ColorPurple 0x8010 |
Suky | 1:1085b6177f6e | 68 | #define ColorTeal 0x410 |
Suky | 1:1085b6177f6e | 69 | #define ColorLime 0x7e0 |
Suky | 1:1085b6177f6e | 70 | #define ColorAqua 0x7ff |
Suky | 1:1085b6177f6e | 71 | |
cstevens | 2:ebedda77b33b | 72 | #define LCD_X_MAX 240 // these swapped |
Suky | 1:1085b6177f6e | 73 | #define LCD_Y_MAX 320 |
Suky | 1:1085b6177f6e | 74 | |
Suky | 1:1085b6177f6e | 75 | class LCDTFT: public Stream { |
Suky | 1:1085b6177f6e | 76 | public: |
Suky | 1:1085b6177f6e | 77 | /** Crea LCDTFT interface |
Suky | 1:1085b6177f6e | 78 | * |
Suky | 1:1085b6177f6e | 79 | * @param RD |
Suky | 1:1085b6177f6e | 80 | * @param WR |
Suky | 1:1085b6177f6e | 81 | * @param RS |
Suky | 1:1085b6177f6e | 82 | * @param CS |
Suky | 1:1085b6177f6e | 83 | * @param RESET |
cstevens | 4:1c2f9e3b9b12 | 84 | * @param PORTLCD (8-bits) |
Suky | 1:1085b6177f6e | 85 | */ |
cstevens | 4:1c2f9e3b9b12 | 86 | LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, PortOut *PORTLCD); |
Suky | 1:1085b6177f6e | 87 | /** Inicializa LCD |
cstevens | 2:ebedda77b33b | 88 | * format =0 portrait and 1 for landscape |
Suky | 1:1085b6177f6e | 89 | */ |
cstevens | 2:ebedda77b33b | 90 | void vLCDTFTInit(bool format); |
Suky | 1:1085b6177f6e | 91 | /** Fija parametros para escritura mediante printf |
Suky | 1:1085b6177f6e | 92 | * |
Suky | 1:1085b6177f6e | 93 | * @param Xo X inicial |
Suky | 1:1085b6177f6e | 94 | * @param Yo Y inicial |
Suky | 1:1085b6177f6e | 95 | * @param Xmin X minimo |
Suky | 1:1085b6177f6e | 96 | * @param Xmax X maximo |
Suky | 1:1085b6177f6e | 97 | * @param Alto Alto de letra (1,2,3..) |
Suky | 1:1085b6177f6e | 98 | * @param Color Color de letra 16-bits |
cstevens | 2:ebedda77b33b | 99 | * and the background color for clearing |
Suky | 1:1085b6177f6e | 100 | */ |
cstevens | 2:ebedda77b33b | 101 | 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 | 102 | /** Pinta pantalla completa de color |
Suky | 1:1085b6177f6e | 103 | * @param Color Color de 16-bits |
Suky | 1:1085b6177f6e | 104 | */ |
Suky | 1:1085b6177f6e | 105 | void vLCDTFTFillScreen(unsigned short Color); |
Suky | 1:1085b6177f6e | 106 | /** Dibuja punto en pantalla |
Suky | 1:1085b6177f6e | 107 | * @param x Posicion x |
Suky | 1:1085b6177f6e | 108 | * @param y Posicion y |
Suky | 1:1085b6177f6e | 109 | * @param Color Color 16-bits |
Suky | 1:1085b6177f6e | 110 | */ |
Suky | 1:1085b6177f6e | 111 | void vLCDTFTPoint(unsigned short x,unsigned short y,unsigned short Color); |
Suky | 1:1085b6177f6e | 112 | /** Escribe string en LCD |
Suky | 1:1085b6177f6e | 113 | * @param x X inicial |
Suky | 1:1085b6177f6e | 114 | * @param y Y inicial |
Suky | 1:1085b6177f6e | 115 | * @param *PtrText Texto a escribir |
Suky | 1:1085b6177f6e | 116 | * @param *Fuente Fuente de letra a escribir (ARIAL) |
Suky | 1:1085b6177f6e | 117 | * @param Alto Alto de letra (1,2,3) |
Suky | 1:1085b6177f6e | 118 | * @param Color Color de 16-bits |
Suky | 1:1085b6177f6e | 119 | */ |
cstevens | 2:ebedda77b33b | 120 | 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 | 121 | |
Suky | 1:1085b6177f6e | 122 | void vLCDTFTLine(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,unsigned short Color); |
Suky | 1:1085b6177f6e | 123 | void vLCDTFTRectangle(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,bool Filled,unsigned short Color); |
Suky | 1:1085b6177f6e | 124 | void vLCDTFTCircle(unsigned short x,unsigned short y,unsigned short Radius,bool Filled,unsigned short Color); |
Suky | 1:1085b6177f6e | 125 | /** Dibuja imagen ubicada en memoria de mbed (2Mbytes) centrada en patalla |
Suky | 1:1085b6177f6e | 126 | * @param NameImagen nombre de imagen (ejm: IMAGEN.BMP) |
Suky | 1:1085b6177f6e | 127 | */ |
Suky | 1:1085b6177f6e | 128 | void vDrawImageBMP24Bits(const char *NameImagen); |
Suky | 1:1085b6177f6e | 129 | void vLCDTFTDrawImage(unsigned short x,unsigned short y, unsigned short Width, unsigned short Heigh, unsigned int Lenght, const unsigned short *Imagen); |
Suky | 1:1085b6177f6e | 130 | #if DOXYGEN_ONLY |
Suky | 1:1085b6177f6e | 131 | /** Escribe un caracter en LCD |
Suky | 1:1085b6177f6e | 132 | * |
Suky | 1:1085b6177f6e | 133 | * @param c El caracter a escribir en LCD |
Suky | 1:1085b6177f6e | 134 | */ |
Suky | 1:1085b6177f6e | 135 | int putc(int c); |
Suky | 1:1085b6177f6e | 136 | |
Suky | 1:1085b6177f6e | 137 | /** Escribe un string formateado en LCD |
Suky | 1:1085b6177f6e | 138 | * |
Suky | 1:1085b6177f6e | 139 | * @param format A printf-style format string, followed by the |
Suky | 1:1085b6177f6e | 140 | * variables to use in formating the string. |
Suky | 1:1085b6177f6e | 141 | */ |
Suky | 1:1085b6177f6e | 142 | int printf(const char* format, ...); |
Suky | 1:1085b6177f6e | 143 | #endif |
Suky | 1:1085b6177f6e | 144 | |
Suky | 1:1085b6177f6e | 145 | private: |
Suky | 1:1085b6177f6e | 146 | DigitalOut LCD_PIN_RD,LCD_PIN_WR,LCD_PIN_RS,LCD_PIN_CS,LCD_PIN_RESET; |
cstevens | 4:1c2f9e3b9b12 | 147 | PortOut *LCD_PORT; |
cstevens | 2:ebedda77b33b | 148 | unsigned short X,Y,X_min,X_max,_Alto,_Color,_Background; |
Suky | 1:1085b6177f6e | 149 | // Stream implementation functions |
Suky | 1:1085b6177f6e | 150 | virtual int _putc(int value); |
Suky | 1:1085b6177f6e | 151 | virtual int _getc(); |
Suky | 1:1085b6177f6e | 152 | |
Suky | 1:1085b6177f6e | 153 | virtual void vLCDTFTWriteCommand(unsigned short Data); |
Suky | 1:1085b6177f6e | 154 | virtual void vLCDTFTWriteData(unsigned short Data); |
Suky | 1:1085b6177f6e | 155 | virtual void vLCDTFTWriteCommandData(unsigned short CMD,unsigned short Data); |
Suky | 1:1085b6177f6e | 156 | virtual void vLCDTFTAddressSet(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2); |
Suky | 1:1085b6177f6e | 157 | virtual void vLCDTFTAddressSetPoint(unsigned short x,unsigned short y); |
Suky | 1:1085b6177f6e | 158 | }; |
Suky | 1:1085b6177f6e | 159 | // ************************************************************************************************************************************** |