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 chris stevens

Committer:
cstevens
Date:
Tue Sep 02 09:02:18 2014 +0000
Revision:
2:ebedda77b33b
Parent:
1:1085b6177f6e
Child:
4:1c2f9e3b9b12
based on fuentes library for tft lcd - this does the ssd0139 samsung driver for 240x320 color screens like those often sold on ebay

Who changed what in which revision?

UserRevisionLine numberNew 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
Suky 1:1085b6177f6e 23 /** Libreria para LCD TFT chip Himax HX8347-A
Suky 1:1085b6177f6e 24 *
Suky 1:1085b6177f6e 25 *
Suky 1:1085b6177f6e 26 * @code
Suky 1:1085b6177f6e 27 * #include "mbed.h"
Suky 1:1085b6177f6e 28 * #include "LCDTFT.h"
Suky 1:1085b6177f6e 29 *
Suky 1:1085b6177f6e 30 *BusOut MyBus(p13,p14,p15,p16,p17,p18,p19,p20,p30,p29,p28,p27,p26,p25,p24,p23);
Suky 1:1085b6177f6e 31 *LCDTFT MyLCD(p5,p6,p7,p22,p21,&MyBus);
Suky 1:1085b6177f6e 32 *
Suky 1:1085b6177f6e 33 *int main(){
Suky 1:1085b6177f6e 34 * MyLCD.vLCDTFTInit();
Suky 1:1085b6177f6e 35 * MyLCD.vLCDTFTFillScreen(ColorWhite);
Suky 1:1085b6177f6e 36 * MyLCD.printf("Hola mbed!!!");
Suky 1:1085b6177f6e 37 *
Suky 1:1085b6177f6e 38 * MyLCD.vDrawImageBMP24Bits("IMG0.BMP");
Suky 1:1085b6177f6e 39 *
Suky 1:1085b6177f6e 40 * while(1){
Suky 1:1085b6177f6e 41 * }
Suky 1:1085b6177f6e 42 *}
Suky 1:1085b6177f6e 43 * @endcode
Suky 1:1085b6177f6e 44 */
Suky 1:1085b6177f6e 45
Suky 1:1085b6177f6e 46 #include "mbed.h"
Suky 1:1085b6177f6e 47 #include "Fuentes.h"
Suky 1:1085b6177f6e 48
Suky 1:1085b6177f6e 49 #define ColorRed 0xf800
Suky 1:1085b6177f6e 50 #define ColorGreen 0x400
Suky 1:1085b6177f6e 51 #define ColorBlue 0x001f
Suky 1:1085b6177f6e 52 #define ColorMarron 0x8208
Suky 1:1085b6177f6e 53 #define ColorBlack 0x0
Suky 1:1085b6177f6e 54 #define ColorWhite 0xffff
Suky 1:1085b6177f6e 55 #define ColorMaroon 0x8000
Suky 1:1085b6177f6e 56 #define ColorFuchsia 0xf81f
Suky 1:1085b6177f6e 57 #define ColorVioleta 0x801f
Suky 1:1085b6177f6e 58 #define ColorAzulMarino 0x14
Suky 1:1085b6177f6e 59 #define ColorGray 0x8410
Suky 1:1085b6177f6e 60 #define ColorOlive 0x8400
Suky 1:1085b6177f6e 61 #define ColorNaranja 0xfc08
Suky 1:1085b6177f6e 62 #define ColorYellow 0xffe0
Suky 1:1085b6177f6e 63 #define ColorCian 0x87ff
Suky 1:1085b6177f6e 64 #define ColorRosado 0xf810
Suky 1:1085b6177f6e 65 #define ColorNavy 0x10
Suky 1:1085b6177f6e 66 #define ColorPurple 0x8010
Suky 1:1085b6177f6e 67 #define ColorTeal 0x410
Suky 1:1085b6177f6e 68 #define ColorLime 0x7e0
Suky 1:1085b6177f6e 69 #define ColorAqua 0x7ff
Suky 1:1085b6177f6e 70
cstevens 2:ebedda77b33b 71 #define LCD_X_MAX 240 // these swapped
Suky 1:1085b6177f6e 72 #define LCD_Y_MAX 320
Suky 1:1085b6177f6e 73
Suky 1:1085b6177f6e 74 class LCDTFT: public Stream {
Suky 1:1085b6177f6e 75 public:
Suky 1:1085b6177f6e 76 /** Crea LCDTFT interface
Suky 1:1085b6177f6e 77 *
Suky 1:1085b6177f6e 78 * @param RD
Suky 1:1085b6177f6e 79 * @param WR
Suky 1:1085b6177f6e 80 * @param RS
Suky 1:1085b6177f6e 81 * @param CS
Suky 1:1085b6177f6e 82 * @param RESET
Suky 1:1085b6177f6e 83 * @param BusLCD (16-bits)
Suky 1:1085b6177f6e 84 */
Suky 1:1085b6177f6e 85 LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, BusOut *BUSLCD);
Suky 1:1085b6177f6e 86 /** Inicializa LCD
cstevens 2:ebedda77b33b 87 * format =0 portrait and 1 for landscape
Suky 1:1085b6177f6e 88 */
cstevens 2:ebedda77b33b 89 void vLCDTFTInit(bool format);
Suky 1:1085b6177f6e 90 /** Fija parametros para escritura mediante printf
Suky 1:1085b6177f6e 91 *
Suky 1:1085b6177f6e 92 * @param Xo X inicial
Suky 1:1085b6177f6e 93 * @param Yo Y inicial
Suky 1:1085b6177f6e 94 * @param Xmin X minimo
Suky 1:1085b6177f6e 95 * @param Xmax X maximo
Suky 1:1085b6177f6e 96 * @param Alto Alto de letra (1,2,3..)
Suky 1:1085b6177f6e 97 * @param Color Color de letra 16-bits
cstevens 2:ebedda77b33b 98 * and the background color for clearing
Suky 1:1085b6177f6e 99 */
cstevens 2:ebedda77b33b 100 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 101 /** Pinta pantalla completa de color
Suky 1:1085b6177f6e 102 * @param Color Color de 16-bits
Suky 1:1085b6177f6e 103 */
Suky 1:1085b6177f6e 104 void vLCDTFTFillScreen(unsigned short Color);
Suky 1:1085b6177f6e 105 /** Dibuja punto en pantalla
Suky 1:1085b6177f6e 106 * @param x Posicion x
Suky 1:1085b6177f6e 107 * @param y Posicion y
Suky 1:1085b6177f6e 108 * @param Color Color 16-bits
Suky 1:1085b6177f6e 109 */
Suky 1:1085b6177f6e 110 void vLCDTFTPoint(unsigned short x,unsigned short y,unsigned short Color);
Suky 1:1085b6177f6e 111 /** Escribe string en LCD
Suky 1:1085b6177f6e 112 * @param x X inicial
Suky 1:1085b6177f6e 113 * @param y Y inicial
Suky 1:1085b6177f6e 114 * @param *PtrText Texto a escribir
Suky 1:1085b6177f6e 115 * @param *Fuente Fuente de letra a escribir (ARIAL)
Suky 1:1085b6177f6e 116 * @param Alto Alto de letra (1,2,3)
Suky 1:1085b6177f6e 117 * @param Color Color de 16-bits
Suky 1:1085b6177f6e 118 */
cstevens 2:ebedda77b33b 119 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 120
Suky 1:1085b6177f6e 121 void vLCDTFTLine(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,unsigned short Color);
Suky 1:1085b6177f6e 122 void vLCDTFTRectangle(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2,bool Filled,unsigned short Color);
Suky 1:1085b6177f6e 123 void vLCDTFTCircle(unsigned short x,unsigned short y,unsigned short Radius,bool Filled,unsigned short Color);
Suky 1:1085b6177f6e 124 /** Dibuja imagen ubicada en memoria de mbed (2Mbytes) centrada en patalla
Suky 1:1085b6177f6e 125 * @param NameImagen nombre de imagen (ejm: IMAGEN.BMP)
Suky 1:1085b6177f6e 126 */
Suky 1:1085b6177f6e 127 void vDrawImageBMP24Bits(const char *NameImagen);
Suky 1:1085b6177f6e 128 void vLCDTFTDrawImage(unsigned short x,unsigned short y, unsigned short Width, unsigned short Heigh, unsigned int Lenght, const unsigned short *Imagen);
Suky 1:1085b6177f6e 129 #if DOXYGEN_ONLY
Suky 1:1085b6177f6e 130 /** Escribe un caracter en LCD
Suky 1:1085b6177f6e 131 *
Suky 1:1085b6177f6e 132 * @param c El caracter a escribir en LCD
Suky 1:1085b6177f6e 133 */
Suky 1:1085b6177f6e 134 int putc(int c);
Suky 1:1085b6177f6e 135
Suky 1:1085b6177f6e 136 /** Escribe un string formateado en LCD
Suky 1:1085b6177f6e 137 *
Suky 1:1085b6177f6e 138 * @param format A printf-style format string, followed by the
Suky 1:1085b6177f6e 139 * variables to use in formating the string.
Suky 1:1085b6177f6e 140 */
Suky 1:1085b6177f6e 141 int printf(const char* format, ...);
Suky 1:1085b6177f6e 142 #endif
Suky 1:1085b6177f6e 143
Suky 1:1085b6177f6e 144 private:
Suky 1:1085b6177f6e 145 DigitalOut LCD_PIN_RD,LCD_PIN_WR,LCD_PIN_RS,LCD_PIN_CS,LCD_PIN_RESET;
Suky 1:1085b6177f6e 146 BusOut *LCD_PORT;
cstevens 2:ebedda77b33b 147 unsigned short X,Y,X_min,X_max,_Alto,_Color,_Background;
Suky 1:1085b6177f6e 148 // Stream implementation functions
Suky 1:1085b6177f6e 149 virtual int _putc(int value);
Suky 1:1085b6177f6e 150 virtual int _getc();
Suky 1:1085b6177f6e 151
Suky 1:1085b6177f6e 152 virtual void vLCDTFTWriteCommand(unsigned short Data);
Suky 1:1085b6177f6e 153 virtual void vLCDTFTWriteData(unsigned short Data);
Suky 1:1085b6177f6e 154 virtual void vLCDTFTWriteCommandData(unsigned short CMD,unsigned short Data);
Suky 1:1085b6177f6e 155 virtual void vLCDTFTAddressSet(unsigned short x1,unsigned short y1,unsigned short x2,unsigned short y2);
Suky 1:1085b6177f6e 156 virtual void vLCDTFTAddressSetPoint(unsigned short x,unsigned short y);
Suky 1:1085b6177f6e 157 };
Suky 1:1085b6177f6e 158 // **************************************************************************************************************************************