mcufriend 2.4 TFT LCD Shield Lib
Dependents: Nucleo_LCD_mcufriend_test
Fork of 24_TFT_STMNUCLEO by
mcufriend 2.4" TFT LCD Shield
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
Diff: lcd_base.h
- Revision:
- 30:ede1a0a32e04
- Parent:
- 22:4c169297f374
--- a/lcd_base.h Mon Jun 30 17:29:42 2014 +0000 +++ b/lcd_base.h Wed Nov 09 09:33:04 2016 +0000 @@ -30,14 +30,14 @@ *********************************************************************/ #ifndef TFTLCD_BASE_H #define TFTLCD_BASE_H - + #include "mbed.h" #include "terminus.h" - + #ifdef __cplusplus extern "C" { #endif - + /** \def RGB(r,g,b) * \brief Creates a RGB color from distinct bytes for the red, green and blue components. * @@ -81,8 +81,8 @@ * \brief Shorthand for RGB( 255, 255, 0 ) */ #define COLOR_YELLOW RGB( 0xFF, 0xFF, 0x00 ) - - + + /** \enum Orientation_enum * \brief Display orientation. */ @@ -97,7 +97,7 @@ * \brief Convenience shortcut for display orientation. */ typedef enum Orientation_enum orientation_t; - + /** \enum ColorDepth_enum * \brief Color depth */ @@ -111,7 +111,7 @@ * \brief Convenience shortcut for display color depth. */ typedef enum ColorDepth_enum colordepth_t; - + /** \enum Alignment_enum * \brief Horizontal text alignment on the line. */ @@ -125,7 +125,7 @@ * \brief Convenience shortcut for text alignment. */ typedef enum Alignment_enum align_t; - + ///** \struct Font_struct // * \brief Describes fonts and their properties. // * \sa Comments in fonts.h @@ -142,7 +142,7 @@ // * \brief Convenience shortcut for fonts properties. // */ //typedef struct Font_struct font_metrics_t; - + /** \struct Bitmap_struct * \brief Describes an image. */ @@ -157,7 +157,7 @@ * \brief Convenience shortcut bitmap type. */ typedef struct Bitmap_struct bitmap_t; - + /** \struct BacklightPwmCtrl_enum * \brief Type of backlight control for the LCD. * @@ -185,8 +185,8 @@ * \brief Convenience shortcut for the backlight control type. */ typedef BacklightPwmCtrl_enum backlight_t; - - + + /** Base class for LCD implementations. * * All separate LCD controller implementations have to subclass this one. @@ -197,7 +197,7 @@ class LCD { public: - + /** Initialize display. * * Wakes up the display from sleep, initializes power parameters. @@ -340,6 +340,33 @@ * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. */ virtual void DrawRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color = -2 ); + + /** Paints a Triangle. + * + * \param x1 + * \param y1 + * \param x2 + * \param y2 + * \param x3 + * \param y3 + * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. + */ + virtual void DrawTriangle( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned short x3, unsigned short y3, int color = -2 ); + + /** Draw a Triangle and fill the color. + * + * \param x1 + * \param y1 + * \param x2 + * \param y2 + * \param x3 + * \param y3 + * \param color The color to use for painting. -1 indicated background, -2 foreground, or custom color. + */ + + + virtual void FillTriangle( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, unsigned short x3, unsigned short y3, int color = -2 ); + /** Paints a rectangle and fills it with the paint color. * @@ -567,7 +594,7 @@ * \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 ); - + protected: unsigned short _disp_width, _disp_height; DigitalOut _lcd_pin_cs, _lcd_pin_rs, _lcd_pin_reset; @@ -580,9 +607,9 @@ backlight_t _bl_type; float _bl_pwm_default, _bl_pwm_current; }; - + #ifdef __cplusplus } #endif - -#endif /* TFTLCD_BASE_H */ + +#endif /* TFTLCD_BASE_H */ \ No newline at end of file