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.

Committer:
bcostm
Date:
Tue Apr 28 12:02:43 2015 +0000
Revision:
1:6ee9c1afd6ec
Parent:
0:5d8241e6bd3b
Add code example.

Who changed what in which revision?

UserRevisionLine numberNew 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 #include "EPD_GDE021A1.h"
bcostm 0:5d8241e6bd3b 20
bcostm 0:5d8241e6bd3b 21 /**
bcostm 0:5d8241e6bd3b 22 * @brief GDE021A1 Size
bcostm 0:5d8241e6bd3b 23 */
bcostm 0:5d8241e6bd3b 24 #define GDE021A1_EPD_PIXEL_WIDTH ((uint16_t)172)
bcostm 0:5d8241e6bd3b 25 #define GDE021A1_EPD_PIXEL_HEIGHT ((uint16_t)18)
bcostm 0:5d8241e6bd3b 26
bcostm 0:5d8241e6bd3b 27 /**
bcostm 0:5d8241e6bd3b 28 * @brief GDE021A1 Registers
bcostm 0:5d8241e6bd3b 29 */
bcostm 0:5d8241e6bd3b 30 #define EPD_REG_0 0x00 /* Status Read */
bcostm 0:5d8241e6bd3b 31 #define EPD_REG_1 0x01 /* Driver Output Control */
bcostm 0:5d8241e6bd3b 32 #define EPD_REG_3 0x03 /* Gate driving voltage control */
bcostm 0:5d8241e6bd3b 33 #define EPD_REG_4 0x04 /* Source driving coltage control */
bcostm 0:5d8241e6bd3b 34 #define EPD_REG_7 0x07 /* Display Control */
bcostm 0:5d8241e6bd3b 35 #define EPD_REG_11 0x0B /* Gate and Sorce non overlap period COntrol */
bcostm 0:5d8241e6bd3b 36 #define EPD_REG_15 0x0F /* Gate scan start */
bcostm 0:5d8241e6bd3b 37 #define EPD_REG_16 0x10 /* Deep Sleep mode setting */
bcostm 0:5d8241e6bd3b 38 #define EPD_REG_17 0x11 /* Data Entry Mode Setting */
bcostm 0:5d8241e6bd3b 39 #define EPD_REG_18 0x12 /* SWRESET */
bcostm 0:5d8241e6bd3b 40 #define EPD_REG_26 0x1A /* Temperature Sensor Control (Write to Temp Register) */
bcostm 0:5d8241e6bd3b 41 #define EPD_REG_27 0x1B /* Temperature Sensor Control(Read from Temp Register) */
bcostm 0:5d8241e6bd3b 42 #define EPD_REG_28 0x1C /* Temperature Sensor Control(Write Command to Temp sensor) */
bcostm 0:5d8241e6bd3b 43 #define EPD_REG_29 0x1D /* Temperature Sensor Control(Load temperature register with temperature sensor reading) */
bcostm 0:5d8241e6bd3b 44 #define EPD_REG_32 0x20 /* Master activation */
bcostm 0:5d8241e6bd3b 45 #define EPD_REG_33 0x21 /* Display update */
bcostm 0:5d8241e6bd3b 46 #define EPD_REG_34 0x22 /* Display update control 2 */
bcostm 0:5d8241e6bd3b 47 #define EPD_REG_36 0x24 /* write RAM */
bcostm 0:5d8241e6bd3b 48 #define EPD_REG_37 0x25 /* Read RAM */
bcostm 0:5d8241e6bd3b 49 #define EPD_REG_40 0x28 /* VCOM sense */
bcostm 0:5d8241e6bd3b 50 #define EPD_REG_41 0x29 /* VCOM Sense duration */
bcostm 0:5d8241e6bd3b 51 #define EPD_REG_42 0x2A /* VCOM OTP program */
bcostm 0:5d8241e6bd3b 52 #define EPD_REG_44 0x2C /* Write VCOMregister */
bcostm 0:5d8241e6bd3b 53 #define EPD_REG_45 0x2D /* Read OTP registers */
bcostm 0:5d8241e6bd3b 54 #define EPD_REG_48 0x30 /* Program WS OTP */
bcostm 0:5d8241e6bd3b 55 #define EPD_REG_50 0x32 /* Write LUT register */
bcostm 0:5d8241e6bd3b 56 #define EPD_REG_51 0x33 /* Read LUT register */
bcostm 0:5d8241e6bd3b 57 #define EPD_REG_54 0x36 /* Program OTP selection */
bcostm 0:5d8241e6bd3b 58 #define EPD_REG_55 0x37 /* Proceed OTP selection */
bcostm 0:5d8241e6bd3b 59 #define EPD_REG_58 0x3A /* Set dummy line pulse period */
bcostm 0:5d8241e6bd3b 60 #define EPD_REG_59 0x3B /* Set Gate line width */
bcostm 0:5d8241e6bd3b 61 #define EPD_REG_60 0x3C /* Select Border waveform */
bcostm 0:5d8241e6bd3b 62 #define EPD_REG_68 0x44 /* Set RAM X - Address Start / End Position */
bcostm 0:5d8241e6bd3b 63 #define EPD_REG_69 0x45 /* Set RAM Y - Address Start / End Position */
bcostm 0:5d8241e6bd3b 64 #define EPD_REG_78 0x4E /* Set RAM X Address Counter */
bcostm 0:5d8241e6bd3b 65 #define EPD_REG_79 0x4F /* Set RAM Y Address Counter */
bcostm 0:5d8241e6bd3b 66 #define EPD_REG_240 0xF0 /* Booster Set Internal Feedback Selection */
bcostm 0:5d8241e6bd3b 67 #define EPD_REG_255 0xFF /* NOP */
bcostm 0:5d8241e6bd3b 68
bcostm 0:5d8241e6bd3b 69 /* Look-up table for the epaper (90 bytes) */
bcostm 0:5d8241e6bd3b 70 const unsigned char WF_LUT[]={
bcostm 0:5d8241e6bd3b 71 0x82,0x00,0x00,0x00,0xAA,0x00,0x00,0x00,
bcostm 0:5d8241e6bd3b 72 0xAA,0xAA,0x00,0x00,0xAA,0xAA,0xAA,0x00,
bcostm 0:5d8241e6bd3b 73 0x55,0xAA,0xAA,0x00,0x55,0x55,0x55,0x55,
bcostm 0:5d8241e6bd3b 74 0xAA,0xAA,0xAA,0xAA,0x55,0x55,0x55,0x55,
bcostm 0:5d8241e6bd3b 75 0xAA,0xAA,0xAA,0xAA,0x15,0x15,0x15,0x15,
bcostm 0:5d8241e6bd3b 76 0x05,0x05,0x05,0x05,0x01,0x01,0x01,0x01,
bcostm 0:5d8241e6bd3b 77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
bcostm 0:5d8241e6bd3b 78 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
bcostm 0:5d8241e6bd3b 79 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
bcostm 0:5d8241e6bd3b 80 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
bcostm 0:5d8241e6bd3b 81 0x41,0x45,0xF1,0xFF,0x5F,0x55,0x01,0x00,
bcostm 0:5d8241e6bd3b 82 0x00,0x00,};
bcostm 0:5d8241e6bd3b 83
bcostm 0:5d8241e6bd3b 84 // Constructor
bcostm 0:5d8241e6bd3b 85 EPD_GDE021A1::EPD_GDE021A1(PinName cs, PinName dc, PinName rst, PinName bsy, PinName pwr, PinName spi_mosi, PinName spi_miso, PinName spi_sck) :
bcostm 0:5d8241e6bd3b 86 _cs(cs, 1),
bcostm 0:5d8241e6bd3b 87 _dc(dc, 1),
bcostm 0:5d8241e6bd3b 88 _rst(rst, 1),
bcostm 0:5d8241e6bd3b 89 _bsy(bsy, PullDown),
bcostm 0:5d8241e6bd3b 90 _pwr(pwr, 1),
bcostm 0:5d8241e6bd3b 91 _spi(spi_mosi, spi_miso, spi_sck)
bcostm 0:5d8241e6bd3b 92 {
bcostm 0:5d8241e6bd3b 93 _pwr = 0;
bcostm 0:5d8241e6bd3b 94 _cs = 0;
bcostm 0:5d8241e6bd3b 95 _cs = 1;
bcostm 0:5d8241e6bd3b 96 _rst = 1;
bcostm 0:5d8241e6bd3b 97
bcostm 0:5d8241e6bd3b 98 wait_ms(10);
bcostm 0:5d8241e6bd3b 99
bcostm 0:5d8241e6bd3b 100 _spi.format(8);
bcostm 0:5d8241e6bd3b 101 _spi.frequency(1000000);
bcostm 0:5d8241e6bd3b 102
bcostm 0:5d8241e6bd3b 103 gde021a1_Init();
bcostm 0:5d8241e6bd3b 104
bcostm 0:5d8241e6bd3b 105 Clear(EPD_COLOR_WHITE);
bcostm 0:5d8241e6bd3b 106
bcostm 0:5d8241e6bd3b 107 SetFont(&Font12);
bcostm 0:5d8241e6bd3b 108 }
bcostm 0:5d8241e6bd3b 109
bcostm 0:5d8241e6bd3b 110 // Destructor
bcostm 0:5d8241e6bd3b 111 EPD_GDE021A1::~EPD_GDE021A1() { }
bcostm 0:5d8241e6bd3b 112
bcostm 0:5d8241e6bd3b 113 //=================================================================================================================
bcostm 0:5d8241e6bd3b 114 // Public methods
bcostm 0:5d8241e6bd3b 115 //=================================================================================================================
bcostm 0:5d8241e6bd3b 116
bcostm 0:5d8241e6bd3b 117 uint32_t EPD_GDE021A1::GetXSize(void)
bcostm 0:5d8241e6bd3b 118 {
bcostm 0:5d8241e6bd3b 119 return(gde021a1_GetEpdPixelWidth());
bcostm 0:5d8241e6bd3b 120 }
bcostm 0:5d8241e6bd3b 121
bcostm 0:5d8241e6bd3b 122 uint32_t EPD_GDE021A1::GetYSize(void)
bcostm 0:5d8241e6bd3b 123 {
bcostm 0:5d8241e6bd3b 124 return(gde021a1_GetEpdPixelHeight());
bcostm 0:5d8241e6bd3b 125 }
bcostm 0:5d8241e6bd3b 126
bcostm 0:5d8241e6bd3b 127 void EPD_GDE021A1::SetFont(sFONT *pFonts)
bcostm 0:5d8241e6bd3b 128 {
bcostm 0:5d8241e6bd3b 129 pFont = pFonts;
bcostm 0:5d8241e6bd3b 130 }
bcostm 0:5d8241e6bd3b 131
bcostm 0:5d8241e6bd3b 132 sFONT *EPD_GDE021A1::GetFont(void)
bcostm 0:5d8241e6bd3b 133 {
bcostm 0:5d8241e6bd3b 134 return pFont;
bcostm 0:5d8241e6bd3b 135 }
bcostm 0:5d8241e6bd3b 136
bcostm 0:5d8241e6bd3b 137 void EPD_GDE021A1::Clear(uint16_t Color)
bcostm 0:5d8241e6bd3b 138 {
bcostm 0:5d8241e6bd3b 139 uint32_t index = 0;
bcostm 0:5d8241e6bd3b 140
bcostm 0:5d8241e6bd3b 141 gde021a1_SetDisplayWindow(0, 0, 171, 17);
bcostm 0:5d8241e6bd3b 142
bcostm 0:5d8241e6bd3b 143 for(index = 0; index < 3096; index++)
bcostm 0:5d8241e6bd3b 144 {
bcostm 0:5d8241e6bd3b 145 gde021a1_WritePixel(Color);
bcostm 0:5d8241e6bd3b 146 }
bcostm 0:5d8241e6bd3b 147 }
bcostm 0:5d8241e6bd3b 148
bcostm 0:5d8241e6bd3b 149 void EPD_GDE021A1::DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii)
bcostm 0:5d8241e6bd3b 150 {
bcostm 0:5d8241e6bd3b 151 Ascii -= 32;
bcostm 0:5d8241e6bd3b 152
bcostm 0:5d8241e6bd3b 153 DrawChar(Xpos, Ypos, &pFont->table[Ascii * ((pFont->Height) * (pFont->Width))]);
bcostm 0:5d8241e6bd3b 154 }
bcostm 0:5d8241e6bd3b 155
bcostm 0:5d8241e6bd3b 156 void EPD_GDE021A1::DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode)
bcostm 0:5d8241e6bd3b 157 {
bcostm 0:5d8241e6bd3b 158 uint16_t refcolumn = 1, i = 0;
bcostm 0:5d8241e6bd3b 159 uint32_t size = 0, xsize = 0;
bcostm 0:5d8241e6bd3b 160 uint8_t *ptr = Text;
bcostm 0:5d8241e6bd3b 161
bcostm 0:5d8241e6bd3b 162 /* Get the text size */
bcostm 0:5d8241e6bd3b 163 while (*ptr++) size ++ ;
bcostm 0:5d8241e6bd3b 164
bcostm 0:5d8241e6bd3b 165 /* Characters number per line */
bcostm 0:5d8241e6bd3b 166 xsize = (GetXSize()/pFont->Width);
bcostm 0:5d8241e6bd3b 167
bcostm 0:5d8241e6bd3b 168 switch (Mode)
bcostm 0:5d8241e6bd3b 169 {
bcostm 0:5d8241e6bd3b 170 case CENTER_MODE:
bcostm 0:5d8241e6bd3b 171 {
bcostm 0:5d8241e6bd3b 172 refcolumn = Xpos + ((xsize - size)* pFont->Width) / 2;
bcostm 0:5d8241e6bd3b 173 break;
bcostm 0:5d8241e6bd3b 174 }
bcostm 0:5d8241e6bd3b 175 case LEFT_MODE:
bcostm 0:5d8241e6bd3b 176 {
bcostm 0:5d8241e6bd3b 177 refcolumn = Xpos;
bcostm 0:5d8241e6bd3b 178 break;
bcostm 0:5d8241e6bd3b 179 }
bcostm 0:5d8241e6bd3b 180 case RIGHT_MODE:
bcostm 0:5d8241e6bd3b 181 {
bcostm 0:5d8241e6bd3b 182 refcolumn = - Xpos + ((xsize - size)*pFont->Width);
bcostm 0:5d8241e6bd3b 183 break;
bcostm 0:5d8241e6bd3b 184 }
bcostm 0:5d8241e6bd3b 185 default:
bcostm 0:5d8241e6bd3b 186 {
bcostm 0:5d8241e6bd3b 187 refcolumn = Xpos;
bcostm 0:5d8241e6bd3b 188 break;
bcostm 0:5d8241e6bd3b 189 }
bcostm 0:5d8241e6bd3b 190 }
bcostm 0:5d8241e6bd3b 191
bcostm 0:5d8241e6bd3b 192 /* Send the string character by character on EPD */
bcostm 0:5d8241e6bd3b 193 while ((*Text != 0) & (((GetXSize() - (i*pFont->Width)) & 0xFFFF) >= pFont->Width))
bcostm 0:5d8241e6bd3b 194 {
bcostm 0:5d8241e6bd3b 195 /* Display one character on EPD */
bcostm 0:5d8241e6bd3b 196 DisplayChar(refcolumn, Ypos, *Text);
bcostm 0:5d8241e6bd3b 197 /* Decrement the column position by 16 */
bcostm 0:5d8241e6bd3b 198 refcolumn += pFont->Width;
bcostm 0:5d8241e6bd3b 199 /* Point on the next character */
bcostm 0:5d8241e6bd3b 200 Text++;
bcostm 0:5d8241e6bd3b 201 i++;
bcostm 0:5d8241e6bd3b 202 }
bcostm 0:5d8241e6bd3b 203 }
bcostm 0:5d8241e6bd3b 204
bcostm 0:5d8241e6bd3b 205 void EPD_GDE021A1::DisplayStringAtLine(uint16_t Line, uint8_t *ptr, Text_AlignModeTypdef Mode)
bcostm 0:5d8241e6bd3b 206 {
bcostm 0:5d8241e6bd3b 207 DisplayStringAt(0, LINE(Line), ptr, Mode);
bcostm 0:5d8241e6bd3b 208 }
bcostm 0:5d8241e6bd3b 209
bcostm 0:5d8241e6bd3b 210 void EPD_GDE021A1::DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
bcostm 0:5d8241e6bd3b 211 {
bcostm 0:5d8241e6bd3b 212 uint32_t index = 0;
bcostm 0:5d8241e6bd3b 213
bcostm 0:5d8241e6bd3b 214 gde021a1_SetDisplayWindow(Xpos, Ypos, Xpos + Length, Ypos);
bcostm 0:5d8241e6bd3b 215
bcostm 0:5d8241e6bd3b 216 for(index = 0; index < Length; index++)
bcostm 0:5d8241e6bd3b 217 {
bcostm 0:5d8241e6bd3b 218 /* Prepare the register to write data on the RAM */
bcostm 0:5d8241e6bd3b 219 gde021a1_WritePixel(0x3F);
bcostm 0:5d8241e6bd3b 220 }
bcostm 0:5d8241e6bd3b 221 }
bcostm 0:5d8241e6bd3b 222
bcostm 0:5d8241e6bd3b 223 void EPD_GDE021A1::DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
bcostm 0:5d8241e6bd3b 224 {
bcostm 0:5d8241e6bd3b 225 uint32_t index = 0;
bcostm 0:5d8241e6bd3b 226
bcostm 0:5d8241e6bd3b 227 gde021a1_SetDisplayWindow(Xpos, Ypos, Xpos, Ypos + Length);
bcostm 0:5d8241e6bd3b 228
bcostm 0:5d8241e6bd3b 229 for(index = 0; index < Length; index++)
bcostm 0:5d8241e6bd3b 230 {
bcostm 0:5d8241e6bd3b 231 /* Prepare the register to write data on the RAM */
bcostm 0:5d8241e6bd3b 232 gde021a1_WritePixel(0x00);
bcostm 0:5d8241e6bd3b 233 }
bcostm 0:5d8241e6bd3b 234 }
bcostm 0:5d8241e6bd3b 235
bcostm 0:5d8241e6bd3b 236 void EPD_GDE021A1::DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
bcostm 0:5d8241e6bd3b 237 {
bcostm 0:5d8241e6bd3b 238 /* Draw horizontal lines */
bcostm 0:5d8241e6bd3b 239 DrawHLine(Xpos, Ypos, Width);
bcostm 0:5d8241e6bd3b 240 DrawHLine(Xpos, (Ypos + Height), (Width + 1));
bcostm 0:5d8241e6bd3b 241
bcostm 0:5d8241e6bd3b 242 /* Draw vertical lines */
bcostm 0:5d8241e6bd3b 243 DrawVLine(Xpos, Ypos, Height);
bcostm 0:5d8241e6bd3b 244 DrawVLine((Xpos + Width), Ypos , Height);
bcostm 0:5d8241e6bd3b 245 }
bcostm 0:5d8241e6bd3b 246
bcostm 0:5d8241e6bd3b 247 void EPD_GDE021A1::FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
bcostm 0:5d8241e6bd3b 248 {
bcostm 0:5d8241e6bd3b 249 uint16_t index = 0;
bcostm 0:5d8241e6bd3b 250
bcostm 0:5d8241e6bd3b 251 /* Set the rectangle */
bcostm 0:5d8241e6bd3b 252 gde021a1_SetDisplayWindow(Xpos, Ypos, (Xpos + Width), (Ypos + Height));
bcostm 0:5d8241e6bd3b 253
bcostm 0:5d8241e6bd3b 254 for(index = 0; index < 3096; index++)
bcostm 0:5d8241e6bd3b 255 {
bcostm 0:5d8241e6bd3b 256 gde021a1_WritePixel(0xFF);
bcostm 0:5d8241e6bd3b 257 }
bcostm 0:5d8241e6bd3b 258 }
bcostm 0:5d8241e6bd3b 259
bcostm 0:5d8241e6bd3b 260 void EPD_GDE021A1::DrawImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata)
bcostm 0:5d8241e6bd3b 261 {
bcostm 0:5d8241e6bd3b 262 /* Set display window */
bcostm 0:5d8241e6bd3b 263 gde021a1_SetDisplayWindow(Xpos, Ypos, (Xpos+Ysize-1), (Ypos+(Xsize/4)-1));
bcostm 0:5d8241e6bd3b 264
bcostm 0:5d8241e6bd3b 265 gde021a1_DrawImage(Xpos, Ypos, Xsize, Ysize, pdata);
bcostm 0:5d8241e6bd3b 266
bcostm 0:5d8241e6bd3b 267 gde021a1_SetDisplayWindow(0, 0, GetXSize(), GetYSize());
bcostm 0:5d8241e6bd3b 268 }
bcostm 0:5d8241e6bd3b 269
bcostm 0:5d8241e6bd3b 270 void EPD_GDE021A1::CloseChargePump(void)
bcostm 0:5d8241e6bd3b 271 {
bcostm 0:5d8241e6bd3b 272 /* Close charge pump */
bcostm 0:5d8241e6bd3b 273 gde021a1_CloseChargePump();
bcostm 0:5d8241e6bd3b 274
bcostm 0:5d8241e6bd3b 275 wait_ms(400);
bcostm 0:5d8241e6bd3b 276 }
bcostm 0:5d8241e6bd3b 277
bcostm 0:5d8241e6bd3b 278 /**
bcostm 0:5d8241e6bd3b 279 * @brief Updates the display from the data located into the RAM.
bcostm 0:5d8241e6bd3b 280 * @param None
bcostm 0:5d8241e6bd3b 281 * @retval None
bcostm 0:5d8241e6bd3b 282 */
bcostm 0:5d8241e6bd3b 283 void EPD_GDE021A1::RefreshDisplay(void)
bcostm 0:5d8241e6bd3b 284 {
bcostm 0:5d8241e6bd3b 285 gde021a1_RefreshDisplay();
bcostm 0:5d8241e6bd3b 286
bcostm 0:5d8241e6bd3b 287 /* Poll on the BUSY signal and wait for the EPD to be ready */
bcostm 0:5d8241e6bd3b 288 while (_bsy != 0);
bcostm 0:5d8241e6bd3b 289
bcostm 0:5d8241e6bd3b 290 _rst = 1;
bcostm 0:5d8241e6bd3b 291
bcostm 0:5d8241e6bd3b 292 wait_ms(10);
bcostm 0:5d8241e6bd3b 293 }
bcostm 0:5d8241e6bd3b 294
bcostm 0:5d8241e6bd3b 295 //=================================================================================================================
bcostm 0:5d8241e6bd3b 296 // Private methods
bcostm 0:5d8241e6bd3b 297 //=================================================================================================================
bcostm 0:5d8241e6bd3b 298
bcostm 0:5d8241e6bd3b 299 void EPD_GDE021A1::EPD_IO_WriteData(uint16_t RegValue)
bcostm 0:5d8241e6bd3b 300 {
bcostm 0:5d8241e6bd3b 301 _cs = 0;
bcostm 0:5d8241e6bd3b 302 _dc = 1;
bcostm 0:5d8241e6bd3b 303 _spi.write(RegValue);
bcostm 0:5d8241e6bd3b 304 _cs = 1;
bcostm 0:5d8241e6bd3b 305 }
bcostm 0:5d8241e6bd3b 306
bcostm 0:5d8241e6bd3b 307 void EPD_GDE021A1::EPD_IO_WriteReg(uint8_t Reg)
bcostm 0:5d8241e6bd3b 308 {
bcostm 0:5d8241e6bd3b 309 _cs = 0;
bcostm 0:5d8241e6bd3b 310 _dc = 0;
bcostm 0:5d8241e6bd3b 311 _spi.write(Reg);
bcostm 0:5d8241e6bd3b 312 _cs = 1;
bcostm 0:5d8241e6bd3b 313 }
bcostm 0:5d8241e6bd3b 314
bcostm 0:5d8241e6bd3b 315 uint16_t EPD_GDE021A1::EPD_IO_ReadData(void)
bcostm 0:5d8241e6bd3b 316 {
bcostm 0:5d8241e6bd3b 317 _cs = 0;
bcostm 0:5d8241e6bd3b 318 _cs = 1;
bcostm 0:5d8241e6bd3b 319 return _spi.write(0xFF);
bcostm 0:5d8241e6bd3b 320 }
bcostm 0:5d8241e6bd3b 321
bcostm 0:5d8241e6bd3b 322 //=================================================================================================================
bcostm 0:5d8241e6bd3b 323
bcostm 0:5d8241e6bd3b 324 /**
bcostm 0:5d8241e6bd3b 325 * @brief Initialize the GDE021A1 EPD Component.
bcostm 0:5d8241e6bd3b 326 * @param None
bcostm 0:5d8241e6bd3b 327 * @retval None
bcostm 0:5d8241e6bd3b 328 */
bcostm 0:5d8241e6bd3b 329 void EPD_GDE021A1::gde021a1_Init(void)
bcostm 0:5d8241e6bd3b 330 {
bcostm 0:5d8241e6bd3b 331 uint8_t nb_bytes = 0;
bcostm 0:5d8241e6bd3b 332
bcostm 0:5d8241e6bd3b 333 EPD_IO_WriteReg(EPD_REG_16); /* Deep sleep mode disable */
bcostm 0:5d8241e6bd3b 334 EPD_IO_WriteData(0x00);
bcostm 0:5d8241e6bd3b 335 EPD_IO_WriteReg(EPD_REG_17); /* Data Entry Mode Setting */
bcostm 0:5d8241e6bd3b 336 EPD_IO_WriteData(0x03);
bcostm 0:5d8241e6bd3b 337 EPD_IO_WriteReg(EPD_REG_68); /* Set the RAM X start/end address */
bcostm 0:5d8241e6bd3b 338 EPD_IO_WriteData(0x00); /* RAM X address start = 00h */
bcostm 0:5d8241e6bd3b 339 EPD_IO_WriteData(0x11); /* RAM X adress end = 11h (17 * 4pixels by address = 72 pixels) */
bcostm 0:5d8241e6bd3b 340 EPD_IO_WriteReg(EPD_REG_69); /* Set the RAM Y start/end address */
bcostm 0:5d8241e6bd3b 341 EPD_IO_WriteData(0x00); /* RAM Y address start = 0 */
bcostm 0:5d8241e6bd3b 342 EPD_IO_WriteData(0xAB); /* RAM Y adress end = 171 */
bcostm 0:5d8241e6bd3b 343 EPD_IO_WriteReg(EPD_REG_78); /* Set RAM X Address counter */
bcostm 0:5d8241e6bd3b 344 EPD_IO_WriteData(0x00);
bcostm 0:5d8241e6bd3b 345 EPD_IO_WriteReg(EPD_REG_79); /* Set RAM Y Address counter */
bcostm 0:5d8241e6bd3b 346 EPD_IO_WriteData(0x00);
bcostm 0:5d8241e6bd3b 347 EPD_IO_WriteReg(EPD_REG_240); /* Booster Set Internal Feedback Selection */
bcostm 0:5d8241e6bd3b 348 EPD_IO_WriteData(0x1F);
bcostm 0:5d8241e6bd3b 349 EPD_IO_WriteReg(EPD_REG_33); /* Disable RAM bypass and set GS transition to GSA = GS0 and GSB = GS3 */
bcostm 0:5d8241e6bd3b 350 EPD_IO_WriteData(0x03);
bcostm 0:5d8241e6bd3b 351 EPD_IO_WriteReg(EPD_REG_44); /* Write VCOMregister */
bcostm 0:5d8241e6bd3b 352 EPD_IO_WriteData(0xA0);
bcostm 0:5d8241e6bd3b 353 EPD_IO_WriteReg(EPD_REG_60); /* Border waveform */
bcostm 0:5d8241e6bd3b 354 EPD_IO_WriteData(0x64);
bcostm 0:5d8241e6bd3b 355 EPD_IO_WriteReg(EPD_REG_50); /* Write LUT register */
bcostm 0:5d8241e6bd3b 356
bcostm 0:5d8241e6bd3b 357 for (nb_bytes=0; nb_bytes<90; nb_bytes++)
bcostm 0:5d8241e6bd3b 358 {
bcostm 0:5d8241e6bd3b 359 EPD_IO_WriteData(WF_LUT[nb_bytes]);
bcostm 0:5d8241e6bd3b 360 }
bcostm 0:5d8241e6bd3b 361 }
bcostm 0:5d8241e6bd3b 362
bcostm 0:5d8241e6bd3b 363 /**
bcostm 0:5d8241e6bd3b 364 * @brief Writes to the selected EPD register.
bcostm 0:5d8241e6bd3b 365 * @param EPD_Reg: Address of the selected register.
bcostm 0:5d8241e6bd3b 366 * @param EPD_RegValue: value to write to the selected register.
bcostm 0:5d8241e6bd3b 367 * @retval None
bcostm 0:5d8241e6bd3b 368 */
bcostm 0:5d8241e6bd3b 369 void EPD_GDE021A1::gde021a1_WriteReg(uint8_t EPD_Reg, uint8_t EPD_RegValue)
bcostm 0:5d8241e6bd3b 370 {
bcostm 0:5d8241e6bd3b 371 EPD_IO_WriteReg(EPD_Reg);
bcostm 0:5d8241e6bd3b 372
bcostm 0:5d8241e6bd3b 373 EPD_IO_WriteData(EPD_RegValue);
bcostm 0:5d8241e6bd3b 374 }
bcostm 0:5d8241e6bd3b 375
bcostm 0:5d8241e6bd3b 376 /**
bcostm 0:5d8241e6bd3b 377 * @brief Reads the selected EPD Register.
bcostm 0:5d8241e6bd3b 378 * @param EPD_Reg: address of the selected register
bcostm 0:5d8241e6bd3b 379 * @retval EPD Register Value
bcostm 0:5d8241e6bd3b 380 */
bcostm 0:5d8241e6bd3b 381 uint8_t EPD_GDE021A1::gde021a1_ReadReg(uint8_t EPD_Reg)
bcostm 0:5d8241e6bd3b 382 {
bcostm 0:5d8241e6bd3b 383 /* Write 8-bit Index (then Read Reg) */
bcostm 0:5d8241e6bd3b 384 EPD_IO_WriteReg(EPD_Reg);
bcostm 0:5d8241e6bd3b 385
bcostm 0:5d8241e6bd3b 386 /* Read 8-bit Reg */
bcostm 0:5d8241e6bd3b 387 return (EPD_IO_ReadData());
bcostm 0:5d8241e6bd3b 388 }
bcostm 0:5d8241e6bd3b 389
bcostm 0:5d8241e6bd3b 390 /**
bcostm 0:5d8241e6bd3b 391 * @brief Writes 4 dots.
bcostm 0:5d8241e6bd3b 392 * @param HEX_Code: specifies the Data to write.
bcostm 0:5d8241e6bd3b 393 * @retval None
bcostm 0:5d8241e6bd3b 394 */
bcostm 0:5d8241e6bd3b 395 void EPD_GDE021A1::gde021a1_WritePixel(uint8_t HEX_Code)
bcostm 0:5d8241e6bd3b 396 {
bcostm 0:5d8241e6bd3b 397 /* Prepare the register to write data on the RAM */
bcostm 0:5d8241e6bd3b 398 EPD_IO_WriteReg(EPD_REG_36);
bcostm 0:5d8241e6bd3b 399
bcostm 0:5d8241e6bd3b 400 /* Send the data to write */
bcostm 0:5d8241e6bd3b 401 EPD_IO_WriteData(HEX_Code);
bcostm 0:5d8241e6bd3b 402 }
bcostm 0:5d8241e6bd3b 403
bcostm 0:5d8241e6bd3b 404 /**
bcostm 0:5d8241e6bd3b 405 * @brief Displays picture..
bcostm 0:5d8241e6bd3b 406 * @param pdata: picture address.
bcostm 0:5d8241e6bd3b 407 * @param Xpos: Image X position in the EPD
bcostm 0:5d8241e6bd3b 408 * @param Ypos: Image Y position in the EPD
bcostm 0:5d8241e6bd3b 409 * @param Xsize: Image X size in the EPD
bcostm 0:5d8241e6bd3b 410 * @note Xsize have to be a multiple of 4
bcostm 0:5d8241e6bd3b 411 * @param Ysize: Image Y size in the EPD
bcostm 0:5d8241e6bd3b 412 * @retval None
bcostm 0:5d8241e6bd3b 413 */
bcostm 0:5d8241e6bd3b 414 void EPD_GDE021A1::gde021a1_DrawImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata)
bcostm 0:5d8241e6bd3b 415 {
bcostm 0:5d8241e6bd3b 416 uint32_t i, j = 0;
bcostm 0:5d8241e6bd3b 417 uint8_t pixels_4 = 0;
bcostm 0:5d8241e6bd3b 418 uint8_t pixels_4_grey[4] = {0};
bcostm 0:5d8241e6bd3b 419 uint8_t nb_4_pixels, data_res = 0;
bcostm 0:5d8241e6bd3b 420
bcostm 0:5d8241e6bd3b 421 /* Prepare the register to write data on the RAM */
bcostm 0:5d8241e6bd3b 422 EPD_IO_WriteReg(EPD_REG_36);
bcostm 0:5d8241e6bd3b 423
bcostm 0:5d8241e6bd3b 424 /* X size is a multiple of 8 */
bcostm 0:5d8241e6bd3b 425 if ((Xsize % 8) == 0)
bcostm 0:5d8241e6bd3b 426 {
bcostm 0:5d8241e6bd3b 427 for (i= 0; i< ((((Ysize) * (Xsize/4)))/2) ; i++)
bcostm 0:5d8241e6bd3b 428 {
bcostm 0:5d8241e6bd3b 429 /* Get the current data */
bcostm 0:5d8241e6bd3b 430 pixels_4 = pdata[i];
bcostm 0:5d8241e6bd3b 431 if (pixels_4 !=0)
bcostm 0:5d8241e6bd3b 432 {
bcostm 0:5d8241e6bd3b 433 /* One byte read codes 8 pixels in 1-bit bitmap */
bcostm 0:5d8241e6bd3b 434 for (nb_4_pixels = 0; nb_4_pixels < 2; nb_4_pixels++)
bcostm 0:5d8241e6bd3b 435 {
bcostm 0:5d8241e6bd3b 436 /* Processing 8 pixels */
bcostm 0:5d8241e6bd3b 437 /* Preparing the 4 pixels coded with 4 grey level per pixel
bcostm 0:5d8241e6bd3b 438 from a monochrome xbm file */
bcostm 0:5d8241e6bd3b 439 for (j= 0; j<4; j++)
bcostm 0:5d8241e6bd3b 440 {
bcostm 0:5d8241e6bd3b 441 if (((pixels_4) & 0x01) == 1)
bcostm 0:5d8241e6bd3b 442 {
bcostm 0:5d8241e6bd3b 443 /* Two LSB is coding black in 4 grey level */
bcostm 0:5d8241e6bd3b 444 pixels_4_grey[j] &= 0xFC;
bcostm 0:5d8241e6bd3b 445 }
bcostm 0:5d8241e6bd3b 446 else
bcostm 0:5d8241e6bd3b 447 {
bcostm 0:5d8241e6bd3b 448 /* Two LSB is coded white in 4 grey level */
bcostm 0:5d8241e6bd3b 449 pixels_4_grey[j] |= 0x03;
bcostm 0:5d8241e6bd3b 450 }
bcostm 0:5d8241e6bd3b 451 pixels_4 = pixels_4 >> 1;
bcostm 0:5d8241e6bd3b 452 }
bcostm 0:5d8241e6bd3b 453
bcostm 0:5d8241e6bd3b 454 /* Processing 4 pixels */
bcostm 0:5d8241e6bd3b 455 /* Format the data to have the Lower pixel number sent on the MSB for the SPI to fit with the RAM
bcostm 0:5d8241e6bd3b 456 EPD topology */
bcostm 0:5d8241e6bd3b 457 data_res = pixels_4_grey[0] << 6 | pixels_4_grey[1] << 4 | pixels_4_grey[2] << 2 | pixels_4_grey[3] << 0;
bcostm 0:5d8241e6bd3b 458
bcostm 0:5d8241e6bd3b 459 /* Send the data to the EPD's RAM through SPI */
bcostm 0:5d8241e6bd3b 460 EPD_IO_WriteData(data_res);
bcostm 0:5d8241e6bd3b 461 }
bcostm 0:5d8241e6bd3b 462 }
bcostm 0:5d8241e6bd3b 463 else
bcostm 0:5d8241e6bd3b 464 {
bcostm 0:5d8241e6bd3b 465 /* 1 byte read from xbm files is equivalent to 8 pixels in the
bcostm 0:5d8241e6bd3b 466 other words 2 bytes to be transferred */
bcostm 0:5d8241e6bd3b 467 EPD_IO_WriteData(0xFF);
bcostm 0:5d8241e6bd3b 468 EPD_IO_WriteData(0xFF);
bcostm 0:5d8241e6bd3b 469 }
bcostm 0:5d8241e6bd3b 470 }
bcostm 0:5d8241e6bd3b 471 }
bcostm 0:5d8241e6bd3b 472
bcostm 0:5d8241e6bd3b 473 /* X size is a multiple of 4 */
bcostm 0:5d8241e6bd3b 474 else
bcostm 0:5d8241e6bd3b 475 {
bcostm 0:5d8241e6bd3b 476 for (i= 0; i< ((((Ysize) * ((Xsize/4)+1))/2)) ; i++)
bcostm 0:5d8241e6bd3b 477 {
bcostm 0:5d8241e6bd3b 478 /* Get the current data */
bcostm 0:5d8241e6bd3b 479 pixels_4 = pdata[i];
bcostm 0:5d8241e6bd3b 480 if (((i+1) % (((Xsize/4)+1)/2)) != 0)
bcostm 0:5d8241e6bd3b 481 {
bcostm 0:5d8241e6bd3b 482 if (pixels_4 !=0)
bcostm 0:5d8241e6bd3b 483 {
bcostm 0:5d8241e6bd3b 484 /* One byte read codes 8 pixels in 1-bit bitmap */
bcostm 0:5d8241e6bd3b 485 for (nb_4_pixels = 0; nb_4_pixels < 2; nb_4_pixels++)
bcostm 0:5d8241e6bd3b 486 {
bcostm 0:5d8241e6bd3b 487 /* Processing 8 pixels */
bcostm 0:5d8241e6bd3b 488 /* Preparing the 4 pixels coded with 4 grey level per pixel
bcostm 0:5d8241e6bd3b 489 from a monochrome xbm file */
bcostm 0:5d8241e6bd3b 490 for (j= 0; j<4; j++)
bcostm 0:5d8241e6bd3b 491 {
bcostm 0:5d8241e6bd3b 492 if (((pixels_4) & 0x01) == 1)
bcostm 0:5d8241e6bd3b 493 {
bcostm 0:5d8241e6bd3b 494 /* Two LSB is coding black in 4 grey level */
bcostm 0:5d8241e6bd3b 495 pixels_4_grey[j] &= 0xFC;
bcostm 0:5d8241e6bd3b 496 }
bcostm 0:5d8241e6bd3b 497 else
bcostm 0:5d8241e6bd3b 498 {
bcostm 0:5d8241e6bd3b 499 /* Two LSB is coded white in 4 grey level */
bcostm 0:5d8241e6bd3b 500 pixels_4_grey[j] |= 0x03;
bcostm 0:5d8241e6bd3b 501 }
bcostm 0:5d8241e6bd3b 502 pixels_4 = pixels_4 >> 1;
bcostm 0:5d8241e6bd3b 503 }
bcostm 0:5d8241e6bd3b 504
bcostm 0:5d8241e6bd3b 505 /* Processing 4 pixels */
bcostm 0:5d8241e6bd3b 506 /* Format the data to have the Lower pixel number sent on the MSB for the SPI to fit with the RAM
bcostm 0:5d8241e6bd3b 507 EPD topology */
bcostm 0:5d8241e6bd3b 508 data_res = pixels_4_grey[0] << 6 | pixels_4_grey[1] << 4 | pixels_4_grey[2] << 2 | pixels_4_grey[3] << 0;
bcostm 0:5d8241e6bd3b 509
bcostm 0:5d8241e6bd3b 510 /* Send the data to the EPD's RAM through SPI */
bcostm 0:5d8241e6bd3b 511 EPD_IO_WriteData(data_res);
bcostm 0:5d8241e6bd3b 512 }
bcostm 0:5d8241e6bd3b 513 }
bcostm 0:5d8241e6bd3b 514 else if (pixels_4 == 0)
bcostm 0:5d8241e6bd3b 515 {
bcostm 0:5d8241e6bd3b 516 /* One byte read from xbm files is equivalent to 8 pixels in the
bcostm 0:5d8241e6bd3b 517 other words Two bytes to be transferred */
bcostm 0:5d8241e6bd3b 518 EPD_IO_WriteData(0xFF);
bcostm 0:5d8241e6bd3b 519 EPD_IO_WriteData(0xFF);
bcostm 0:5d8241e6bd3b 520 }
bcostm 0:5d8241e6bd3b 521 }
bcostm 0:5d8241e6bd3b 522
bcostm 0:5d8241e6bd3b 523 else if (((i+1) % (((Xsize/4)+1)/2)) == 0)
bcostm 0:5d8241e6bd3b 524 {
bcostm 0:5d8241e6bd3b 525 if (pixels_4 !=0xf0)
bcostm 0:5d8241e6bd3b 526 {
bcostm 0:5d8241e6bd3b 527 /* Processing 8 pixels */
bcostm 0:5d8241e6bd3b 528 /* Preparing the 4 pixels coded with 4 grey level per pixel
bcostm 0:5d8241e6bd3b 529 from a monochrome xbm file */
bcostm 0:5d8241e6bd3b 530 for (j= 0; j<4; j++)
bcostm 0:5d8241e6bd3b 531 {
bcostm 0:5d8241e6bd3b 532 if (((pixels_4) & 0x01) == 1)
bcostm 0:5d8241e6bd3b 533 {
bcostm 0:5d8241e6bd3b 534 /* 2 LSB is coding black in 4 grey level */
bcostm 0:5d8241e6bd3b 535 pixels_4_grey[j] &= 0xFC;
bcostm 0:5d8241e6bd3b 536 }
bcostm 0:5d8241e6bd3b 537 else
bcostm 0:5d8241e6bd3b 538 {
bcostm 0:5d8241e6bd3b 539 /* 2 LSB is coded white in 4 grey level */
bcostm 0:5d8241e6bd3b 540 pixels_4_grey[j] |= 0x03;
bcostm 0:5d8241e6bd3b 541 }
bcostm 0:5d8241e6bd3b 542 pixels_4 = pixels_4 >> 1;
bcostm 0:5d8241e6bd3b 543 }
bcostm 0:5d8241e6bd3b 544
bcostm 0:5d8241e6bd3b 545 /* Processing 4 pixels */
bcostm 0:5d8241e6bd3b 546 /* Format the data to have the Lower pixel number sent on the MSB for the SPI to fit with the RAM
bcostm 0:5d8241e6bd3b 547 EPD topology */
bcostm 0:5d8241e6bd3b 548 data_res = pixels_4_grey[0] << 6 | pixels_4_grey[1] << 4 | pixels_4_grey[2] << 2 | pixels_4_grey[3] << 0;
bcostm 0:5d8241e6bd3b 549
bcostm 0:5d8241e6bd3b 550 /* Send the data to the EPD's RAM through SPI */
bcostm 0:5d8241e6bd3b 551 EPD_IO_WriteData(data_res);
bcostm 0:5d8241e6bd3b 552 }
bcostm 0:5d8241e6bd3b 553 else if (pixels_4 == 0xf0)
bcostm 0:5d8241e6bd3b 554 {
bcostm 0:5d8241e6bd3b 555 /* One byte to be transferred */
bcostm 0:5d8241e6bd3b 556 EPD_IO_WriteData(0xFF);
bcostm 0:5d8241e6bd3b 557 }
bcostm 0:5d8241e6bd3b 558 }
bcostm 0:5d8241e6bd3b 559 }
bcostm 0:5d8241e6bd3b 560 }
bcostm 0:5d8241e6bd3b 561 }
bcostm 0:5d8241e6bd3b 562
bcostm 0:5d8241e6bd3b 563 /**
bcostm 0:5d8241e6bd3b 564 * @brief Activates display update sequence.
bcostm 0:5d8241e6bd3b 565 * @param None
bcostm 0:5d8241e6bd3b 566 * @retval None
bcostm 0:5d8241e6bd3b 567 */
bcostm 0:5d8241e6bd3b 568 void EPD_GDE021A1::gde021a1_RefreshDisplay(void)
bcostm 0:5d8241e6bd3b 569 {
bcostm 0:5d8241e6bd3b 570 /* Write on the Display update control register */
bcostm 0:5d8241e6bd3b 571 EPD_IO_WriteReg(EPD_REG_34);
bcostm 0:5d8241e6bd3b 572
bcostm 0:5d8241e6bd3b 573 /* Display update data sequence option */
bcostm 0:5d8241e6bd3b 574 EPD_IO_WriteData(0xC4);
bcostm 0:5d8241e6bd3b 575
bcostm 0:5d8241e6bd3b 576 /* Launching the update: Nothing should interrupt this sequence in order
bcostm 0:5d8241e6bd3b 577 to avoid display corruption */
bcostm 0:5d8241e6bd3b 578 EPD_IO_WriteReg(EPD_REG_32);
bcostm 0:5d8241e6bd3b 579 }
bcostm 0:5d8241e6bd3b 580
bcostm 0:5d8241e6bd3b 581 /**
bcostm 0:5d8241e6bd3b 582 * @brief Disables the clock and the charge pump.
bcostm 0:5d8241e6bd3b 583 * @param None
bcostm 0:5d8241e6bd3b 584 * @retval None
bcostm 0:5d8241e6bd3b 585 */
bcostm 0:5d8241e6bd3b 586 void EPD_GDE021A1::gde021a1_CloseChargePump(void)
bcostm 0:5d8241e6bd3b 587 {
bcostm 0:5d8241e6bd3b 588 /* Write on the Display update control register */
bcostm 0:5d8241e6bd3b 589 EPD_IO_WriteReg(EPD_REG_34);
bcostm 0:5d8241e6bd3b 590
bcostm 0:5d8241e6bd3b 591 /* Disable CP then Disable Clock signal */
bcostm 0:5d8241e6bd3b 592 EPD_IO_WriteData(0x03);
bcostm 0:5d8241e6bd3b 593
bcostm 0:5d8241e6bd3b 594 /* Launching the update: Nothing should interrupt this sequence in order
bcostm 0:5d8241e6bd3b 595 to avoid display corruption */
bcostm 0:5d8241e6bd3b 596 EPD_IO_WriteReg(EPD_REG_32);
bcostm 0:5d8241e6bd3b 597 }
bcostm 0:5d8241e6bd3b 598
bcostm 0:5d8241e6bd3b 599 /**
bcostm 0:5d8241e6bd3b 600 * @brief Sets a display window.
bcostm 0:5d8241e6bd3b 601 * @param Xpos: specifies the X bottom left position.
bcostm 0:5d8241e6bd3b 602 * @param Ypos: specifies the Y bottom left position.
bcostm 0:5d8241e6bd3b 603 * @param Width: display window width.
bcostm 0:5d8241e6bd3b 604 * @param Height: display window height.
bcostm 0:5d8241e6bd3b 605 * @retval None
bcostm 0:5d8241e6bd3b 606 */
bcostm 0:5d8241e6bd3b 607 void EPD_GDE021A1::gde021a1_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
bcostm 0:5d8241e6bd3b 608 {
bcostm 0:5d8241e6bd3b 609 /* Set Y position and the height */
bcostm 0:5d8241e6bd3b 610 EPD_IO_WriteReg(EPD_REG_68);
bcostm 0:5d8241e6bd3b 611 EPD_IO_WriteData(Ypos);
bcostm 0:5d8241e6bd3b 612 EPD_IO_WriteData(Height);
bcostm 0:5d8241e6bd3b 613 /* Set X position and the width */
bcostm 0:5d8241e6bd3b 614 EPD_IO_WriteReg(EPD_REG_69);
bcostm 0:5d8241e6bd3b 615 EPD_IO_WriteData(Xpos);
bcostm 0:5d8241e6bd3b 616 EPD_IO_WriteData(Width);
bcostm 0:5d8241e6bd3b 617 /* Set the height counter */
bcostm 0:5d8241e6bd3b 618 EPD_IO_WriteReg(EPD_REG_78);
bcostm 0:5d8241e6bd3b 619 EPD_IO_WriteData(Ypos);
bcostm 0:5d8241e6bd3b 620 /* Set the width counter */
bcostm 0:5d8241e6bd3b 621 EPD_IO_WriteReg(EPD_REG_79);
bcostm 0:5d8241e6bd3b 622 EPD_IO_WriteData(Xpos);
bcostm 0:5d8241e6bd3b 623 }
bcostm 0:5d8241e6bd3b 624
bcostm 0:5d8241e6bd3b 625 /**
bcostm 0:5d8241e6bd3b 626 * @brief Gets the EPD pixel Width.
bcostm 0:5d8241e6bd3b 627 * @param None
bcostm 0:5d8241e6bd3b 628 * @retval The EPD Pixel Width
bcostm 0:5d8241e6bd3b 629 */
bcostm 0:5d8241e6bd3b 630 uint16_t EPD_GDE021A1::gde021a1_GetEpdPixelWidth(void)
bcostm 0:5d8241e6bd3b 631 {
bcostm 0:5d8241e6bd3b 632 return GDE021A1_EPD_PIXEL_WIDTH;
bcostm 0:5d8241e6bd3b 633 }
bcostm 0:5d8241e6bd3b 634
bcostm 0:5d8241e6bd3b 635 /**
bcostm 0:5d8241e6bd3b 636 * @brief Gets the EPD pixel Height.
bcostm 0:5d8241e6bd3b 637 * @param None
bcostm 0:5d8241e6bd3b 638 * @retval The EPD Pixel Height
bcostm 0:5d8241e6bd3b 639 */
bcostm 0:5d8241e6bd3b 640 uint16_t EPD_GDE021A1::gde021a1_GetEpdPixelHeight(void)
bcostm 0:5d8241e6bd3b 641 {
bcostm 0:5d8241e6bd3b 642 return GDE021A1_EPD_PIXEL_HEIGHT;
bcostm 0:5d8241e6bd3b 643 }
bcostm 0:5d8241e6bd3b 644
bcostm 0:5d8241e6bd3b 645 /**
bcostm 0:5d8241e6bd3b 646 * @brief Draws a character on EPD.
bcostm 0:5d8241e6bd3b 647 * @param Xpos: specifies the X position, can be a value from 0 to 171
bcostm 0:5d8241e6bd3b 648 * @param Ypos: specifies the Y position, can be a value from 0 to 17
bcostm 0:5d8241e6bd3b 649 * @param c: pointer to the character data
bcostm 0:5d8241e6bd3b 650 * @retval None
bcostm 0:5d8241e6bd3b 651 */
bcostm 0:5d8241e6bd3b 652 void EPD_GDE021A1::DrawChar(uint16_t Xpos, uint16_t Ypos, const uint8_t *c)
bcostm 0:5d8241e6bd3b 653 {
bcostm 0:5d8241e6bd3b 654 uint32_t index = 0;
bcostm 0:5d8241e6bd3b 655 uint32_t data_length = 0;
bcostm 0:5d8241e6bd3b 656 uint16_t height = 0;
bcostm 0:5d8241e6bd3b 657 uint16_t width = 0;
bcostm 0:5d8241e6bd3b 658
bcostm 0:5d8241e6bd3b 659 width = pFont->Width;
bcostm 0:5d8241e6bd3b 660 height = pFont->Height;
bcostm 0:5d8241e6bd3b 661
bcostm 0:5d8241e6bd3b 662 /* Set the Character display window */
bcostm 0:5d8241e6bd3b 663 gde021a1_SetDisplayWindow(Xpos, Ypos, (Xpos + width - 1), (Ypos + height - 1));
bcostm 0:5d8241e6bd3b 664
bcostm 0:5d8241e6bd3b 665 data_length = (height * width);
bcostm 0:5d8241e6bd3b 666
bcostm 0:5d8241e6bd3b 667 for(index = 0; index < data_length; index++)
bcostm 0:5d8241e6bd3b 668 {
bcostm 0:5d8241e6bd3b 669 gde021a1_WritePixel(c[index]);
bcostm 0:5d8241e6bd3b 670 }
bcostm 0:5d8241e6bd3b 671 }