16 GxEPD2_EPD(cs, dc, rst, busy, LOW, 20000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
33 for (uint32_t i = 0; i < uint32_t(
WIDTH) * uint32_t(
HEIGHT) / 8; i++)
40 for (uint32_t i = 0; i < uint32_t(
WIDTH) * uint32_t(
HEIGHT) / 8; i++)
62 for (uint16_t i = 0; i < uint32_t(
WIDTH) * uint32_t(
HEIGHT) / 8; i++)
69 for (uint16_t i = 0; i < uint32_t(
WIDTH) * uint32_t(
HEIGHT) / 8; i++)
77void GxEPD2_420c::writeImage(
const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
79 writeImage(bitmap, NULL, x, y, w, h, invert, mirror_y, pgm);
82void GxEPD2_420c::writeImage(
const uint8_t* black,
const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
86 int16_t wb = (w + 7) / 8;
89 int16_t x1 = x < 0 ? 0 : x;
90 int16_t y1 = y < 0 ? 0 : y;
91 int16_t w1 = x + w < int16_t(
WIDTH) ? w : int16_t(
WIDTH) - x;
92 int16_t h1 = y + h < int16_t(
HEIGHT) ? h : int16_t(
HEIGHT) - y;
97 if ((w1 <= 0) || (h1 <= 0))
return;
100 _setPartialRamArea(x1, y1, w1, h1);
103 for (int16_t i = 0; i < h1; i++)
105 for (int16_t j = 0; j < w1 / 8; j++)
111 int16_t idx = mirror_y ? j + dx / 8 + ((h - 1 - (i + dy))) * wb : j + dx / 8 + (i + dy) * wb;
114#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
115 data = pgm_read_byte(&black[idx]);
124 if (invert) data = ~data;
132 for (int16_t i = 0; i < h1; i++)
134 for (int16_t j = 0; j < w1 / 8; j++)
140 int16_t idx = mirror_y ? j + dx / 8 + ((h - 1 - (i + dy))) * wb : j + dx / 8 + (i + dy) * wb;
143#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
144 data = pgm_read_byte(&color[idx]);
153 if (invert) data = ~data;
164 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
166 writeImagePart(bitmap, NULL, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
170 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
174 if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0))
return;
175 if ((x_part < 0) || (x_part >= w_bitmap))
return;
176 if ((y_part < 0) || (y_part >= h_bitmap))
return;
177 int16_t wb_bitmap = (w_bitmap + 7) / 8;
178 x_part -= x_part % 8;
179 w = w_bitmap - x_part < w ? w_bitmap - x_part : w;
180 h = h_bitmap - y_part < h ? h_bitmap - y_part : h;
182 w = 8 * ((w + 7) / 8);
183 int16_t x1 = x < 0 ? 0 : x;
184 int16_t y1 = y < 0 ? 0 : y;
185 int16_t w1 = x + w < int16_t(
WIDTH) ? w : int16_t(
WIDTH) - x;
186 int16_t h1 = y + h < int16_t(
HEIGHT) ? h : int16_t(
HEIGHT) - y;
191 if ((w1 <= 0) || (h1 <= 0))
return;
194 _setPartialRamArea(x1, y1, w1, h1);
197 for (int16_t i = 0; i < h1; i++)
199 for (int16_t j = 0; j < w1 / 8; j++)
203 int16_t idx = mirror_y ? x_part / 8 + j + dx / 8 + ((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 8 + j + dx / 8 + (y_part + i + dy) * wb_bitmap;
206#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
207 data = pgm_read_byte(&black[idx]);
216 if (invert) data = ~data;
223 for (int16_t i = 0; i < h1; i++)
225 for (int16_t j = 0; j < w1 / 8; j++)
231 int16_t idx = mirror_y ? x_part / 8 + j + dx / 8 + ((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 8 + j + dx / 8 + (y_part + i + dy) * wb_bitmap;
234#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
235 data = pgm_read_byte(&color[idx]);
244 if (invert) data = ~data;
254void GxEPD2_420c::writeNative(
const uint8_t* data1,
const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
258 writeImage(data1, x, y, w, h, invert, mirror_y, pgm);
262void GxEPD2_420c::drawImage(
const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
264 writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
269 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
271 writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
275void GxEPD2_420c::drawImage(
const uint8_t* black,
const uint8_t* color, int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
277 writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
281void GxEPD2_420c::drawImagePart(
const uint8_t* black,
const uint8_t* color, int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap,
282 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
284 writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
288void GxEPD2_420c::drawNative(
const uint8_t* data1,
const uint8_t* data2, int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
290 writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
303 int16_t w1 = x < 0 ? w + x : w;
304 int16_t h1 = y < 0 ? h + y : h;
305 int16_t x1 = x < 0 ? 0 : x;
306 int16_t y1 = y < 0 ? 0 : y;
307 w1 = x1 + w1 < int16_t(
WIDTH) ? w1 : int16_t(
WIDTH) - x1;
308 h1 = y1 + h1 < int16_t(
HEIGHT) ? h1 : int16_t(
HEIGHT) - y1;
309 if ((w1 <= 0) || (h1 <= 0))
return;
312 if (w1 % 8 > 0) w1 += 8 - w1 % 8;
316 _setPartialRamArea(x1, y1, w1, h1);
337void GxEPD2_420c::_setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
339 uint16_t xe = (x + w - 1) | 0x0007;
340 uint16_t ye = y + h - 1;
356void GxEPD2_420c::_PowerOn()
366void GxEPD2_420c::_PowerOff()
373void GxEPD2_420c::_InitDisplay()
391void GxEPD2_420c::_Init_Full()
397void GxEPD2_420c::_Init_Part()
403void GxEPD2_420c::_Update_Full()
409void GxEPD2_420c::_Update_Part()
void refresh(bool partial_update_mode=false)
void writeScreenBuffer(uint8_t value=0xFF)
static const bool usePartialUpdateWindow
void writeImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
void writeNative(const uint8_t *data1, const uint8_t *data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
void drawNative(const uint8_t *data1, const uint8_t *data2, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
static const uint16_t WIDTH
static const uint16_t power_on_time
void writeImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
GxEPD2_420c(int16_t cs, int16_t dc, int16_t rst, int16_t busy)
static const uint16_t HEIGHT
void clearScreen(uint8_t value=0xFF)
static const uint16_t partial_refresh_time
static const uint16_t power_off_time
void drawImage(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
void drawImagePart(const uint8_t bitmap[], int16_t x_part, int16_t y_part, int16_t w_bitmap, int16_t h_bitmap, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)
static const uint16_t full_refresh_time
void _writeCommand(uint8_t c)
void _writeData(uint8_t d)
void _waitWhileBusy(const char *comment=0, uint16_t busy_time=5000)
void _transfer(uint8_t value)