ST / EPD_GDE021A1

Dependents:   DISCO-L053C8_ePD_demo DISCO-L053C8_ePD_demo Ruche_V1 DISCO-L053C8_ePD_demo ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EPD_GDE021A1.h Source File

EPD_GDE021A1.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 __EPD_GDE021A1_H
00020 #define __EPD_GDE021A1_H
00021 
00022 #include "mbed.h"
00023 #include "fontsepd.h"
00024 
00025 /**
00026   * @brief  EPD color
00027   */
00028 #define EPD_COLOR_BLACK         0x00
00029 #define EPD_COLOR_DARKGRAY      0x55
00030 #define EPD_COLOR_LIGHTGRAY     0xAA
00031 #define EPD_COLOR_WHITE         0xFF
00032 
00033 /**
00034   * @brief  Line mode structures definition
00035   */
00036 typedef enum
00037 {
00038   CENTER_MODE = 0x01,
00039   RIGHT_MODE  = 0x02,
00040   LEFT_MODE   = 0x03
00041 } Text_AlignModeTypdef;
00042 
00043 /**
00044  * ePaperDisplay on SPI
00045  *
00046  * Example:
00047  * @code
00048  * #include "mbed.h"
00049  * #include "EPD_GDE021A1.h"
00050  *
00051  * #define EPD_CS       PA_15
00052  * #define EPD_DC       PB_11
00053  * #define EPD_RESET    PB_2
00054  * #define EPD_BUSY     PA_8
00055  * #define EPD_POWER    PB_10
00056  * #define EPD_SPI_MOSI PB_5
00057  * #define EPD_SPI_MISO PB_4
00058  * #define EPD_SPI_SCK  PB_3
00059  * 
00060  * EPD_GDE021A1 epd(EPD_CS, EPD_DC, EPD_RESET, EPD_BUSY, EPD_POWER, EPD_SPI_MOSI, EPD_SPI_MISO, EPD_SPI_SCK);
00061  * 
00062  * int main()
00063  * {
00064  *   epd.Clear(EPD_COLOR_WHITE);  
00065  *   epd.DisplayStringAtLine(5, (uint8_t*)"MBED", CENTER_MODE);
00066  *   epd.DisplayStringAtLine(3, (uint8_t*)"Epaper display", LEFT_MODE);
00067  *   epd.DisplayStringAtLine(2, (uint8_t*)"demo", LEFT_MODE);
00068  *   epd.RefreshDisplay();
00069  *   wait(2);
00070  *  
00071  *   while(1) {
00072  *     led1 = !led1;
00073  *     wait(1);
00074  *   }
00075  * }
00076  * @endcode
00077  */
00078 class EPD_GDE021A1
00079 {
00080 public:
00081    /**
00082     * Constructor
00083     * @param cs   EPD CS pin
00084     * @param dc   EPD DC pin
00085     * @param rst  EPD RESET pin
00086     * @param bsy  EPD BUSY pin
00087     * @param pwr  EPD POWER pin
00088     * @param mosi SPI MOSI pin
00089     * @param miso SPI MISO pin
00090     * @param scl  SPI SCLK pin
00091     */
00092     EPD_GDE021A1(PinName cs, PinName dc, PinName rst, PinName bsy, PinName pwr, PinName spi_mosi, PinName spi_miso, PinName spi_scl);
00093 
00094    /**
00095     * Destructor
00096     */
00097     ~EPD_GDE021A1();
00098 
00099     /**
00100       * @brief  Gets the EPD X size.
00101       * @param  None
00102       * @retval EPD X size
00103       */
00104     uint32_t GetXSize(void);
00105 
00106     /**
00107       * @brief  Gets the EPD Y size.
00108       * @param  None   
00109       * @retval EPD Y size
00110       */
00111     uint32_t GetYSize(void);
00112 
00113    /**
00114     * @brief  Sets the Text Font.
00115     * @param  pFonts: specifies the layer font to be used.
00116     * @retval None
00117     */
00118     void SetFont(sFONT *pFonts);
00119 
00120     /**
00121       * @brief  Gets the Text Font.
00122       * @param  None.
00123       * @retval the used layer font.
00124       */
00125     sFONT *GetFont(void);
00126   
00127    /**
00128     * @brief  Clears the EPD.
00129     * @param  Color: Color of the background
00130     * @retval None
00131     */
00132     void Clear(uint16_t Color);
00133 
00134     /**
00135       * @brief  Displays one character.
00136       * @param  Xpos: start column address.
00137       * @param  Ypos: the Line where to display the character shape.
00138       * @param  Ascii: character ascii code, must be between 0x20 and 0x7E.
00139       * @retval None
00140       */
00141     void DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii);
00142     
00143     /**
00144       * @brief  Displays characters on the EPD.
00145       * @param  Xpos: X position
00146       * @param  Ypos: Y position
00147       * @param  Text: Pointer to string to display on EPD
00148       * @param  Mode: Display mode
00149       *          This parameter can be one of the following values:
00150       *            @arg  CENTER_MODE
00151       *            @arg  RIGHT_MODE
00152       *            @arg  LEFT_MODE  
00153       * @retval None
00154       */
00155     void DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode);
00156 
00157     /**
00158       * @brief  Displays a character on the EPD.
00159       * @param  Line: Line where to display the character shape
00160       *          This parameter can be one of the following values:
00161       *            @arg  0..8: if the Current fonts is Font8
00162       *            @arg  0..5: if the Current fonts is Font12
00163       *            @arg  0..3: if the Current fonts is Font16
00164       *            @arg  0..2: if the Current fonts is Font20
00165       * @param  ptr: Pointer to string to display on EPD
00166       * @retval None
00167       */
00168     void DisplayStringAtLine(uint16_t Line, uint8_t *ptr, Text_AlignModeTypdef Mode);
00169 
00170     /**
00171       * @brief  Draws an horizontal line.
00172       * @param  Xpos: X position 
00173       * @param  Ypos: Y position
00174       * @param  Length: line length
00175       * @retval None
00176       */
00177     void DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
00178       
00179     /**
00180       * @brief  Draws a vertical line.
00181       * @param  Xpos: X position
00182       * @param  Ypos: Y position
00183       * @param  Length: line length.
00184       * @retval None
00185       */
00186     void DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length);
00187       
00188     /**
00189       * @brief  Draws a rectangle.
00190       * @param  Xpos: X position
00191       * @param  Ypos: Y position
00192       * @param  Height: rectangle height
00193       * @param  Width: rectangle width
00194       * @retval None
00195       */
00196     void DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
00197 
00198     /**
00199       * @brief  Displays a full rectangle.
00200       * @param  Xpos: X position.
00201       * @param  Ypos: Y position.
00202       * @param  Height: display rectangle height.
00203       * @param  Width: display rectangle width.
00204       * @retval None
00205       */
00206     void FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
00207 
00208     /**
00209       * @brief  Draws an Image.
00210       * @param  Xpos: X position in the EPD
00211       * @param  Ypos: Y position in the EPD
00212       * @param  Xsize: X size in the EPD
00213       * @param  Ysize: Y size in the EPD
00214       * @param  pdata: Pointer to the Image address
00215       * @retval None
00216       */
00217     void DrawImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata);
00218 
00219     /**
00220       * @brief  Disables the clock and the charge pump.
00221       * @param  None
00222       * @retval None
00223       */
00224     void CloseChargePump(void);
00225 
00226     /**
00227       * @brief  Updates the display from the data located into the RAM.
00228       * @param  None
00229       * @retval None
00230       */
00231     void RefreshDisplay(void);
00232   
00233 private:
00234     SPI _spi;
00235     DigitalOut _cs;
00236     DigitalOut _dc;
00237     DigitalOut _rst;
00238     DigitalIn _bsy;
00239     DigitalOut _pwr;
00240 
00241     sFONT *pFont;
00242 
00243     void EPD_IO_WriteData(uint16_t RegValue);
00244     void EPD_IO_WriteReg(uint8_t Reg);
00245     uint16_t EPD_IO_ReadData(void);
00246 
00247     void gde021a1_Init(void);
00248     void gde021a1_WriteReg(uint8_t EPD_Reg, uint8_t EPD_RegValue);
00249     uint8_t gde021a1_ReadReg(uint8_t EPD_Reg);
00250     void gde021a1_WritePixel(uint8_t HEX_Code);
00251     void gde021a1_DrawImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata);
00252     void gde021a1_RefreshDisplay(void);
00253     void gde021a1_CloseChargePump(void);
00254     void gde021a1_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
00255     uint16_t gde021a1_GetEpdPixelWidth(void);
00256     uint16_t gde021a1_GetEpdPixelHeight(void);
00257 
00258     void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c);
00259 };
00260 
00261 #endif