mcufriend 2.4 TFT LCD Shield Lib

Dependents:   Nucleo_LCD_mcufriend_test

Fork of 24_TFT_STMNUCLEO by Carlos Silva

mcufriend 2.4" TFT LCD Shield

front back

Import program

00001 #include "mbed.h"
00002 #include "ili9328.h"
00003 
00004 // prepare the data bus for writing commands and pixel data
00005 BusOut dataBus( D8, D9, D2, D3, D4, D5, D6, D7 ); // 8 pins
00006 // create the lcd instance
00007 ILI9328_LCD lcd( A3,  A4, A2,A1, &dataBus, NC, A0); // control pins and data bus
00008 //ILI9328_LCD(  CS,  RESET,  RS, WR, BusOut* DATA_PORT, PinName BL = NC,  RD );
00009    
00010 int main()
00011 {
00012     int ii,height,width;
00013     
00014     height = lcd.GetHeight();
00015     width =  lcd.GetWidth();
00016     // initialize display - place it in standard portrait mode and set background to black and
00017     //                      foreground to white color.
00018     lcd.Initialize();
00019 
00020     // print something on the screen
00021     lcd.Print( "Hello, World!", CENTER, 50); // align text to center horizontally and use starndard colors
00022  
00023     wait(2);
00024    
00025     lcd.ClearScreen();
00026  
00027     for(ii=0;ii<width;ii++)
00028     {
00029         lcd.DrawLine(0, 0, height, ii,COLOR_GREEN);
00030         ii = ii+10;    
00031     }
00032     wait(2);
00033  
00034     lcd.DrawCircle(height/4, width/4, 20, COLOR_GREEN);
00035     wait(2);
00036  
00037     lcd.FillCircle(height/2, width/2, 50, COLOR_GREEN);
00038     wait(2);
00039  
00040     lcd.FillTriangle(height/4, width/4,(height/4)+20, (width/4)+40,(height/4)-20, (width/4)+40, COLOR_RED);
00041  
00042     while ( 1 ) { }
00043 }

HW information about the mcufriend LCD Shield

Revision:
9:58b328831d0a
Parent:
8:7a4791dbb065
Child:
10:69571adcfad5
--- a/lcd_base.h	Thu Dec 06 02:18:22 2012 +0000
+++ b/lcd_base.h	Fri Dec 07 16:14:13 2012 +0000
@@ -161,11 +161,10 @@
      * in place, the new setting will be used for that single operation only and
      * will not change this value.
      *
-     * \param color The color to be used. Use the RGB macro to create the correct
-     *              color for the used LCD driver.
+     * \param color The color to be used. The value must be in RGB-565 format.
      * \sa #RGB(r,g,b)
      */
-    virtual void SetForeground( unsigned int color = COLOR_WHITE );
+    virtual void SetForeground( unsigned short color = COLOR_WHITE );
     
     /** Set the background color for painting.
      *
@@ -174,11 +173,10 @@
      * when the function is called, the new value will be used only for this
      * single call and will not change this setting.
      *
-     * \param color The background color. Use the RGB macro to create the correct
-     *              color for the used LCD driver.
+     * \param color The background color as RGB-565 value.
      * \sa #RGB(r,g,b)
      */
-    virtual void SetBackground( unsigned int color = COLOR_BLACK );
+    virtual void SetBackground( unsigned short color = COLOR_BLACK );
     
     /** Sets the font to be used for painting of text on the screen.
      * \param font A pointer to the font data.
@@ -197,10 +195,9 @@
     unsigned short GetHeight( void );
     
     /** Fills the whole screen with a single color.
-     * \param color The color to be used. Use the RGB macro to create the correct
-     *              color for the used LCD driver.
-     * \remarks The special values -1 and -2 signify the preset background and
-     *          foreground colors, respectively. The backround color is the default.
+     * \param color The color to be used. The value must be in RGB-565 format.
+     * \remarks The special values -1 and -2 signify the preset background and foreground colors, respectively.
+     *          The backround color is the default.
      */
     virtual void FillScreen( int color = -1 );
     
@@ -217,8 +214,7 @@
      *
      * \param x The horizontal offset of the pixel from the upper left corner of the screen.
      * \param y The vertical offset of the pixel from the upper left corner of the screen.
-     * \param color The color to be used. Use the RGB macro for custom color to produce the
-     *              correct format, or -1 for background and -2 for foreground color.
+     * \param color The color to be used. Must be in RGB-565 format, or -1 for background and -2 for foreground color.
      */
     virtual void DrawPixel( unsigned short x, unsigned short y, int color = -2 );
     
