This class drives the LCD display present on the DISCO_F469NI board.

Dependents:   DISCO-F469NI_LCDTS_GUI_demo DISCO-F469NI_LCD_demo Configurable_Robots DISCO-F469NI_LCD_demo ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LCD_DISCO_F469NI.h Source File

LCD_DISCO_F469NI.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_F469NI_H
00020 #define __LCD_DISCO_F469NI_H
00021 
00022 #ifdef TARGET_DISCO_F469NI
00023 
00024 #include "mbed.h"
00025 #include "stm32469i_discovery_lcd.h"
00026 
00027 /*
00028   This class drives the LCD display (xxxxxx) present on DISCO_F469NI board.
00029 
00030   Usage:
00031 
00032   #include "mbed.h"
00033   #include "LCD_DISCO_F469NI.h"
00034 
00035   LCD_DISCO_F469NI lcd;
00036 
00037   int main()
00038   {
00039       lcd.Clear(LCD_COLOR_BLUE);
00040       lcd.SetBackColor(LCD_COLOR_BLUE);
00041       lcd.SetTextColor(LCD_COLOR_WHITE);
00042       lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"HELLO", CENTER_MODE);
00043       while(1)
00044       {
00045       }
00046   }
00047 */
00048 class LCD_DISCO_F469NI
00049 {
00050   
00051 public:
00052   //! Constructor
00053   LCD_DISCO_F469NI();
00054 
00055   //! Destructor
00056   ~LCD_DISCO_F469NI();
00057 
00058 
00059   /**
00060     * @brief  Initializes the DSI LCD.
00061     * @param  None
00062     * @retval LCD state
00063     */
00064   uint8_t Init(void);
00065 
00066   /**
00067     * @brief  Initializes the DSI LCD. 
00068     * The initialization is done as below:
00069     *     - DSI PLL initialization
00070     *     - DSI initialization
00071     *     - LTDC initialization
00072     *     - OTM8009A LCD Display IC Driver initialization
00073     * @param  None
00074     * @retval LCD state
00075     */
00076   uint8_t InitEx(LCD_OrientationTypeDef orientation);
00077 
00078   /**
00079     * @brief  BSP LCD Reset
00080     *         Hw reset the LCD DSI activating its XRES signal (active low for some time);
00081     *         and desactivating it later.
00082     *         This signal is only cabled on Discovery Rev B and beyond.
00083     */
00084   void Reset(void);
00085 
00086   /**
00087     * @brief  Gets the LCD X size.
00088     * @retval Used LCD X size
00089     */
00090   uint32_t GetXSize(void);
00091 
00092   /**
00093     * @brief  Gets the LCD Y size.
00094     * @retval Used LCD Y size
00095     */
00096   uint32_t GetYSize(void);
00097 
00098   /**
00099     * @brief  Set the LCD X size.
00100     * @param  imageWidthPixels : uint32_t image width in pixels unit
00101     * @retval None
00102     */
00103   void SetXSize(uint32_t imageWidthPixels);
00104 
00105   /**
00106     * @brief  Set the LCD Y size.
00107     * @param  imageHeightPixels : uint32_t image height in lines unit
00108     */
00109   void SetYSize(uint32_t imageHeightPixels);
00110 
00111   /**
00112     * @brief  Initializes the LCD layers.
00113     * @param  LayerIndex: Layer foreground or background
00114     * @param  FB_Address: Layer frame buffer
00115     * @retval None
00116     */
00117   void LayerDefaultInit(uint16_t LayerIndex, uint32_t FB_Address);
00118 
00119   /**
00120     * @brief  Selects the LCD Layer.
00121     * @param  LayerIndex: Layer foreground or background
00122     */
00123   void SelectLayer(uint32_t LayerIndex);
00124 
00125   /**
00126     * @brief  Sets an LCD Layer visible
00127     * @param  LayerIndex: Visible Layer
00128     * @param  State: New state of the specified layer
00129     *          This parameter can be one of the following values:
00130     *            @arg  ENABLE
00131     *            @arg  DISABLE
00132     */
00133   void SetLayerVisible(uint32_t LayerIndex, FunctionalState State);
00134 
00135   /**
00136     * @brief  Configures the transparency.
00137     * @param  LayerIndex: Layer foreground or background.
00138     * @param  Transparency: Transparency
00139     *           This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF
00140     */
00141   void SetTransparency(uint32_t LayerIndex, uint8_t Transparency);
00142 
00143   /**
00144     * @brief  Sets an LCD layer frame buffer address.
00145     * @param  LayerIndex: Layer foreground or background
00146     * @param  Address: New LCD frame buffer value
00147     */
00148   void SetLayerAddress(uint32_t LayerIndex, uint32_t Address);
00149 
00150   /**
00151     * @brief  Sets display window.
00152     * @param  LayerIndex: Layer index
00153     * @param  Xpos: LCD X position
00154     * @param  Ypos: LCD Y position
00155     * @param  Width: LCD window width
00156     * @param  Height: LCD window height
00157     */
00158   void SetLayerWindow(uint16_t LayerIndex, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
00159 
00160   /**
00161     * @brief  Configures and sets the color keying.
00162     * @param  LayerIndex: Layer foreground or background
00163     * @param  RGBValue: Color reference
00164     */
00165   void SetColorKeying(uint32_t LayerIndex, uint32_t RGBValue);
00166 
00167   /**
00168     * @brief  Disables the color keying.
00169     * @param  LayerIndex: Layer foreground or background
00170     */
00171   void ResetColorKeying(uint32_t LayerIndex);
00172 
00173   /**
00174     * @brief  Sets the LCD text color.
00175     * @param  Color: Text color code ARGB(8-8-8-8);
00176     */
00177   void SetTextColor(uint32_t Color);
00178 
00179   /**
00180     * @brief  Gets the LCD text color.
00181     * @retval Used text color.
00182     */
00183   uint32_t GetTextColor(void);
00184 
00185   /**
00186     * @brief  Sets the LCD background color.
00187     * @param  Color: Layer background color code ARGB(8-8-8-8);
00188     */
00189   void SetBackColor(uint32_t Color);
00190 
00191   /**
00192     * @brief  Gets the LCD background color.
00193     * @retval Used background color
00194     */
00195   uint32_t GetBackColor(void);
00196 
00197   /**
00198     * @brief  Sets the LCD text font.
00199     * @param  fonts: Layer font to be used
00200     */
00201   void SetFont(sFONT *fonts);
00202 
00203   /**
00204     * @brief  Gets the LCD text font.
00205     * @retval Used layer font
00206     */
00207   sFONT *GetFont(void);
00208 
00209   /**
00210     * @brief  Reads an LCD pixel.
00211     * @param  Xpos: X position
00212     * @param  Ypos: Y position
00213     * @retval RGB pixel color
00214     */
00215   uint32_t ReadPixel(uint16_t Xpos, uint16_t Ypos);
00216 
00217   /**
00218     * @brief  Clears the whole currently active layer of LTDC.
00219     * @param  Color: Color of the background
00220     */
00221   void Clear(uint32_t Color);
00222 
00223   /**
00224     * @brief  Clears the selected line in currently active layer.
00225     * @param  Line: Line to be cleared
00226     */
00227   void ClearStringLine(uint32_t Line);
00228 
00229   /**
00230     * @brief  Displays one character in currently active layer.
00231     * @param  Xpos: Start column address
00232     * @param  Ypos: Line where to display the character shape.
00233     * @param  Ascii: Character ascii code
00234     *           This parameter must be a number between Min_Data = 0x20 and Max_Data = 0x7E
00235     */
00236   void DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii);
00237 
00238   /**
00239     * @brief  Displays characters in currently active layer.
00240     * @param  Xpos: X position (in pixel);
00241     * @param  Ypos: Y position (in pixel);
00242     * @param  Text: Pointer to string to display on LCD
00243     * @param  Mode: Display mode
00244     *          This parameter can be one of the following values:
00245     *            @arg  CENTER_MODE
00246     *            @arg  RIGHT_MODE
00247     *            @arg  LEFT_MODE
00248     */
00249   void DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode);
00250 
00251   /**
00252     * @brief  Displays a maximum of 60 characters on the LCD.
00253     * @param  Line: Line where to display the character shape
00254     * @param  ptr: Pointer to string to display on LCD
00255     */
00256   void DisplayStringAtLine(uint16_t Line, uint8_t *ptr);
00257 
00258   /**
00259     * @brief  Draws an horizontal line in currently active layer.
00260     * @param  Xpos: X position
00261     * @param  Ypos: Y position
00262     * @param  Length: Line length
00263     */
00264   void DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
00265 
00266   /**
00267     * @brief  Draws a vertical line in currently active layer.
00268     * @param  Xpos: X position
00269     * @param  Ypos: Y position
00270     * @param  Length: Line length
00271     */
00272   void DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
00273 
00274   /**
00275     * @brief  Draws an uni-line (between two points); in currently active layer.
00276     * @param  x1: Point 1 X position
00277     * @param  y1: Point 1 Y position
00278     * @param  x2: Point 2 X position
00279     * @param  y2: Point 2 Y position
00280     */
00281   void DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
00282 
00283   /**
00284     * @brief  Draws a rectangle in currently active layer.
00285     * @param  Xpos: X position
00286     * @param  Ypos: Y position
00287     * @param  Width: Rectangle width
00288     * @param  Height: Rectangle height
00289     */
00290   void DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
00291 
00292   /**
00293     * @brief  Draws a circle in currently active layer.
00294     * @param  Xpos: X position
00295     * @param  Ypos: Y position
00296     * @param  Radius: Circle radius
00297     */
00298   void DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
00299 
00300   /**
00301     * @brief  Draws an poly-line (between many points); in currently active layer.
00302     * @param  Points: Pointer to the points array
00303     * @param  PointCount: Number of points
00304     */
00305   void DrawPolygon(pPoint Points, uint16_t PointCount);
00306 
00307   /**
00308     * @brief  Draws an ellipse on LCD in currently active layer.
00309     * @param  Xpos: X position
00310     * @param  Ypos: Y position
00311     * @param  XRadius: Ellipse X radius
00312     * @param  YRadius: Ellipse Y radius
00313     */
00314   void DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
00315 
00316   /**
00317     * @brief  Draws a bitmap picture loaded in the internal Flash (32 bpp); in currently active layer.
00318     * @param  Xpos: Bmp X position in the LCD
00319     * @param  Ypos: Bmp Y position in the LCD
00320     * @param  pbmp: Pointer to Bmp picture address in the internal Flash
00321     */
00322   void DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp);
00323 
00324   /**
00325     * @brief  Draws a full rectangle in currently active layer.
00326     * @param  Xpos: X position
00327     * @param  Ypos: Y position
00328     * @param  Width: Rectangle width
00329     * @param  Height: Rectangle height
00330     */
00331   void FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
00332 
00333   /**
00334     * @brief  Draws a full circle in currently active layer.
00335     * @param  Xpos: X position
00336     * @param  Ypos: Y position
00337     * @param  Radius: Circle radius
00338     */
00339   void FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
00340 
00341   /**
00342     * @brief  Draws a full poly-line (between many points); in currently active layer.
00343     * @param  Points: Pointer to the points array
00344     * @param  PointCount: Number of points
00345     */
00346   void FillPolygon(pPoint Points, uint16_t PointCount);
00347 
00348   /**
00349     * @brief  Draws a full ellipse in currently active layer.
00350     * @param  Xpos: X position
00351     * @param  Ypos: Y position
00352     * @param  XRadius: Ellipse X radius
00353     * @param  YRadius: Ellipse Y radius
00354     */
00355   void FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius);
00356 
00357   /**
00358     * @brief  Switch back on the display if was switched off by previous call of DisplayOff();.
00359     *         Exit DSI ULPM mode if was allowed and configured in Dsi Configuration.
00360     */
00361   void DisplayOn(void);
00362 
00363   /**
00364     * @brief  Switch Off the display.
00365     *         Enter DSI ULPM mode if was allowed and configured in Dsi Configuration.
00366     */
00367   void DisplayOff(void);
00368 
00369   /**
00370     * @brief  Draws a pixel on LCD.
00371     * @param  Xpos: X position
00372     * @param  Ypos: Y position
00373     * @param  RGB_Code: Pixel color in ARGB mode (8-8-8-8);
00374     */
00375   void DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code);
00376 
00377 private:
00378 
00379 };
00380 
00381 #else
00382 #error "This class must be used with DISCO_F469NI board only."
00383 #endif // TARGET_DISCO_F469NI
00384 
00385 #endif