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
EPD_GDE021A1.cpp
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 #include "EPD_GDE021A1.h" 00020 00021 /** 00022 * @brief GDE021A1 Size 00023 */ 00024 #define GDE021A1_EPD_PIXEL_WIDTH ((uint16_t)172) 00025 #define GDE021A1_EPD_PIXEL_HEIGHT ((uint16_t)18) 00026 00027 /** 00028 * @brief GDE021A1 Registers 00029 */ 00030 #define EPD_REG_0 0x00 /* Status Read */ 00031 #define EPD_REG_1 0x01 /* Driver Output Control */ 00032 #define EPD_REG_3 0x03 /* Gate driving voltage control */ 00033 #define EPD_REG_4 0x04 /* Source driving coltage control */ 00034 #define EPD_REG_7 0x07 /* Display Control */ 00035 #define EPD_REG_11 0x0B /* Gate and Sorce non overlap period COntrol */ 00036 #define EPD_REG_15 0x0F /* Gate scan start */ 00037 #define EPD_REG_16 0x10 /* Deep Sleep mode setting */ 00038 #define EPD_REG_17 0x11 /* Data Entry Mode Setting */ 00039 #define EPD_REG_18 0x12 /* SWRESET */ 00040 #define EPD_REG_26 0x1A /* Temperature Sensor Control (Write to Temp Register) */ 00041 #define EPD_REG_27 0x1B /* Temperature Sensor Control(Read from Temp Register) */ 00042 #define EPD_REG_28 0x1C /* Temperature Sensor Control(Write Command to Temp sensor) */ 00043 #define EPD_REG_29 0x1D /* Temperature Sensor Control(Load temperature register with temperature sensor reading) */ 00044 #define EPD_REG_32 0x20 /* Master activation */ 00045 #define EPD_REG_33 0x21 /* Display update */ 00046 #define EPD_REG_34 0x22 /* Display update control 2 */ 00047 #define EPD_REG_36 0x24 /* write RAM */ 00048 #define EPD_REG_37 0x25 /* Read RAM */ 00049 #define EPD_REG_40 0x28 /* VCOM sense */ 00050 #define EPD_REG_41 0x29 /* VCOM Sense duration */ 00051 #define EPD_REG_42 0x2A /* VCOM OTP program */ 00052 #define EPD_REG_44 0x2C /* Write VCOMregister */ 00053 #define EPD_REG_45 0x2D /* Read OTP registers */ 00054 #define EPD_REG_48 0x30 /* Program WS OTP */ 00055 #define EPD_REG_50 0x32 /* Write LUT register */ 00056 #define EPD_REG_51 0x33 /* Read LUT register */ 00057 #define EPD_REG_54 0x36 /* Program OTP selection */ 00058 #define EPD_REG_55 0x37 /* Proceed OTP selection */ 00059 #define EPD_REG_58 0x3A /* Set dummy line pulse period */ 00060 #define EPD_REG_59 0x3B /* Set Gate line width */ 00061 #define EPD_REG_60 0x3C /* Select Border waveform */ 00062 #define EPD_REG_68 0x44 /* Set RAM X - Address Start / End Position */ 00063 #define EPD_REG_69 0x45 /* Set RAM Y - Address Start / End Position */ 00064 #define EPD_REG_78 0x4E /* Set RAM X Address Counter */ 00065 #define EPD_REG_79 0x4F /* Set RAM Y Address Counter */ 00066 #define EPD_REG_240 0xF0 /* Booster Set Internal Feedback Selection */ 00067 #define EPD_REG_255 0xFF /* NOP */ 00068 00069 /* Look-up table for the epaper (90 bytes) */ 00070 const unsigned char WF_LUT[]={ 00071 0x82,0x00,0x00,0x00,0xAA,0x00,0x00,0x00, 00072 0xAA,0xAA,0x00,0x00,0xAA,0xAA,0xAA,0x00, 00073 0x55,0xAA,0xAA,0x00,0x55,0x55,0x55,0x55, 00074 0xAA,0xAA,0xAA,0xAA,0x55,0x55,0x55,0x55, 00075 0xAA,0xAA,0xAA,0xAA,0x15,0x15,0x15,0x15, 00076 0x05,0x05,0x05,0x05,0x01,0x01,0x01,0x01, 00077 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 00078 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 00079 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 00080 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 00081 0x41,0x45,0xF1,0xFF,0x5F,0x55,0x01,0x00, 00082 0x00,0x00,}; 00083 00084 // Constructor 00085 EPD_GDE021A1::EPD_GDE021A1(PinName cs, PinName dc, PinName rst, PinName bsy, PinName pwr, PinName spi_mosi, PinName spi_miso, PinName spi_sck) : 00086 _cs(cs, 1), 00087 _dc(dc, 1), 00088 _rst(rst, 1), 00089 _bsy(bsy, PullDown), 00090 _pwr(pwr, 1), 00091 _spi(spi_mosi, spi_miso, spi_sck) 00092 { 00093 _pwr = 0; 00094 _cs = 0; 00095 _cs = 1; 00096 _rst = 1; 00097 00098 wait_ms(10); 00099 00100 _spi.format(8); 00101 _spi.frequency(1000000); 00102 00103 gde021a1_Init(); 00104 00105 Clear(EPD_COLOR_WHITE); 00106 00107 SetFont(&Font12); 00108 } 00109 00110 // Destructor 00111 EPD_GDE021A1::~EPD_GDE021A1() { } 00112 00113 //================================================================================================================= 00114 // Public methods 00115 //================================================================================================================= 00116 00117 uint32_t EPD_GDE021A1::GetXSize(void) 00118 { 00119 return(gde021a1_GetEpdPixelWidth()); 00120 } 00121 00122 uint32_t EPD_GDE021A1::GetYSize(void) 00123 { 00124 return(gde021a1_GetEpdPixelHeight()); 00125 } 00126 00127 void EPD_GDE021A1::SetFont(sFONT *pFonts) 00128 { 00129 pFont = pFonts; 00130 } 00131 00132 sFONT *EPD_GDE021A1::GetFont(void) 00133 { 00134 return pFont; 00135 } 00136 00137 void EPD_GDE021A1::Clear(uint16_t Color) 00138 { 00139 uint32_t index = 0; 00140 00141 gde021a1_SetDisplayWindow(0, 0, 171, 17); 00142 00143 for(index = 0; index < 3096; index++) 00144 { 00145 gde021a1_WritePixel(Color); 00146 } 00147 } 00148 00149 void EPD_GDE021A1::DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii) 00150 { 00151 Ascii -= 32; 00152 00153 DrawChar(Xpos, Ypos, &pFont->table[Ascii * ((pFont->Height) * (pFont->Width))]); 00154 } 00155 00156 void EPD_GDE021A1::DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode) 00157 { 00158 uint16_t refcolumn = 1, i = 0; 00159 uint32_t size = 0, xsize = 0; 00160 uint8_t *ptr = Text; 00161 00162 /* Get the text size */ 00163 while (*ptr++) size ++ ; 00164 00165 /* Characters number per line */ 00166 xsize = (GetXSize()/pFont->Width); 00167 00168 switch (Mode) 00169 { 00170 case CENTER_MODE: 00171 { 00172 refcolumn = Xpos + ((xsize - size)* pFont->Width) / 2; 00173 break; 00174 } 00175 case LEFT_MODE: 00176 { 00177 refcolumn = Xpos; 00178 break; 00179 } 00180 case RIGHT_MODE: 00181 { 00182 refcolumn = - Xpos + ((xsize - size)*pFont->Width); 00183 break; 00184 } 00185 default: 00186 { 00187 refcolumn = Xpos; 00188 break; 00189 } 00190 } 00191 00192 /* Send the string character by character on EPD */ 00193 while ((*Text != 0) & (((GetXSize() - (i*pFont->Width)) & 0xFFFF) >= pFont->Width)) 00194 { 00195 /* Display one character on EPD */ 00196 DisplayChar(refcolumn, Ypos, *Text); 00197 /* Decrement the column position by 16 */ 00198 refcolumn += pFont->Width; 00199 /* Point on the next character */ 00200 Text++; 00201 i++; 00202 } 00203 } 00204 00205 void EPD_GDE021A1::DisplayStringAtLine(uint16_t Line, uint8_t *ptr, Text_AlignModeTypdef Mode) 00206 { 00207 DisplayStringAt(0, LINE(Line), ptr, Mode); 00208 } 00209 00210 void EPD_GDE021A1::DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) 00211 { 00212 uint32_t index = 0; 00213 00214 gde021a1_SetDisplayWindow(Xpos, Ypos, Xpos + Length, Ypos); 00215 00216 for(index = 0; index < Length; index++) 00217 { 00218 /* Prepare the register to write data on the RAM */ 00219 gde021a1_WritePixel(0x3F); 00220 } 00221 } 00222 00223 void EPD_GDE021A1::DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length) 00224 { 00225 uint32_t index = 0; 00226 00227 gde021a1_SetDisplayWindow(Xpos, Ypos, Xpos, Ypos + Length); 00228 00229 for(index = 0; index < Length; index++) 00230 { 00231 /* Prepare the register to write data on the RAM */ 00232 gde021a1_WritePixel(0x00); 00233 } 00234 } 00235 00236 void EPD_GDE021A1::DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) 00237 { 00238 /* Draw horizontal lines */ 00239 DrawHLine(Xpos, Ypos, Width); 00240 DrawHLine(Xpos, (Ypos + Height), (Width + 1)); 00241 00242 /* Draw vertical lines */ 00243 DrawVLine(Xpos, Ypos, Height); 00244 DrawVLine((Xpos + Width), Ypos , Height); 00245 } 00246 00247 void EPD_GDE021A1::FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) 00248 { 00249 uint16_t index = 0; 00250 00251 /* Set the rectangle */ 00252 gde021a1_SetDisplayWindow(Xpos, Ypos, (Xpos + Width), (Ypos + Height)); 00253 00254 for(index = 0; index < 3096; index++) 00255 { 00256 gde021a1_WritePixel(0xFF); 00257 } 00258 } 00259 00260 void EPD_GDE021A1::DrawImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata) 00261 { 00262 /* Set display window */ 00263 gde021a1_SetDisplayWindow(Xpos, Ypos, (Xpos+Ysize-1), (Ypos+(Xsize/4)-1)); 00264 00265 gde021a1_DrawImage(Xpos, Ypos, Xsize, Ysize, pdata); 00266 00267 gde021a1_SetDisplayWindow(0, 0, GetXSize(), GetYSize()); 00268 } 00269 00270 void EPD_GDE021A1::CloseChargePump(void) 00271 { 00272 /* Close charge pump */ 00273 gde021a1_CloseChargePump(); 00274 00275 wait_ms(400); 00276 } 00277 00278 /** 00279 * @brief Updates the display from the data located into the RAM. 00280 * @param None 00281 * @retval None 00282 */ 00283 void EPD_GDE021A1::RefreshDisplay(void) 00284 { 00285 gde021a1_RefreshDisplay(); 00286 00287 /* Poll on the BUSY signal and wait for the EPD to be ready */ 00288 while (_bsy != 0); 00289 00290 _rst = 1; 00291 00292 wait_ms(10); 00293 } 00294 00295 //================================================================================================================= 00296 // Private methods 00297 //================================================================================================================= 00298 00299 void EPD_GDE021A1::EPD_IO_WriteData(uint16_t RegValue) 00300 { 00301 _cs = 0; 00302 _dc = 1; 00303 _spi.write(RegValue); 00304 _cs = 1; 00305 } 00306 00307 void EPD_GDE021A1::EPD_IO_WriteReg(uint8_t Reg) 00308 { 00309 _cs = 0; 00310 _dc = 0; 00311 _spi.write(Reg); 00312 _cs = 1; 00313 } 00314 00315 uint16_t EPD_GDE021A1::EPD_IO_ReadData(void) 00316 { 00317 _cs = 0; 00318 _cs = 1; 00319 return _spi.write(0xFF); 00320 } 00321 00322 //================================================================================================================= 00323 00324 /** 00325 * @brief Initialize the GDE021A1 EPD Component. 00326 * @param None 00327 * @retval None 00328 */ 00329 void EPD_GDE021A1::gde021a1_Init(void) 00330 { 00331 uint8_t nb_bytes = 0; 00332 00333 EPD_IO_WriteReg(EPD_REG_16); /* Deep sleep mode disable */ 00334 EPD_IO_WriteData(0x00); 00335 EPD_IO_WriteReg(EPD_REG_17); /* Data Entry Mode Setting */ 00336 EPD_IO_WriteData(0x03); 00337 EPD_IO_WriteReg(EPD_REG_68); /* Set the RAM X start/end address */ 00338 EPD_IO_WriteData(0x00); /* RAM X address start = 00h */ 00339 EPD_IO_WriteData(0x11); /* RAM X adress end = 11h (17 * 4pixels by address = 72 pixels) */ 00340 EPD_IO_WriteReg(EPD_REG_69); /* Set the RAM Y start/end address */ 00341 EPD_IO_WriteData(0x00); /* RAM Y address start = 0 */ 00342 EPD_IO_WriteData(0xAB); /* RAM Y adress end = 171 */ 00343 EPD_IO_WriteReg(EPD_REG_78); /* Set RAM X Address counter */ 00344 EPD_IO_WriteData(0x00); 00345 EPD_IO_WriteReg(EPD_REG_79); /* Set RAM Y Address counter */ 00346 EPD_IO_WriteData(0x00); 00347 EPD_IO_WriteReg(EPD_REG_240); /* Booster Set Internal Feedback Selection */ 00348 EPD_IO_WriteData(0x1F); 00349 EPD_IO_WriteReg(EPD_REG_33); /* Disable RAM bypass and set GS transition to GSA = GS0 and GSB = GS3 */ 00350 EPD_IO_WriteData(0x03); 00351 EPD_IO_WriteReg(EPD_REG_44); /* Write VCOMregister */ 00352 EPD_IO_WriteData(0xA0); 00353 EPD_IO_WriteReg(EPD_REG_60); /* Border waveform */ 00354 EPD_IO_WriteData(0x64); 00355 EPD_IO_WriteReg(EPD_REG_50); /* Write LUT register */ 00356 00357 for (nb_bytes=0; nb_bytes<90; nb_bytes++) 00358 { 00359 EPD_IO_WriteData(WF_LUT[nb_bytes]); 00360 } 00361 } 00362 00363 /** 00364 * @brief Writes to the selected EPD register. 00365 * @param EPD_Reg: Address of the selected register. 00366 * @param EPD_RegValue: value to write to the selected register. 00367 * @retval None 00368 */ 00369 void EPD_GDE021A1::gde021a1_WriteReg(uint8_t EPD_Reg, uint8_t EPD_RegValue) 00370 { 00371 EPD_IO_WriteReg(EPD_Reg); 00372 00373 EPD_IO_WriteData(EPD_RegValue); 00374 } 00375 00376 /** 00377 * @brief Reads the selected EPD Register. 00378 * @param EPD_Reg: address of the selected register 00379 * @retval EPD Register Value 00380 */ 00381 uint8_t EPD_GDE021A1::gde021a1_ReadReg(uint8_t EPD_Reg) 00382 { 00383 /* Write 8-bit Index (then Read Reg) */ 00384 EPD_IO_WriteReg(EPD_Reg); 00385 00386 /* Read 8-bit Reg */ 00387 return (EPD_IO_ReadData()); 00388 } 00389 00390 /** 00391 * @brief Writes 4 dots. 00392 * @param HEX_Code: specifies the Data to write. 00393 * @retval None 00394 */ 00395 void EPD_GDE021A1::gde021a1_WritePixel(uint8_t HEX_Code) 00396 { 00397 /* Prepare the register to write data on the RAM */ 00398 EPD_IO_WriteReg(EPD_REG_36); 00399 00400 /* Send the data to write */ 00401 EPD_IO_WriteData(HEX_Code); 00402 } 00403 00404 /** 00405 * @brief Displays picture.. 00406 * @param pdata: picture address. 00407 * @param Xpos: Image X position in the EPD 00408 * @param Ypos: Image Y position in the EPD 00409 * @param Xsize: Image X size in the EPD 00410 * @note Xsize have to be a multiple of 4 00411 * @param Ysize: Image Y size in the EPD 00412 * @retval None 00413 */ 00414 void EPD_GDE021A1::gde021a1_DrawImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata) 00415 { 00416 uint32_t i, j = 0; 00417 uint8_t pixels_4 = 0; 00418 uint8_t pixels_4_grey[4] = {0}; 00419 uint8_t nb_4_pixels, data_res = 0; 00420 00421 /* Prepare the register to write data on the RAM */ 00422 EPD_IO_WriteReg(EPD_REG_36); 00423 00424 /* X size is a multiple of 8 */ 00425 if ((Xsize % 8) == 0) 00426 { 00427 for (i= 0; i< ((((Ysize) * (Xsize/4)))/2) ; i++) 00428 { 00429 /* Get the current data */ 00430 pixels_4 = pdata[i]; 00431 if (pixels_4 !=0) 00432 { 00433 /* One byte read codes 8 pixels in 1-bit bitmap */ 00434 for (nb_4_pixels = 0; nb_4_pixels < 2; nb_4_pixels++) 00435 { 00436 /* Processing 8 pixels */ 00437 /* Preparing the 4 pixels coded with 4 grey level per pixel 00438 from a monochrome xbm file */ 00439 for (j= 0; j<4; j++) 00440 { 00441 if (((pixels_4) & 0x01) == 1) 00442 { 00443 /* Two LSB is coding black in 4 grey level */ 00444 pixels_4_grey[j] &= 0xFC; 00445 } 00446 else 00447 { 00448 /* Two LSB is coded white in 4 grey level */ 00449 pixels_4_grey[j] |= 0x03; 00450 } 00451 pixels_4 = pixels_4 >> 1; 00452 } 00453 00454 /* Processing 4 pixels */ 00455 /* Format the data to have the Lower pixel number sent on the MSB for the SPI to fit with the RAM 00456 EPD topology */ 00457 data_res = pixels_4_grey[0] << 6 | pixels_4_grey[1] << 4 | pixels_4_grey[2] << 2 | pixels_4_grey[3] << 0; 00458 00459 /* Send the data to the EPD's RAM through SPI */ 00460 EPD_IO_WriteData(data_res); 00461 } 00462 } 00463 else 00464 { 00465 /* 1 byte read from xbm files is equivalent to 8 pixels in the 00466 other words 2 bytes to be transferred */ 00467 EPD_IO_WriteData(0xFF); 00468 EPD_IO_WriteData(0xFF); 00469 } 00470 } 00471 } 00472 00473 /* X size is a multiple of 4 */ 00474 else 00475 { 00476 for (i= 0; i< ((((Ysize) * ((Xsize/4)+1))/2)) ; i++) 00477 { 00478 /* Get the current data */ 00479 pixels_4 = pdata[i]; 00480 if (((i+1) % (((Xsize/4)+1)/2)) != 0) 00481 { 00482 if (pixels_4 !=0) 00483 { 00484 /* One byte read codes 8 pixels in 1-bit bitmap */ 00485 for (nb_4_pixels = 0; nb_4_pixels < 2; nb_4_pixels++) 00486 { 00487 /* Processing 8 pixels */ 00488 /* Preparing the 4 pixels coded with 4 grey level per pixel 00489 from a monochrome xbm file */ 00490 for (j= 0; j<4; j++) 00491 { 00492 if (((pixels_4) & 0x01) == 1) 00493 { 00494 /* Two LSB is coding black in 4 grey level */ 00495 pixels_4_grey[j] &= 0xFC; 00496 } 00497 else 00498 { 00499 /* Two LSB is coded white in 4 grey level */ 00500 pixels_4_grey[j] |= 0x03; 00501 } 00502 pixels_4 = pixels_4 >> 1; 00503 } 00504 00505 /* Processing 4 pixels */ 00506 /* Format the data to have the Lower pixel number sent on the MSB for the SPI to fit with the RAM 00507 EPD topology */ 00508 data_res = pixels_4_grey[0] << 6 | pixels_4_grey[1] << 4 | pixels_4_grey[2] << 2 | pixels_4_grey[3] << 0; 00509 00510 /* Send the data to the EPD's RAM through SPI */ 00511 EPD_IO_WriteData(data_res); 00512 } 00513 } 00514 else if (pixels_4 == 0) 00515 { 00516 /* One byte read from xbm files is equivalent to 8 pixels in the 00517 other words Two bytes to be transferred */ 00518 EPD_IO_WriteData(0xFF); 00519 EPD_IO_WriteData(0xFF); 00520 } 00521 } 00522 00523 else if (((i+1) % (((Xsize/4)+1)/2)) == 0) 00524 { 00525 if (pixels_4 !=0xf0) 00526 { 00527 /* Processing 8 pixels */ 00528 /* Preparing the 4 pixels coded with 4 grey level per pixel 00529 from a monochrome xbm file */ 00530 for (j= 0; j<4; j++) 00531 { 00532 if (((pixels_4) & 0x01) == 1) 00533 { 00534 /* 2 LSB is coding black in 4 grey level */ 00535 pixels_4_grey[j] &= 0xFC; 00536 } 00537 else 00538 { 00539 /* 2 LSB is coded white in 4 grey level */ 00540 pixels_4_grey[j] |= 0x03; 00541 } 00542 pixels_4 = pixels_4 >> 1; 00543 } 00544 00545 /* Processing 4 pixels */ 00546 /* Format the data to have the Lower pixel number sent on the MSB for the SPI to fit with the RAM 00547 EPD topology */ 00548 data_res = pixels_4_grey[0] << 6 | pixels_4_grey[1] << 4 | pixels_4_grey[2] << 2 | pixels_4_grey[3] << 0; 00549 00550 /* Send the data to the EPD's RAM through SPI */ 00551 EPD_IO_WriteData(data_res); 00552 } 00553 else if (pixels_4 == 0xf0) 00554 { 00555 /* One byte to be transferred */ 00556 EPD_IO_WriteData(0xFF); 00557 } 00558 } 00559 } 00560 } 00561 } 00562 00563 /** 00564 * @brief Activates display update sequence. 00565 * @param None 00566 * @retval None 00567 */ 00568 void EPD_GDE021A1::gde021a1_RefreshDisplay(void) 00569 { 00570 /* Write on the Display update control register */ 00571 EPD_IO_WriteReg(EPD_REG_34); 00572 00573 /* Display update data sequence option */ 00574 EPD_IO_WriteData(0xC4); 00575 00576 /* Launching the update: Nothing should interrupt this sequence in order 00577 to avoid display corruption */ 00578 EPD_IO_WriteReg(EPD_REG_32); 00579 } 00580 00581 /** 00582 * @brief Disables the clock and the charge pump. 00583 * @param None 00584 * @retval None 00585 */ 00586 void EPD_GDE021A1::gde021a1_CloseChargePump(void) 00587 { 00588 /* Write on the Display update control register */ 00589 EPD_IO_WriteReg(EPD_REG_34); 00590 00591 /* Disable CP then Disable Clock signal */ 00592 EPD_IO_WriteData(0x03); 00593 00594 /* Launching the update: Nothing should interrupt this sequence in order 00595 to avoid display corruption */ 00596 EPD_IO_WriteReg(EPD_REG_32); 00597 } 00598 00599 /** 00600 * @brief Sets a display window. 00601 * @param Xpos: specifies the X bottom left position. 00602 * @param Ypos: specifies the Y bottom left position. 00603 * @param Width: display window width. 00604 * @param Height: display window height. 00605 * @retval None 00606 */ 00607 void EPD_GDE021A1::gde021a1_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) 00608 { 00609 /* Set Y position and the height */ 00610 EPD_IO_WriteReg(EPD_REG_68); 00611 EPD_IO_WriteData(Ypos); 00612 EPD_IO_WriteData(Height); 00613 /* Set X position and the width */ 00614 EPD_IO_WriteReg(EPD_REG_69); 00615 EPD_IO_WriteData(Xpos); 00616 EPD_IO_WriteData(Width); 00617 /* Set the height counter */ 00618 EPD_IO_WriteReg(EPD_REG_78); 00619 EPD_IO_WriteData(Ypos); 00620 /* Set the width counter */ 00621 EPD_IO_WriteReg(EPD_REG_79); 00622 EPD_IO_WriteData(Xpos); 00623 } 00624 00625 /** 00626 * @brief Gets the EPD pixel Width. 00627 * @param None 00628 * @retval The EPD Pixel Width 00629 */ 00630 uint16_t EPD_GDE021A1::gde021a1_GetEpdPixelWidth(void) 00631 { 00632 return GDE021A1_EPD_PIXEL_WIDTH; 00633 } 00634 00635 /** 00636 * @brief Gets the EPD pixel Height. 00637 * @param None 00638 * @retval The EPD Pixel Height 00639 */ 00640 uint16_t EPD_GDE021A1::gde021a1_GetEpdPixelHeight(void) 00641 { 00642 return GDE021A1_EPD_PIXEL_HEIGHT; 00643 } 00644 00645 /** 00646 * @brief Draws a character on EPD. 00647 * @param Xpos: specifies the X position, can be a value from 0 to 171 00648 * @param Ypos: specifies the Y position, can be a value from 0 to 17 00649 * @param c: pointer to the character data 00650 * @retval None 00651 */ 00652 void EPD_GDE021A1::DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c) 00653 { 00654 uint32_t index = 0; 00655 uint32_t data_length = 0; 00656 uint16_t height = 0; 00657 uint16_t width = 0; 00658 00659 width = pFont->Width; 00660 height = pFont->Height; 00661 00662 /* Set the Character display window */ 00663 gde021a1_SetDisplayWindow(Xpos, Ypos, (Xpos + width - 1), (Ypos + height - 1)); 00664 00665 data_length = (height * width); 00666 00667 for(index = 0; index < data_length; index++) 00668 { 00669 gde021a1_WritePixel(c[index]); 00670 } 00671 }
Generated on Tue Jul 12 2022 22:14:36 by 1.7.2