@@ -228,8 +224,7 @@
      * \param y1 Vertical offset of the beginning point of the line.
      * \param x2 Horizontal offset of the end point of the line.
      * \param y2 Verical offset of the end point of the line.
-     * \param color The color to use for painting; use -1 for background, or -2 for foreground,
-     *              or the RGB macro for custom colors.
+     * \param color The color to use for painting, in RGB-565 format, or -1 for background, or -2 for foreground.
      */
     virtual void DrawLine( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -239,7 +234,7 @@
      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void DrawRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -249,7 +244,7 @@
      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void DrawRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -259,7 +254,7 @@
      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void FillRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -269,7 +264,7 @@
      * \param y1 The vertical offset of the beginning point of one of the rectangle's diagonals.
      * \param x2 The horizontal offset of the end point of the same of the rectangle's diagonals.
      * \param y2 The vertical offset of the end point of the same of the rectangle's diagonals.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void FillRoundRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 );
     
@@ -278,7 +273,7 @@
      * \param x The offset of the circle's center from the left edge of the screen.
      * \param y The offset of the circle's center from the top edge of the screen.
      * \param radius The circle's radius.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void DrawCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 );
     
@@ -287,7 +282,7 @@
      * \param x The offset of the circle's center from the left edge of the screen.
      * \param y The offset of the circle's center from the top edge of the screen.
      * \param radius The circle's radius.
-     * \param color The color to use for painting. -1 indicated background, -2 foreground, or use the RGB macro for custom color.
+     * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color in RGB-565 format.
      */
     virtual void FillCircle( unsigned short x, unsigned short y, unsigned short radius, int color = -2 );
     
@@ -419,7 +414,7 @@
      * \param y Y coordinate of the starting point of the line.
      * \param len Length of the line.
      * \param color The color to use to draw the line. By default the global foreground color is used ( -2 ),
-     *              -1 switches to the default background color, or use the RGB macro for custom color.
+     *              -1 switches to the default background color, or any other RGB-565 color can be used.
      */
     virtual void DrawHLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 );
     
@@ -432,7 +427,7 @@
      * \param y Y coordinate of the starting point of the line.
      * \param len Height of the line.
      * \param color The color to use to draw the line. By default the global foreground color is used ( -2 ),
-     *              -1 switches to the default background color, or use the RGB macro for custom color.
+     *              -1 switches to the default background color, or any other RGB-565 color can be used.
      */
     virtual void DrawVLine( unsigned short x, unsigned short y, unsigned short len, int color = -2 );
     
@@ -442,9 +437,9 @@
      * \param x X coordinate of the character position.
      * \param y Y coordinate of the character position.
      * \param fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ),
-     *                -1 switches to the default background color, or use the RGB macro for custom color.
+     *                -1 switches to the default background color, or any other RGB-565 color can be used.
      * \param bgColor Background color for drawing. By default the global background color is used ( -1 ),
-     *                -2 switches to the default foreground color, or use the RGB macro for custom color.
+     *                -2 switches to the default foreground color, or any other RGB-565 color can be used.
      */
     virtual void PrintChar( char c, unsigned short x, unsigned short y, int fgColor = -2, int bgColor = -1 );
     
@@ -455,9 +450,9 @@
      * \param y Y coordinate of the character position.
      * \param pos Position of the character in the string from which it originates (used to rotate a whole string).
      * \param fgColor Foreground color for drawing. By default the global foreground color is used ( -2 ),
-     *                -1 switches to the default background color, or use the RGB macro for custom color.
+     *                -1 switches to the default background color, or any other RGB-565 color can be used.
      * \param bgColor Background color for drawing. By default the global background color is used ( -1 ),
-     *                -2 switches to the default foreground color, or use the RGB macro for custom color.
+     *                -2 switches to the default foreground color, or any other RGB-565 color can be used.
      * \param deg The angle at which to rotate. 
      */
     virtual void RotateChar( char c, unsigned short x, unsigned short y, int pos, int fgColor = -2, int bgColor = -1, unsigned short deg = 0 );
@@ -466,7 +461,7 @@
     unsigned short  _disp_width, _disp_height;
     DigitalOut      _lcd_pin_cs, _lcd_pin_rs, _lcd_pin_reset;
     orientation_t   _orientation;
-    unsigned int    _foreground, _background;
+    unsigned short  _foreground, _background;
     font_metrics_t  _font;
 };