18 GxEPD2_EPD(cs, dc, rst, busy, LOW, 25000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
45 for (uint32_t i = 0; i < uint32_t(
WIDTH) * uint32_t(
HEIGHT) / 2; i++)
48 _transfer(0xFF == black_value ? 0x11 : black_value);
53void GxEPD2_565c::writeImage(
const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
58 if (_paged && (x == 0) && (w == int16_t(
WIDTH)) && (h < int16_t(
HEIGHT)))
62 for (uint32_t i = 0; i < uint32_t(
WIDTH) * uint32_t(h) / 8; i++)
64 uint8_t data = bitmap[i];
65 for (int16_t k = 0; k < 4; k++)
67 uint8_t data2 = (data & 0x80 ? 0x10 : 0x00) | (data & 0x40 ? 0x01 : 0x00);
82 int16_t wb = (w + 7) / 8;
85 if ((w <= 0) || (h <= 0))
return;
89 for (int16_t i = 0; i < int16_t(
HEIGHT); i++)
91 for (int16_t j = 0; j < int16_t(
WIDTH); j += 8)
94 if ((j >= x) && (j <= x + w) && (i >= y) && (i < y + h))
96 uint32_t idx = mirror_y ? (j - x) / 8 + uint32_t((h - 1 - (i - y))) * wb : (j - x) / 8 + uint32_t(i - y) * wb;
99#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
100 data = pgm_read_byte(&bitmap[idx]);
109 if (invert) data = ~data;
111 for (int16_t k = 0; k < 4; k++)
113 uint8_t data2 = (data & 0x80 ? 0x10 : 0x00) | (data & 0x40 ? 0x01 : 0x00);
124void GxEPD2_565c::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)
126 if (!black && !color)
return;
127 if (!color)
return writeImage(black, x, y, w, h, invert, mirror_y, pgm);
131 if (_paged && (x == 0) && (w == int16_t(
WIDTH)) && (h < int16_t(
HEIGHT)))
135 for (uint32_t i = 0; i < uint32_t(
WIDTH) * uint32_t(h) / 8; i++)
137 uint8_t black_data = black[i];
138 uint8_t color_data = color[i];
139 for (int16_t k = 0; k < 4; k++)
141 uint8_t out_data = 0x00;
142 for (int16_t l = 0; l < 2; l++)
145 if (!(color_data & 0x80)) out_data |= 0x04;
146 else out_data |= black_data & 0x80 ? 0x01 : 0x00;
163 int16_t wb = (w + 7) / 8;
166 if ((w <= 0) || (h <= 0))
return;
170 for (int16_t i = 0; i < int16_t(
HEIGHT); i++)
172 for (int16_t j = 0; j < int16_t(
WIDTH); j += 8)
174 uint8_t black_data = 0xFF, color_data = 0xFF;
175 if ((j >= x) && (j < x + w) && (i >= y) && (i < y + h))
177 uint32_t idx = mirror_y ? (j - x) / 8 + uint32_t((h - 1 - (i - y))) * wb : (j - x) / 8 + uint32_t(i - y) * wb;
180#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
181 black_data = pgm_read_byte(&black[idx]);
182 color_data = pgm_read_byte(&color[idx]);
184 black_data = black[idx];
185 color_data = color[idx];
190 black_data = black[idx];
191 color_data = color[idx];
195 black_data = ~black_data;
196 color_data = ~color_data;
199 for (int16_t k = 0; k < 4; k++)
201 uint8_t out_data = 0x00;
202 for (int16_t l = 0; l < 2; l++)
205 if (!(color_data & 0x80)) out_data |= 0x04;
206 else out_data |= black_data & 0x80 ? 0x01 : 0x00;
220 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
223 if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0))
return;
224 if ((x_part < 0) || (x_part >= w_bitmap))
return;
225 if ((y_part < 0) || (y_part >= h_bitmap))
return;
226 int16_t wb_bitmap = (w_bitmap + 7) / 8;
227 x_part -= x_part % 8;
228 w = w_bitmap - x_part < w ? w_bitmap - x_part : w;
229 h = h_bitmap - y_part < h ? h_bitmap - y_part : h;
231 w = 8 * ((w + 7) / 8);
232 int16_t x1 = x < 0 ? 0 : x;
233 int16_t y1 = y < 0 ? 0 : y;
234 int16_t w1 = x + w < int16_t(
WIDTH) ? w : int16_t(
WIDTH) - x;
235 int16_t h1 = y + h < int16_t(
HEIGHT) ? h : int16_t(
HEIGHT) - y;
240 if ((w1 <= 0) || (h1 <= 0))
return;
244 for (int16_t i = 0; i < int16_t(
HEIGHT); i++)
246 for (int16_t j = 0; j < int16_t(
WIDTH); j += 8)
249 if ((j >= x1) && (j < x1 + w) && (i >= y1) && (i < y1 + h))
252 uint32_t idx = mirror_y ? (x_part + j - x1) / 8 + uint32_t((h_bitmap - 1 - (y_part + i - y1))) * wb_bitmap : (x_part + j - x1) / 8 + uint32_t(y_part + i - y1) * wb_bitmap;
255#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
256 data = pgm_read_byte(&bitmap[idx]);
265 if (invert) data = ~data;
267 for (int16_t k = 0; k < 4; k++)
269 uint8_t data2 = (data & 0x80 ? 0x10 : 0x00) | (data & 0x40 ? 0x01 : 0x00);
280 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
286 if (!black && !color)
return;
287 if (!color)
return writeImagePart(black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
289 if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0))
return;
290 if ((x_part < 0) || (x_part >= w_bitmap))
return;
291 if ((y_part < 0) || (y_part >= h_bitmap))
return;
292 int16_t wb_bitmap = (w_bitmap + 7) / 8;
293 x_part -= x_part % 8;
294 w = w_bitmap - x_part < w ? w_bitmap - x_part : w;
295 h = h_bitmap - y_part < h ? h_bitmap - y_part : h;
297 w = 8 * ((w + 7) / 8);
298 int16_t x1 = x < 0 ? 0 : x;
299 int16_t y1 = y < 0 ? 0 : y;
300 int16_t w1 = x + w < int16_t(
WIDTH) ? w : int16_t(
WIDTH) - x;
301 int16_t h1 = y + h < int16_t(
HEIGHT) ? h : int16_t(
HEIGHT) - y;
306 if ((w1 <= 0) || (h1 <= 0))
return;
310 for (int16_t i = 0; i < int16_t(
HEIGHT); i++)
312 for (int16_t j = 0; j < int16_t(
WIDTH); j += 8)
314 uint8_t black_data = 0xFF, color_data = 0xFF;
315 if ((j >= x1) && (j < x1 + w) && (i >= y1) && (i < y1 + h))
318 uint32_t idx = mirror_y ? (x_part + j - x1) / 8 + uint32_t((h_bitmap - 1 - (y_part + i - y1))) * wb_bitmap : (x_part + j - x1) / 8 + uint32_t(y_part + i - y1) * wb_bitmap;
321#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
322 black_data = pgm_read_byte(&black[idx]);
323 color_data = pgm_read_byte(&color[idx]);
325 black_data = black[idx];
326 color_data = color[idx];
331 black_data = black[idx];
332 color_data = color[idx];
336 black_data = ~black_data;
337 color_data = ~color_data;
340 for (int16_t k = 0; k < 4; k++)
342 uint8_t out_data = 0x00;
343 for (int16_t l = 0; l < 2; l++)
346 if (!(color_data & 0x80)) out_data |= 0x04;
347 else out_data |= black_data & 0x80 ? 0x01 : 0x00;
359void GxEPD2_565c::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)
366 if (_paged && (x == 0) && (w == int16_t(
WIDTH)) && (h < int16_t(
HEIGHT)))
370 for (uint32_t i = 0; i < uint32_t(
WIDTH) * uint32_t(h) / 2; i++)
372 uint8_t data = data1[i];
385 int16_t wb = (w + 1) / 2;
388 if ((w <= 0) || (h <= 0))
return;
392 for (int16_t i = 0; i < int16_t(
HEIGHT); i++)
394 for (int16_t j = 0; j < int16_t(
WIDTH); j += 2)
399 if ((j >= x) && (j < x + w) && (i >= y) && (i < y + h))
401 uint32_t idx = mirror_y ? (j - x) / 2 + uint32_t((h - 1 - (i - y))) * wb : (j - x) / 2 + uint32_t(i - y) * wb;
404#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
405 data = pgm_read_byte(&data1[idx]);
414 if (invert) data = ~data;
427 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
435 if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0))
return;
436 if ((x_part < 0) || (x_part >= w_bitmap))
return;
437 if ((y_part < 0) || (y_part >= h_bitmap))
return;
438 int16_t wb_bitmap = (w_bitmap + 1) / 2;
439 x_part -= x_part % 2;
440 w = w_bitmap - x_part < w ? w_bitmap - x_part : w;
441 h = h_bitmap - y_part < h ? h_bitmap - y_part : h;
443 w = 2 * ((w + 1) / 2);
444 int16_t x1 = x < 0 ? 0 : x;
445 int16_t y1 = y < 0 ? 0 : y;
446 int16_t w1 = x + w < int16_t(
WIDTH) ? w : int16_t(
WIDTH) - x;
447 int16_t h1 = y + h < int16_t(
HEIGHT) ? h : int16_t(
HEIGHT) - y;
452 if ((w1 <= 0) || (h1 <= 0))
return;
456 for (int16_t i = 0; i < int16_t(
HEIGHT); i++)
458 for (int16_t j = 0; j < int16_t(
WIDTH); j += 2)
461 if ((j >= x1) && (j < x1 + w) && (i >= y1) && (i < y1 + h))
464 uint32_t idx = mirror_y ? (x_part + j - x1) / 2 + uint32_t((h_bitmap - 1 - (y_part + i - y1))) * wb_bitmap : (x_part + j - x1) / 2 + uint32_t(y_part + i - y1) * wb_bitmap;
467#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
468 data = pgm_read_byte(&data1[idx]);
477 if (invert) data = ~data;
486void GxEPD2_565c::drawImage(
const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
488 writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
493 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
495 writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
499void GxEPD2_565c::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)
501 writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
505void GxEPD2_565c::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,
506 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
508 writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
512void GxEPD2_565c::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)
514 writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
552void GxEPD2_565c::_PowerOn()
562void GxEPD2_565c::_PowerOff()
573void GxEPD2_565c::_InitDisplay()
610void GxEPD2_565c::_Init_Full()
616void GxEPD2_565c::_Init_Part()
622void GxEPD2_565c::_Update_Full()
628void GxEPD2_565c::_Update_Part()
void writeScreenBuffer(uint8_t value=0xFF)
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)
static const uint16_t partial_refresh_time
static const uint16_t power_on_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)
static const uint16_t HEIGHT
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 writeNativePart(const uint8_t *data1, const uint8_t *data2, 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 refresh(bool partial_update_mode=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)
GxEPD2_565c(int16_t cs, int16_t dc, int16_t rst, int16_t busy)
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 clearScreen(uint8_t value=0xFF)
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 power_off_time
static const uint16_t WIDTH
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)