This class drives the LCD display (4-inch 800x472 LCD-TFT) present on STM32F769I-DISCO board

Dependents:   Datarecorder2 DISCO-F769NI_several_example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LCD_DISCO_F769NI.h Source File

LCD_DISCO_F769NI.h

00001 /* Copyright (c) 2010-2011 mbed.org, MIT License
00002 *
00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004 * and associated documentation files (the "Software"), to deal in the Software without
00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00007 * Software is furnished to do so, subject to the following conditions:
00008 *
00009 * The above copyright notice and this permission notice shall be included in all copies or
00010 * substantial portions of the Software.
00011 *
00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017 */
00018 
00019 #ifndef __LCD_DISCO_F769NI_H
00020 #define __LCD_DISCO_F769NI_H
00021 
00022 #ifdef TARGET_DISCO_F769NI
00023 
00024 #include "mbed.h"
00025 #include "stm32f769i_discovery_lcd.h"
00026 
00027 /*
00028   This class drives the LCD display (4-inch 800x472 LCD-TFT) present on STM32F769I-DISCO board.
00029 
00030   Usage:
00031 
00032   #include "mbed.h"
00033   #include "LCD_DISCO_F769NI.h"
00034 
00035   LCD_DISCO_F769NI lcd;
00036 
00037   int main()
00038   {
00039       lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"MBED EXAMPLE", CENTER_MODE);
00040       wait(1);
00041       lcd.Clear(LCD_COLOR_BLUE);
00042       lcd.SetBackColor(LCD_COLOR_BLUE);
00043       lcd.SetTextColor(LCD_COLOR_WHITE);
00044       lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"DISCOVERY STM32F769NI", CENTER_MODE);
00045       while(1)
00046       {
00047       }
00048   }
00049 */
00050 class LCD_DISCO_F769NI
00051 {
00052 
00053 public:
00054     //! Constructor
00055     LCD_DISCO_F769NI();
00056 
00057     //! Destructor
00058     ~LCD_DISCO_F769NI();
00059 
00060     /**
00061       * @brief  Initializes the DSI LCD.
00062       * @param  None
00063       * @retval LCD state
00064       */
00065     uint8_t Init(void);
00066 
00067     /**
00068       * @brief  Initializes the DSI LCD.
00069       * The ititialization is done as below:
00070       *     - DSI PLL ititialization
00071       *     - DSI ititialization
00072       *     - LTDC ititialization
00073       *     - OTM8009A LCD Display IC Driver ititialization
00074       * @param  None
00075       * @retval LCD state
00076       */
00077     uint8_t InitEx(LCD_OrientationTypeDef orientation);
00078 
00079     /**
00080       * @brief  Initializes the DSI for HDMI monitor.
00081       * The ititialization is done as below:
00082       *     - DSI PLL ititialization
00083       *     - DSI ititialization
00084       *     - LTDC ititialization
00085       *     - DSI-HDMI ADV7533 adapter device ititialization
00086       * @param  format : HDMI format could be HDMI_FORMAT_720_480 or HDMI_FORMAT_720_576
00087       * @retval LCD state
00088       */
00089     uint8_t HDMIInitEx(uint8_t format);
00090 
00091     /**
00092       * @brief  BSP LCD Reset
00093       *         Hw reset the LCD DSI activating its XRES signal (active low for some time);
00094       *         and desactivating it later.
00095       */
00096     void Reset(void);
00097 
00098     /**
00099       * @brief  Gets the LCD X size.
00100       * @retval Used LCD X size
00101       */
00102     uint32_t GetXSize(void);
00103 
00104     /**
00105       * @brief  Gets the LCD Y size.
00106       * @retval Used LCD Y size
00107       */
00108     uint32_t GetYSize(void);
00109 
00110     /**
00111       * @brief  Set the LCD X size.
00112       * @param  imageWidthPixels : uint32_t image width in pixels unit
00113       * @retval None
00114       */
00115     void SetXSize(uint32_t imageWidthPixels);
00116 
00117     /**
00118       * @brief  Set the LCD Y size.
00119       * @param  imageHeightPixels : uint32_t image height in lines unit
00120       */
00121     void SetYSize(uint32_t imageHeightPixels);
00122 
00123     /**
00124       * @brief  Initializes the LCD layers.
00125       * @param  LayerIndex: Layer foreground or background
00126       * @param  FB_Address: Layer frame buffer
00127       * @retval None
00128       */
00129     void LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address);
00130 
00131     /**
00132       * @brief  Selects the LCD Layer.
00133       * @param  LayerIndex: Layer foreground or background
00134       */
00135     void SelectLayer(uint32_t LayerIndex);
00136 
00137     /**
00138       * @brief  Sets an LCD Layer visible
00139       * @param  LayerIndex: Visible Layer
00140       * @param  State: New state of the specified layer
00141       *          This parameter can be one of the following values:
00142       *            @arg  ENABLE
00143       *            @arg  DISABLE
00144       */
00145     void SetLayerVisible(uint32_t LayerIndex, FunctionalState State);
00146 
00147     /**
00148       * @brief  Configures the transparency.
00149       * @param  LayerIndex: Layer foreground or background.
00150       * @param  Transparency: Transparency
00151       *           This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF
00152       */
00153     void SetTransparency(uint32_t LayerIndex, uint8_t Transparency);
00154 
00155     /**
00156       * @brief  Sets an LCD layer frame buffer address.
00157       * @param  LayerIndex: Layer foreground or background
00158       * @param  Address: New LCD frame buffer value
00159       */
00160     void SetLayerAddress(uint32_t LayerIndex, uint32_t Address);
00161 
00162     /**
00163       * @brief  Sets display window.
00164       * @param  LayerIndex: Layer index
00165       * @param  Xpos: LCD X position
00166       * @param  Ypos: LCD Y position
00167       * @param  Width: LCD window width
00168       * @param  Height: LCD window height
00169       */
00170     void SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
00171 
00172     /**
00173       * @brief  Configures and sets the color keying.
00174       * @param  LayerIndex: Layer foreground or background
00175       * @param  RGBValue: Color reference
00176       */
00177     void SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue);
00178 
00179     /**
00180       * @brief  Disables the color keying.
00181       * @param  LayerIndex: Layer foreground or background
00182       */
00183     void ResetColorKeying(uint32_t LayerIndex);
00184 
00185     /**
00186       * @brief  Sets the LCD text color.
00187       * @param  Color: Text color code ARGB(8-8-8-8);
00188       */
00189     void SetTextColor(uint32_t Color);
00190 
00191     /**
00192       * @brief  Gets the LCD text color.
00193       * @retval Used text color.
00194       */
00195     uint32_t GetTextColor(void);
00196 
00197     /**
00198       * @brief  Sets the LCD background color.
00199       * @param  Color: Layer background color code ARGB(8-8-8-8);
00200       */
00201     void SetBackColor(uint32_t Color);
00202 
00203     /**
00204       * @brief  Gets the LCD background color.
00205       * @retval Used background color
00206       */
00207     uint32_t GetBackColor(void);
00208 
00209     /**
00210       * @brief  Sets the LCD text font.
00211       * @param  fonts: Layer font to be used
00212       */
00213     void SetFont(sFONT *fonts);
00214 
00215     /**
00216       * @brief  Gets the LCD text font.
00217       * @retval Used layer font
00218       */
00219     sFONT *GetFont(void);
00220 
00221     /**
00222       * @brief  Reads an LCD pixel.
00223       * @param  Xpos: X position
00224       * @param  Ypos: Y position
00225       * @retval RGB pixel color
00226       */
00227     uint32_t ReadPixel(uint16_t Xpos, uint16_t Ypos);
00228 
00229     /**
00230       * @brief  Clears the whole currently active layer of LTDC.
00231       * @param  Color: Color of the background
00232       */
00233     void Clear(uint32_t Color);
00234 
00235     /**
00236       * @brief  Clears the selected line in currently active layer.
00237       * @param  Line: Line to be cleared
00238       */
00239     void ClearStringLine(uint32_t Line);
00240 
00241     /**
00242       * @brief  Displays one character in currently active layer.
00243       * @param  Xpos: Start column address
00244       * @param  Ypos: Line where to display the character shape.
00245       * @param  Ascii: Character ascii code
00246       *           This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E
00247       */
00248     void DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii);
00249 
00250     /**
00251       * @brief  Displays characters in currently active layer.
00252       * @param  Xpos: X position (in pixel);
00253       * @param  Ypos: Y position (in pixel);
00254       * @param  Text: Pointer to string to display on LCD
00255       * @param  Mode: Display mode
00256       *          This parameter can be one of the following values:
00257       *            @arg  CENTER_MODE
00258       *            @arg  RIGHT_MODE
00259       *            @arg  LEFT_MODE
00260       */
00261     void DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode);
00262 
00263     /**
00264       * @brief  Displays a maximum of 60 characters on the LCD.
00265       * @param  Line: Line where to display the character shape
00266       * @param  ptr: Pointer to string to display on LCD
00267       */
00268     void DisplayStringAtLine(uint16_t Line, uint8_t *ptr);
00269 
00270     /**
00271       * @brief  Draws an horizontal line in currently active layer.
00272       * @param  Xpos: X position
00273       * @param  Ypos: Y position
00274       * @param  Length: Line length
00275       */
00276     void DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
00277 
00278     /**
00279       * @brief  Draws a vertical line in currently active layer.
00280       * @param  Xpos: X position
00281       * @param  Ypos: Y position
00282       * @param  Length: Line length
00283       */
00284     void DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
00285 
00286     /**
00287       * @brief  Draws an uni-line (between two points); in currently active layer.
00288       * @param  x1: Point 1 X position
00289       * @param  y1: Point 1 Y position
00290       * @param  x2: Point 2 X position
00291       * @param  y2: Point 2 Y position
00292       */
00293     void DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
00294 
00295     /**
00296       * @brief  Draws a rectangle in currently active layer.
00297       * @param  Xpos: X position
00298       * @param  Ypos: Y position
00299       * @param  Width: Rectangle width
00300       * @param  Height: Rectangle height
00301       */
00302     void DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
00303 
00304     /**
00305       * @brief  Draws a circle in currently active layer.
00306       * @param  Xpos: X position
00307       * @param  Ypos: Y position
00308       * @param  Radius: Circle radius
00309       */
00310     void DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
00311 
00312     /**
00313       * @brief  Draws an poly-line (between many points); in currently active layer.
00314       * @param  Points: Pointer to the points array
00315       * @param  PointCount: Number of points
00316       */
00317     void DrawPolygon(pPoint Points, uint16_t PointCount);
00318 
00319     /**
00320       * @brief  Draws an ellipse on LCD in currently active layer.
00321       * @param  Xpos: X position
00322       * @param  Ypos: Y position
00323       * @param  XRadius: Ellipse X radius
00324       * @param  YRadius: Ellipse Y radius
00325       */
00326     void DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
00327 
00328     /**
00329       * @brief  Draws a bitmap picture loaded in the internal Flash (32 bpp); in currently active layer.
00330       * @param  Xpos: Bmp X position in the LCD
00331       * @param  Ypos: Bmp Y position in the LCD
00332       * @param  pbmp: Pointer to Bmp picture address in the internal Flash
00333       */
00334     void DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp);
00335 
00336     /**
00337       * @brief  Draws a full rectangle in currently active layer.
00338       * @param  Xpos: X position
00339       * @param  Ypos: Y position
00340       * @param  Width: Rectangle width
00341       * @param  Height: Rectangle height
00342       */
00343     void FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
00344 
00345     /**
00346       * @brief  Draws a full circle in currently active layer.
00347       * @param  Xpos: X position
00348       * @param  Ypos: Y position
00349       * @param  Radius: Circle radius
00350       */
00351     void FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
00352 
00353     /**
00354       * @brief  Draws a full poly-line (between many points); in currently active layer.
00355       * @param  Points: Pointer to the points array
00356       * @param  PointCount: Number of points
00357       */
00358     void FillPolygon(pPoint Points, uint16_t PointCount);
00359 
00360     /**
00361       * @brief  Draws a full ellipse in currently active layer.
00362       * @param  Xpos: X position
00363       * @param  Ypos: Y position
00364       * @param  XRadius: Ellipse X radius
00365       * @param  YRadius: Ellipse Y radius
00366       */
00367     void FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
00368 
00369     /**
00370       * @brief  Switch back on the display if was switched off by previous call of DisplayOff();.
00371       *         Exit DSI ULPM mode if was allowed and configured in Dsi Configuration.
00372       */
00373     void DisplayOn(void);
00374 
00375     /**
00376       * @brief  Switch Off the display.
00377       *         Enter DSI ULPM mode if was allowed and configured in Dsi Configuration.
00378       */
00379     void DisplayOff(void);
00380 
00381     /**
00382       * @brief  Set the brightness value
00383       * @param  BrightnessValue: [00: Min (black);, 100 Max]
00384       */
00385     void SetBrightness(uint8_t BrightnessValue);
00386 
00387     /**
00388       * @brief  Returns the ID of connected screen by checking the HDMI
00389       *        (adv7533 component); ID or LCD DSI (via TS ID) ID.
00390       * @param  None
00391       * @retval LCD ID
00392       */
00393     static uint16_t LCD_IO_GetID(void);
00394 
00395     /**
00396       * @brief  De-Initializes the BSP LCD Msp
00397       * Application can surcharge if needed this function implementation.
00398       */
00399     __weak void MspDeInit(void);
00400 
00401     /**
00402       * @brief  Initialize the BSP LCD Msp.
00403       * Application can surcharge if needed this function implementation
00404       */
00405     __weak void MspInit(void);
00406 
00407     /**
00408       * @brief  Draws a pixel on LCD.
00409       * @param  Xpos: X position
00410       * @param  Ypos: Y position
00411       * @param  RGB_Code: Pixel color in ARGB mode (8-8-8-8);
00412       */
00413     void DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code);
00414 
00415     /**
00416       * @brief  Draws a character on LCD.
00417       * @param  Xpos: Line where to display the character shape
00418       * @param  Ypos: Start column address
00419       * @param  c: Pointer to the character data
00420       */
00421     static void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c);
00422 
00423     /**
00424       * @brief  Fills a triangle (between 3 points);.
00425       * @param  x1: Point 1 X position
00426       * @param  y1: Point 1 Y position
00427       * @param  x2: Point 2 X position
00428       * @param  y2: Point 2 Y position
00429       * @param  x3: Point 3 X position
00430       * @param  y3: Point 3 Y position
00431       */
00432     static void FillTriangle(uint16_t x1, uint16_t x2, uint16_t x3, uint16_t y1, uint16_t y2, uint16_t y3);
00433 
00434     /**
00435       * @brief  Fills a buffer.
00436       * @param  LayerIndex: Layer index
00437       * @param  pDst: Pointer to destination buffer
00438       * @param  xSize: Buffer width
00439       * @param  ySize: Buffer height
00440       * @param  OffLine: Offset
00441       * @param  ColorIndex: Color index
00442       */
00443     static void LL_FillBuffer(uint32_t LayerIndex, void *pDst, uint32_t xSize, uint32_t ySize, uint32_t OffLine, uint32_t ColorIndex);
00444 
00445     /**
00446       * @brief  Converts a line to an ARGB8888 pixel format.
00447       * @param  pSrc: Pointer to source buffer
00448       * @param  pDst: Output color
00449       * @param  xSize: Buffer width
00450       * @param  ColorMode: Input color mode
00451       */
00452     static void LL_ConvertLineToARGB8888(void *pSrc, void *pDst, uint32_t xSize, uint32_t ColorMode);
00453 
00454 private:
00455 
00456 };
00457 
00458 #else
00459 #error "This class must be used with DISCO_F746NG board only."
00460 #endif // TARGET_DISCO_F746NG
00461 
00462 #endif