ePaperDisplay (ePD) gde021a1 driver. This ePD is present on the STMicroelectronics Discovery L053 board (STM32L0538-DISCO).
Dependents: DISCO-L053C8_ePD_demo DISCO-L053C8_ePD_demo Ruche_V1 DISCO-L053C8_ePD_demo ... more
GDE021A1 ePaper display Library.
EPD_GDE021A1.h@0:5d8241e6bd3b, 2015-04-28 (annotated)
- Committer:
- bcostm
- Date:
- Tue Apr 28 11:37:05 2015 +0000
- Revision:
- 0:5d8241e6bd3b
- Child:
- 1:6ee9c1afd6ec
First version. Based on epd gde021a1 driver present in STM32CubeL0 package.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:5d8241e6bd3b | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
bcostm | 0:5d8241e6bd3b | 2 | * |
bcostm | 0:5d8241e6bd3b | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
bcostm | 0:5d8241e6bd3b | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
bcostm | 0:5d8241e6bd3b | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
bcostm | 0:5d8241e6bd3b | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
bcostm | 0:5d8241e6bd3b | 7 | * Software is furnished to do so, subject to the following conditions: |
bcostm | 0:5d8241e6bd3b | 8 | * |
bcostm | 0:5d8241e6bd3b | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
bcostm | 0:5d8241e6bd3b | 10 | * substantial portions of the Software. |
bcostm | 0:5d8241e6bd3b | 11 | * |
bcostm | 0:5d8241e6bd3b | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
bcostm | 0:5d8241e6bd3b | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
bcostm | 0:5d8241e6bd3b | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
bcostm | 0:5d8241e6bd3b | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
bcostm | 0:5d8241e6bd3b | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
bcostm | 0:5d8241e6bd3b | 17 | */ |
bcostm | 0:5d8241e6bd3b | 18 | |
bcostm | 0:5d8241e6bd3b | 19 | #ifndef __EPD_GDE021A1_H |
bcostm | 0:5d8241e6bd3b | 20 | #define __EPD_GDE021A1_H |
bcostm | 0:5d8241e6bd3b | 21 | |
bcostm | 0:5d8241e6bd3b | 22 | #include "mbed.h" |
bcostm | 0:5d8241e6bd3b | 23 | #include "fontsepd.h" |
bcostm | 0:5d8241e6bd3b | 24 | |
bcostm | 0:5d8241e6bd3b | 25 | /** |
bcostm | 0:5d8241e6bd3b | 26 | * @brief EPD color |
bcostm | 0:5d8241e6bd3b | 27 | */ |
bcostm | 0:5d8241e6bd3b | 28 | #define EPD_COLOR_BLACK 0x00 |
bcostm | 0:5d8241e6bd3b | 29 | #define EPD_COLOR_DARKGRAY 0x55 |
bcostm | 0:5d8241e6bd3b | 30 | #define EPD_COLOR_LIGHTGRAY 0xAA |
bcostm | 0:5d8241e6bd3b | 31 | #define EPD_COLOR_WHITE 0xFF |
bcostm | 0:5d8241e6bd3b | 32 | |
bcostm | 0:5d8241e6bd3b | 33 | /** |
bcostm | 0:5d8241e6bd3b | 34 | * @brief Line mode structures definition |
bcostm | 0:5d8241e6bd3b | 35 | */ |
bcostm | 0:5d8241e6bd3b | 36 | typedef enum |
bcostm | 0:5d8241e6bd3b | 37 | { |
bcostm | 0:5d8241e6bd3b | 38 | CENTER_MODE = 0x01, |
bcostm | 0:5d8241e6bd3b | 39 | RIGHT_MODE = 0x02, |
bcostm | 0:5d8241e6bd3b | 40 | LEFT_MODE = 0x03 |
bcostm | 0:5d8241e6bd3b | 41 | } Text_AlignModeTypdef; |
bcostm | 0:5d8241e6bd3b | 42 | |
bcostm | 0:5d8241e6bd3b | 43 | /** |
bcostm | 0:5d8241e6bd3b | 44 | * ePaperDisplay on SPI |
bcostm | 0:5d8241e6bd3b | 45 | */ |
bcostm | 0:5d8241e6bd3b | 46 | class EPD_GDE021A1 |
bcostm | 0:5d8241e6bd3b | 47 | { |
bcostm | 0:5d8241e6bd3b | 48 | public: |
bcostm | 0:5d8241e6bd3b | 49 | /** |
bcostm | 0:5d8241e6bd3b | 50 | * Constructor |
bcostm | 0:5d8241e6bd3b | 51 | * @param cs EPD CS pin |
bcostm | 0:5d8241e6bd3b | 52 | * @param dc EPD DC pin |
bcostm | 0:5d8241e6bd3b | 53 | * @param rst EPD RESET pin |
bcostm | 0:5d8241e6bd3b | 54 | * @param bsy EPD BUSY pin |
bcostm | 0:5d8241e6bd3b | 55 | * @param pwr EPD POWER pin |
bcostm | 0:5d8241e6bd3b | 56 | * @param mosi SPI MOSI pin |
bcostm | 0:5d8241e6bd3b | 57 | * @param miso SPI MISO pin |
bcostm | 0:5d8241e6bd3b | 58 | * @param scl SPI SCLK pin |
bcostm | 0:5d8241e6bd3b | 59 | */ |
bcostm | 0:5d8241e6bd3b | 60 | EPD_GDE021A1(PinName cs, PinName dc, PinName rst, PinName bsy, PinName pwr, PinName spi_mosi, PinName spi_miso, PinName spi_scl); |
bcostm | 0:5d8241e6bd3b | 61 | |
bcostm | 0:5d8241e6bd3b | 62 | /** |
bcostm | 0:5d8241e6bd3b | 63 | * Destructor |
bcostm | 0:5d8241e6bd3b | 64 | */ |
bcostm | 0:5d8241e6bd3b | 65 | ~EPD_GDE021A1(); |
bcostm | 0:5d8241e6bd3b | 66 | |
bcostm | 0:5d8241e6bd3b | 67 | /** |
bcostm | 0:5d8241e6bd3b | 68 | * @brief Gets the EPD X size. |
bcostm | 0:5d8241e6bd3b | 69 | * @param None |
bcostm | 0:5d8241e6bd3b | 70 | * @retval EPD X size |
bcostm | 0:5d8241e6bd3b | 71 | */ |
bcostm | 0:5d8241e6bd3b | 72 | uint32_t GetXSize(void); |
bcostm | 0:5d8241e6bd3b | 73 | |
bcostm | 0:5d8241e6bd3b | 74 | /** |
bcostm | 0:5d8241e6bd3b | 75 | * @brief Gets the EPD Y size. |
bcostm | 0:5d8241e6bd3b | 76 | * @param None |
bcostm | 0:5d8241e6bd3b | 77 | * @retval EPD Y size |
bcostm | 0:5d8241e6bd3b | 78 | */ |
bcostm | 0:5d8241e6bd3b | 79 | uint32_t GetYSize(void); |
bcostm | 0:5d8241e6bd3b | 80 | |
bcostm | 0:5d8241e6bd3b | 81 | /** |
bcostm | 0:5d8241e6bd3b | 82 | * @brief Sets the Text Font. |
bcostm | 0:5d8241e6bd3b | 83 | * @param pFonts: specifies the layer font to be used. |
bcostm | 0:5d8241e6bd3b | 84 | * @retval None |
bcostm | 0:5d8241e6bd3b | 85 | */ |
bcostm | 0:5d8241e6bd3b | 86 | void SetFont(sFONT *pFonts); |
bcostm | 0:5d8241e6bd3b | 87 | |
bcostm | 0:5d8241e6bd3b | 88 | /** |
bcostm | 0:5d8241e6bd3b | 89 | * @brief Gets the Text Font. |
bcostm | 0:5d8241e6bd3b | 90 | * @param None. |
bcostm | 0:5d8241e6bd3b | 91 | * @retval the used layer font. |
bcostm | 0:5d8241e6bd3b | 92 | */ |
bcostm | 0:5d8241e6bd3b | 93 | sFONT *GetFont(void); |
bcostm | 0:5d8241e6bd3b | 94 | |
bcostm | 0:5d8241e6bd3b | 95 | /** |
bcostm | 0:5d8241e6bd3b | 96 | * @brief Clears the EPD. |
bcostm | 0:5d8241e6bd3b | 97 | * @param Color: Color of the background |
bcostm | 0:5d8241e6bd3b | 98 | * @retval None |
bcostm | 0:5d8241e6bd3b | 99 | */ |
bcostm | 0:5d8241e6bd3b | 100 | void Clear(uint16_t Color); |
bcostm | 0:5d8241e6bd3b | 101 | |
bcostm | 0:5d8241e6bd3b | 102 | /** |
bcostm | 0:5d8241e6bd3b | 103 | * @brief Displays one character. |
bcostm | 0:5d8241e6bd3b | 104 | * @param Xpos: start column address. |
bcostm | 0:5d8241e6bd3b | 105 | * @param Ypos: the Line where to display the character shape. |
bcostm | 0:5d8241e6bd3b | 106 | * @param Ascii: character ascii code, must be between 0x20 and 0x7E. |
bcostm | 0:5d8241e6bd3b | 107 | * @retval None |
bcostm | 0:5d8241e6bd3b | 108 | */ |
bcostm | 0:5d8241e6bd3b | 109 | void DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii); |
bcostm | 0:5d8241e6bd3b | 110 | |
bcostm | 0:5d8241e6bd3b | 111 | /** |
bcostm | 0:5d8241e6bd3b | 112 | * @brief Displays characters on the EPD. |
bcostm | 0:5d8241e6bd3b | 113 | * @param Xpos: X position |
bcostm | 0:5d8241e6bd3b | 114 | * @param Ypos: Y position |
bcostm | 0:5d8241e6bd3b | 115 | * @param Text: Pointer to string to display on EPD |
bcostm | 0:5d8241e6bd3b | 116 | * @param Mode: Display mode |
bcostm | 0:5d8241e6bd3b | 117 | * This parameter can be one of the following values: |
bcostm | 0:5d8241e6bd3b | 118 | * @arg CENTER_MODE |
bcostm | 0:5d8241e6bd3b | 119 | * @arg RIGHT_MODE |
bcostm | 0:5d8241e6bd3b | 120 | * @arg LEFT_MODE |
bcostm | 0:5d8241e6bd3b | 121 | * @retval None |
bcostm | 0:5d8241e6bd3b | 122 | */ |
bcostm | 0:5d8241e6bd3b | 123 | void DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode); |
bcostm | 0:5d8241e6bd3b | 124 | |
bcostm | 0:5d8241e6bd3b | 125 | /** |
bcostm | 0:5d8241e6bd3b | 126 | * @brief Displays a character on the EPD. |
bcostm | 0:5d8241e6bd3b | 127 | * @param Line: Line where to display the character shape |
bcostm | 0:5d8241e6bd3b | 128 | * This parameter can be one of the following values: |
bcostm | 0:5d8241e6bd3b | 129 | * @arg 0..8: if the Current fonts is Font8 |
bcostm | 0:5d8241e6bd3b | 130 | * @arg 0..5: if the Current fonts is Font12 |
bcostm | 0:5d8241e6bd3b | 131 | * @arg 0..3: if the Current fonts is Font16 |
bcostm | 0:5d8241e6bd3b | 132 | * @arg 0..2: if the Current fonts is Font20 |
bcostm | 0:5d8241e6bd3b | 133 | * @param ptr: Pointer to string to display on EPD |
bcostm | 0:5d8241e6bd3b | 134 | * @retval None |
bcostm | 0:5d8241e6bd3b | 135 | */ |
bcostm | 0:5d8241e6bd3b | 136 | void DisplayStringAtLine(uint16_t Line, uint8_t *ptr, Text_AlignModeTypdef Mode); |
bcostm | 0:5d8241e6bd3b | 137 | |
bcostm | 0:5d8241e6bd3b | 138 | /** |
bcostm | 0:5d8241e6bd3b | 139 | * @brief Draws an horizontal line. |
bcostm | 0:5d8241e6bd3b | 140 | * @param Xpos: X position |
bcostm | 0:5d8241e6bd3b | 141 | * @param Ypos: Y position |
bcostm | 0:5d8241e6bd3b | 142 | * @param Length: line length |
bcostm | 0:5d8241e6bd3b | 143 | * @retval None |
bcostm | 0:5d8241e6bd3b | 144 | */ |
bcostm | 0:5d8241e6bd3b | 145 | void DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); |
bcostm | 0:5d8241e6bd3b | 146 | |
bcostm | 0:5d8241e6bd3b | 147 | /** |
bcostm | 0:5d8241e6bd3b | 148 | * @brief Draws a vertical line. |
bcostm | 0:5d8241e6bd3b | 149 | * @param Xpos: X position |
bcostm | 0:5d8241e6bd3b | 150 | * @param Ypos: Y position |
bcostm | 0:5d8241e6bd3b | 151 | * @param Length: line length. |
bcostm | 0:5d8241e6bd3b | 152 | * @retval None |
bcostm | 0:5d8241e6bd3b | 153 | */ |
bcostm | 0:5d8241e6bd3b | 154 | void DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length); |
bcostm | 0:5d8241e6bd3b | 155 | |
bcostm | 0:5d8241e6bd3b | 156 | /** |
bcostm | 0:5d8241e6bd3b | 157 | * @brief Draws a rectangle. |
bcostm | 0:5d8241e6bd3b | 158 | * @param Xpos: X position |
bcostm | 0:5d8241e6bd3b | 159 | * @param Ypos: Y position |
bcostm | 0:5d8241e6bd3b | 160 | * @param Height: rectangle height |
bcostm | 0:5d8241e6bd3b | 161 | * @param Width: rectangle width |
bcostm | 0:5d8241e6bd3b | 162 | * @retval None |
bcostm | 0:5d8241e6bd3b | 163 | */ |
bcostm | 0:5d8241e6bd3b | 164 | void DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); |
bcostm | 0:5d8241e6bd3b | 165 | |
bcostm | 0:5d8241e6bd3b | 166 | /** |
bcostm | 0:5d8241e6bd3b | 167 | * @brief Displays a full rectangle. |
bcostm | 0:5d8241e6bd3b | 168 | * @param Xpos: X position. |
bcostm | 0:5d8241e6bd3b | 169 | * @param Ypos: Y position. |
bcostm | 0:5d8241e6bd3b | 170 | * @param Height: display rectangle height. |
bcostm | 0:5d8241e6bd3b | 171 | * @param Width: display rectangle width. |
bcostm | 0:5d8241e6bd3b | 172 | * @retval None |
bcostm | 0:5d8241e6bd3b | 173 | */ |
bcostm | 0:5d8241e6bd3b | 174 | void FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); |
bcostm | 0:5d8241e6bd3b | 175 | |
bcostm | 0:5d8241e6bd3b | 176 | /** |
bcostm | 0:5d8241e6bd3b | 177 | * @brief Draws an Image. |
bcostm | 0:5d8241e6bd3b | 178 | * @param Xpos: X position in the EPD |
bcostm | 0:5d8241e6bd3b | 179 | * @param Ypos: Y position in the EPD |
bcostm | 0:5d8241e6bd3b | 180 | * @param Xsize: X size in the EPD |
bcostm | 0:5d8241e6bd3b | 181 | * @param Ysize: Y size in the EPD |
bcostm | 0:5d8241e6bd3b | 182 | * @param pdata: Pointer to the Image address |
bcostm | 0:5d8241e6bd3b | 183 | * @retval None |
bcostm | 0:5d8241e6bd3b | 184 | */ |
bcostm | 0:5d8241e6bd3b | 185 | void DrawImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata); |
bcostm | 0:5d8241e6bd3b | 186 | |
bcostm | 0:5d8241e6bd3b | 187 | /** |
bcostm | 0:5d8241e6bd3b | 188 | * @brief Disables the clock and the charge pump. |
bcostm | 0:5d8241e6bd3b | 189 | * @param None |
bcostm | 0:5d8241e6bd3b | 190 | * @retval None |
bcostm | 0:5d8241e6bd3b | 191 | */ |
bcostm | 0:5d8241e6bd3b | 192 | void CloseChargePump(void); |
bcostm | 0:5d8241e6bd3b | 193 | |
bcostm | 0:5d8241e6bd3b | 194 | /** |
bcostm | 0:5d8241e6bd3b | 195 | * @brief Updates the display from the data located into the RAM. |
bcostm | 0:5d8241e6bd3b | 196 | * @param None |
bcostm | 0:5d8241e6bd3b | 197 | * @retval None |
bcostm | 0:5d8241e6bd3b | 198 | */ |
bcostm | 0:5d8241e6bd3b | 199 | void RefreshDisplay(void); |
bcostm | 0:5d8241e6bd3b | 200 | |
bcostm | 0:5d8241e6bd3b | 201 | private: |
bcostm | 0:5d8241e6bd3b | 202 | SPI _spi; |
bcostm | 0:5d8241e6bd3b | 203 | DigitalOut _cs; |
bcostm | 0:5d8241e6bd3b | 204 | DigitalOut _dc; |
bcostm | 0:5d8241e6bd3b | 205 | DigitalOut _rst; |
bcostm | 0:5d8241e6bd3b | 206 | DigitalIn _bsy; |
bcostm | 0:5d8241e6bd3b | 207 | DigitalOut _pwr; |
bcostm | 0:5d8241e6bd3b | 208 | |
bcostm | 0:5d8241e6bd3b | 209 | sFONT *pFont; |
bcostm | 0:5d8241e6bd3b | 210 | |
bcostm | 0:5d8241e6bd3b | 211 | void EPD_IO_WriteData(uint16_t RegValue); |
bcostm | 0:5d8241e6bd3b | 212 | void EPD_IO_WriteReg(uint8_t Reg); |
bcostm | 0:5d8241e6bd3b | 213 | uint16_t EPD_IO_ReadData(void); |
bcostm | 0:5d8241e6bd3b | 214 | |
bcostm | 0:5d8241e6bd3b | 215 | void gde021a1_Init(void); |
bcostm | 0:5d8241e6bd3b | 216 | void gde021a1_WriteReg(uint8_t EPD_Reg, uint8_t EPD_RegValue); |
bcostm | 0:5d8241e6bd3b | 217 | uint8_t gde021a1_ReadReg(uint8_t EPD_Reg); |
bcostm | 0:5d8241e6bd3b | 218 | void gde021a1_WritePixel(uint8_t HEX_Code); |
bcostm | 0:5d8241e6bd3b | 219 | void gde021a1_DrawImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata); |
bcostm | 0:5d8241e6bd3b | 220 | void gde021a1_RefreshDisplay(void); |
bcostm | 0:5d8241e6bd3b | 221 | void gde021a1_CloseChargePump(void); |
bcostm | 0:5d8241e6bd3b | 222 | void gde021a1_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); |
bcostm | 0:5d8241e6bd3b | 223 | uint16_t gde021a1_GetEpdPixelWidth(void); |
bcostm | 0:5d8241e6bd3b | 224 | uint16_t gde021a1_GetEpdPixelHeight(void); |
bcostm | 0:5d8241e6bd3b | 225 | |
bcostm | 0:5d8241e6bd3b | 226 | void DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c); |
bcostm | 0:5d8241e6bd3b | 227 | }; |
bcostm | 0:5d8241e6bd3b | 228 | |
bcostm | 0:5d8241e6bd3b | 229 | #endif |