16 GxEPD2_EPD(cs, dc, rst, busy, LOW, 40000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
23 if (value == 0xFF) value = 0x33;
29 for (uint32_t i = 0; i < uint32_t(
WIDTH) * uint32_t(
HEIGHT) / 2; i++)
46 for (uint32_t i = 0; i < uint32_t(
WIDTH) * uint32_t(
HEIGHT) / 8; i++)
48 _send8pixel(~black_value, ~color_value);
58 if (value == 0xFF) value = 0x33;
64 for (uint32_t i = 0; i < uint32_t(
WIDTH) * uint32_t(
HEIGHT) / 2; i++)
80 for (uint32_t i = 0; uint32_t(
WIDTH) * uint32_t(
HEIGHT) / 8; i++)
82 _send8pixel(~black_value, ~color_value);
88void GxEPD2_583c::writeImage(
const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
90 writeImage(bitmap, NULL, x, y, w, h, invert, mirror_y, pgm);
93void GxEPD2_583c::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)
97 uint16_t wb = (w + 7) / 8;
100 int16_t x1 = x < 0 ? 0 : x;
101 int16_t y1 = y < 0 ? 0 : y;
102 int16_t w1 = x + w < int16_t(
WIDTH) ? w : int16_t(
WIDTH) - x;
103 int16_t h1 = y + h < int16_t(
HEIGHT) ? h : int16_t(
HEIGHT) - y;
108 if ((w1 <= 0) || (h1 <= 0))
return;
111 _setPartialRamArea(x1, y1, w1, h1);
114 for (int16_t i = 0; i < h1; i++)
116 for (int16_t j = 0; j < w1 / 8; j++)
118 uint8_t black_data = 0xFF;
119 uint8_t color_data = 0xFF;
123 uint16_t idx = mirror_y ? j + dx / 8 + uint16_t((h - 1 - (i + dy))) * wb : j + dx / 8 + uint16_t(i + dy) * wb;
126#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
127 black_data = pgm_read_byte(&black[idx]);
129 black_data = black[idx];
134 black_data = black[idx];
136 if (invert) black_data = ~black_data;
141 uint16_t idx = mirror_y ? j + dx / 8 + uint16_t((h - 1 - (i + dy))) * wb : j + dx / 8 + uint16_t(i + dy) * wb;
144#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
145 color_data = pgm_read_byte(&color[idx]);
147 color_data = color[idx];
152 color_data = color[idx];
154 if (invert) color_data = ~color_data;
156 _send8pixel(~black_data, ~color_data);
168 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
170 writeImagePart(bitmap, NULL, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
174 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
178 if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0))
return;
179 if ((x_part < 0) || (x_part >= w_bitmap))
return;
180 if ((y_part < 0) || (y_part >= h_bitmap))
return;
181 uint16_t wb_bitmap = (w_bitmap + 7) / 8;
182 x_part -= x_part % 8;
183 w = w_bitmap - x_part < w ? w_bitmap - x_part : w;
184 h = h_bitmap - y_part < h ? h_bitmap - y_part : h;
186 w = 8 * ((w + 7) / 8);
187 int16_t x1 = x < 0 ? 0 : x;
188 int16_t y1 = y < 0 ? 0 : y;
189 int16_t w1 = x + w < int16_t(
WIDTH) ? w : int16_t(
WIDTH) - x;
190 int16_t h1 = y + h < int16_t(
HEIGHT) ? h : int16_t(
HEIGHT) - y;
195 if ((w1 <= 0) || (h1 <= 0))
return;
198 _setPartialRamArea(x1, y1, w1, h1);
201 for (int16_t i = 0; i < h1; i++)
203 for (int16_t j = 0; j < w1 / 8; j++)
205 uint8_t black_data = 0xFF;
206 uint8_t color_data = 0xFF;
208 uint16_t idx = mirror_y ? x_part / 8 + j + dx / 8 + uint16_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / 8 + j + dx / 8 + uint16_t(y_part + i + dy) * wb_bitmap;
213#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
214 black_data = pgm_read_byte(&black[idx]);
216 black_data = black[idx];
221 black_data = black[idx];
223 if (invert) black_data = ~black_data;
229#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
230 color_data = pgm_read_byte(&color[idx]);
232 color_data = color[idx];
237 color_data = color[idx];
239 if (invert) color_data = ~color_data;
241 _send8pixel(~black_data, ~color_data);
252void GxEPD2_583c::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 uint16_t wb = (w + 1) / 2;
261 int16_t x1 = x < 0 ? 0 : x;
262 int16_t y1 = y < 0 ? 0 : y;
263 int16_t w1 = x + w < int16_t(
WIDTH) ? w : int16_t(
WIDTH) - x;
264 int16_t h1 = y + h < int16_t(
HEIGHT) ? h : int16_t(
HEIGHT) - y;
269 if ((w1 <= 0) || (h1 <= 0))
return;
272 _setPartialRamArea(x1, y1, w1, h1);
275 for (int16_t i = 0; i < h1; i++)
277 for (int16_t j = 0; j < w1 / 2; j++)
281 uint16_t idx = mirror_y ? j + dx / 2 + uint16_t((h - 1 - (i + dy))) * wb : j + dx / 2 + uint16_t(i + dy) * wb;
284#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
285 data = pgm_read_byte(&data1[idx]);
294 if (invert) data = ~data;
304void GxEPD2_583c::drawImage(
const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
306 writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
311 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
313 writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
317void GxEPD2_583c::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)
319 writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
323void GxEPD2_583c::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,
324 int16_t x, int16_t y, int16_t w, int16_t h,
bool invert,
bool mirror_y,
bool pgm)
326 writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
330void GxEPD2_583c::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)
332 writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
345 int16_t w1 = x < 0 ? w + x : w;
346 int16_t h1 = y < 0 ? h + y : h;
347 int16_t x1 = x < 0 ? 0 : x;
348 int16_t y1 = y < 0 ? 0 : y;
349 w1 = x1 + w1 < int16_t(
WIDTH) ? w1 : int16_t(
WIDTH) - x1;
350 h1 = y1 + h1 < int16_t(
HEIGHT) ? h1 : int16_t(
HEIGHT) - y1;
351 if ((w1 <= 0) || (h1 <= 0))
return;
354 if (w1 % 8 > 0) w1 += 8 - w1 % 8;
357 _setPartialRamArea(x1, y1, w1, h1);
378void GxEPD2_583c::_send8pixel(uint8_t black_data, uint8_t color_data)
380 for (uint8_t j = 0; j < 8; j++)
383 if (black_data & 0x80);
384 else if (color_data & 0x80) t = 0x04;
390 if (black_data & 0x80);
391 else if (color_data & 0x80) t |= 0x04;
399void GxEPD2_583c::_setPartialRamArea(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
401 uint16_t xe = (x + w - 1) | 0x0007;
402 uint16_t ye = y + h - 1;
418void GxEPD2_583c::_PowerOn()
428void GxEPD2_583c::_PowerOff()
435void GxEPD2_583c::_InitDisplay()
468void GxEPD2_583c::_Init_Full()
474void GxEPD2_583c::_Init_Part()
480void GxEPD2_583c::_Update_Full()
486void GxEPD2_583c::_Update_Part()
static const uint16_t HEIGHT
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 WIDTH
static const uint16_t partial_refresh_time
static const uint16_t full_refresh_time
void clearScreen(uint8_t value=0x33)
GxEPD2_583c(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)
void refresh(bool partial_update_mode=false)
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 writeScreenBuffer(uint8_t value=0x33)
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)
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)
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)
static const uint16_t power_on_time
static const uint16_t power_off_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)