Paperd.Ink Library 0.0.5
Library for interacting with Paperd.Ink devices.
Loading...
Searching...
No Matches
GxEPD2_BW< GxEPD2_Type, page_height > Class Template Reference

#include <GxEPD2_BW.h>

Inheritance diagram for GxEPD2_BW< GxEPD2_Type, page_height >:

Public Member Functions

 GxEPD2_BW (GxEPD2_Type epd2_instance)
 
uint16_t pages ()
 
uint16_t pageHeight ()
 
bool mirror (bool m)
 
void drawPixel (int16_t x, int16_t y, uint16_t color)
 
void drawGreyPixel (int16_t x, int16_t y, uint8_t grey)
 
void init (uint32_t serial_diag_bitrate=0)
 
void init (uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration=10, bool pulldown_rst_mode=false)
 
void init (uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration, bool pulldown_rst_mode, SPIClass &spi, SPISettings spi_settings)
 
void fillScreen (uint16_t color)
 
void display (bool partial_update_mode=false)
 
void displayWindow (uint16_t x, uint16_t y, uint16_t w, uint16_t h)
 
void setFullWindow ()
 
void setPartialWindow (uint16_t x, uint16_t y, uint16_t w, uint16_t h)
 
void firstPage ()
 
bool nextPage ()
 
void drawPaged (void(*drawCallback)(const void *), const void *pv)
 
void drawInvertedBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color)
 
void drawGreyPixmap (const uint8_t pixmap[], int16_t depth, int16_t x, int16_t y, int16_t w, int16_t h)
 
void clearScreen (uint8_t value=0xFF)
 
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)
 
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 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)
 
void writeImage (const uint8_t *black, const uint8_t *color, int16_t x, int16_t y, int16_t w, int16_t h)
 
void writeImagePart (const uint8_t *black, const uint8_t *color, 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, bool mirror_y, bool pgm)
 
void writeImagePart (const uint8_t *black, const uint8_t *color, 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)
 
void 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)
 
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)
 
void 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)
 
void drawImage (const uint8_t *black, const uint8_t *color, int16_t x, int16_t y, int16_t w, int16_t h)
 
void 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, int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
 
void 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, int16_t x, int16_t y, int16_t w, int16_t h)
 
void 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)
 
void refresh (bool partial_update_mode=false)
 
void refresh (int16_t x, int16_t y, int16_t w, int16_t h)
 
void powerOff ()
 
void hibernate ()
 

Public Attributes

GxEPD2_Type epd2
 

Detailed Description

template<typename GxEPD2_Type, const uint16_t page_height>
class GxEPD2_BW< GxEPD2_Type, page_height >

Definition at line 82 of file GxEPD2_BW.h.

Constructor & Destructor Documentation

◆ GxEPD2_BW()

template<typename GxEPD2_Type , const uint16_t page_height>
GxEPD2_BW< GxEPD2_Type, page_height >::GxEPD2_BW ( GxEPD2_Type epd2_instance)
inline

Definition at line 89 of file GxEPD2_BW.h.

89 : GxEPD2_GFX_BASE_CLASS(GxEPD2_Type::WIDTH, GxEPD2_Type::HEIGHT), epd2(epd2_instance)
90#endif
91 {
92 _page_height = page_height;
93 _pages = (HEIGHT / _page_height) + ((HEIGHT % _page_height) > 0);
94 _reverse = (epd2_instance.panel == GxEPD2::GDE0213B1);
95 _mirror = false;
96 _using_partial_mode = false;
97 _current_page = 0;
99 }
#define GxEPD2_GFX_BASE_CLASS
Definition GxEPD2_BW.h:30
GxEPD2_Type epd2
Definition GxEPD2_BW.h:85
void setFullWindow()
Definition GxEPD2_BW.h:275
@ GDE0213B1
Definition GxEPD2.h:45

Member Function Documentation

◆ clearScreen()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::clearScreen ( uint8_t value = 0xFF)
inline

Definition at line 609 of file GxEPD2_BW.h.

610 {
611 epd2.clearScreen(value);
612 }

◆ display()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::display ( bool partial_update_mode = false)
inline

Definition at line 241 of file GxEPD2_BW.h.

242 {
243 if (partial_update_mode) epd2.writeImage(_buffer, 0, 0, WIDTH, _page_height);
244 else epd2.writeImageForFullRefresh(_buffer, 0, 0, WIDTH, _page_height);
245 epd2.refresh(partial_update_mode);
246 if (epd2.hasFastPartialUpdate)
247 {
248 epd2.writeImageAgain(_buffer, 0, 0, WIDTH, _page_height);
249 }
250 if (!partial_update_mode) epd2.powerOff();
251 }

◆ displayWindow()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::displayWindow ( uint16_t x,
uint16_t y,
uint16_t w,
uint16_t h )
inline

Definition at line 259 of file GxEPD2_BW.h.

260 {
261 x = gx_uint16_min(x, width());
262 y = gx_uint16_min(y, height());
263 w = gx_uint16_min(w, width() - x);
264 h = gx_uint16_min(h, height() - y);
265 _rotate(x, y, w, h);
266 uint16_t y_part = _reverse ? HEIGHT - h - y : y;
267 epd2.writeImagePart(_buffer, x, y_part, WIDTH, _page_height, x, y, w, h);
268 epd2.refresh(x, y, w, h);
269 if (epd2.hasFastPartialUpdate)
270 {
271 epd2.writeImagePartAgain(_buffer, x, y_part, WIDTH, _page_height, x, y, w, h);
272 }
273 }

◆ drawGreyPixel()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::drawGreyPixel ( int16_t x,
int16_t y,
uint8_t grey )
inline

Definition at line 161 of file GxEPD2_BW.h.

162 {
163 if ((x < 0) || (x >= width()) || (y < 0) || (y >= height())) return;
164 if (_mirror) x = width() - x - 1;
165 // check rotation, move pixel around if necessary
166 switch (getRotation())
167 {
168 case 1:
169 _swap_(x, y);
170 x = WIDTH - x - 1;
171 break;
172 case 2:
173 x = WIDTH - x - 1;
174 y = HEIGHT - y - 1;
175 break;
176 case 3:
177 _swap_(x, y);
178 y = HEIGHT - y - 1;
179 break;
180 }
181 // transpose partial window to 0,0
182 x -= _pw_x;
183 y -= _pw_y;
184 // clip to (partial) window
185 if ((x < 0) || (x >= _pw_w) || (y < 0) || (y >= _pw_h)) return;
186 // adjust for current page
187 y -= _current_page * _page_height;
188 // check if in current page
189 if ((y < 0) || (y >= _page_height)) return;
190 uint16_t i = x / 4 + y * (_pw_w / 4);
191 _buffer[i] = (_buffer[i] & (0xFF ^ (3 << 2 * (3 - x % 4))));
192 _buffer[i] = (_buffer[i] | ((grey >> 6) << 2 * (3 - x % 4)));
193 }

◆ drawGreyPixmap()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::drawGreyPixmap ( const uint8_t pixmap[],
int16_t depth,
int16_t x,
int16_t y,
int16_t w,
int16_t h )
inline

Definition at line 514 of file GxEPD2_BW.h.

515 {
516 switch (depth)
517 {
518 case 1:
519 {
520 int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
521 uint8_t byte = 0;
522 for (int16_t j = 0; j < h; j++)
523 {
524 for (int16_t i = 0; i < w; i++ )
525 {
526 if (i & 7) byte <<= 1;
527 else
528 {
529#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
530 byte = pgm_read_byte(&pixmap[j * byteWidth + i / 8]);
531#else
532 byte = pixmap[j * byteWidth + i / 8];
533#endif
534 }
535 uint16_t color = byte & 0x80 ? 0xFFFF : 0x0000;
536 drawPixel(x + i, y + j, color);
537 }
538 }
539 }
540 break;
541 case 2:
542 {
543 int16_t byteWidth = (w + 3) / 4; // Bitmap scanline pad = whole byte
544 uint8_t byte = 0;
545 for (int16_t j = 0; j < h; j++)
546 {
547 for (int16_t i = 0; i < w; i++ )
548 {
549 if (i & 3) byte <<= 2;
550 else
551 {
552#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
553 byte = pgm_read_byte(&pixmap[j * byteWidth + i / 4]);
554#else
555 byte = pixmap[j * byteWidth + i / 4];
556#endif
557 }
558 drawGreyPixel(x + i, y + j, byte & 0xC0);
559 }
560 }
561 }
562 break;
563 case 4:
564 {
565 int16_t byteWidth = (w + 1) / 2; // Bitmap scanline pad = whole byte
566 uint8_t byte = 0;
567 for (int16_t j = 0; j < h; j++)
568 {
569 for (int16_t i = 0; i < w; i++ )
570 {
571 if (i & 1) byte <<= 4;
572 else
573 {
574#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
575 byte = pgm_read_byte(&pixmap[j * byteWidth + i / 2]);
576#else
577 byte = pixmap[j * byteWidth + i / 2];
578#endif
579 }
580 uint8_t grey = byte & 0xF0;
581 if ((grey < 0xF0) && (grey >= 0xA0)) grey = 0x80; // light grey demo limit for 4bpp
582 else if ((grey < 0xF0) && (grey > 0x00)) grey = 0x40; // dark grey
583 drawGreyPixel(x + i, y + j, grey);
584 }
585 }
586 }
587 break;
588 case 8:
589 {
590 uint8_t byte = 0;
591 for (int16_t j = 0; j < h; j++)
592 {
593 for (int16_t i = 0; i < w; i++ )
594 {
595#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
596 byte = pgm_read_byte(&pixmap[j * w + i]);
597#else
598 byte = pixmap[j * w + i];
599#endif
600 drawGreyPixel(x + i, y + j, byte);
601 }
602 }
603 }
604 break;
605 }
606 }
void drawPixel(int16_t x, int16_t y, uint16_t color)
Definition GxEPD2_BW.h:117
void drawGreyPixel(int16_t x, int16_t y, uint8_t grey)
Definition GxEPD2_BW.h:161

◆ drawImage() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::drawImage ( const uint8_t * black,
const uint8_t * color,
int16_t x,
int16_t y,
int16_t w,
int16_t h )
inline

Definition at line 664 of file GxEPD2_BW.h.

665 {
666 epd2.drawImage(black, color, x, y, w, h, false, false, false);
667 }

◆ drawImage() [2/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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 )
inline

Definition at line 660 of file GxEPD2_BW.h.

661 {
662 epd2.drawImage(black, color, x, y, w, h, invert, mirror_y, pgm);
663 }

◆ drawImage() [3/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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 )
inline

Definition at line 651 of file GxEPD2_BW.h.

652 {
653 epd2.drawImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
654 }

◆ drawImagePart() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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,
int16_t x,
int16_t y,
int16_t w,
int16_t h )
inline

Definition at line 673 of file GxEPD2_BW.h.

675 {
676 epd2.drawImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, false, false, false);
677 }

◆ drawImagePart() [2/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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,
int16_t x,
int16_t y,
int16_t w,
int16_t h,
bool invert,
bool mirror_y,
bool pgm )
inline

Definition at line 668 of file GxEPD2_BW.h.

670 {
671 epd2.drawImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
672 }

◆ drawImagePart() [3/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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 )
inline

Definition at line 655 of file GxEPD2_BW.h.

657 {
658 epd2.drawImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
659 }

◆ drawInvertedBitmap()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::drawInvertedBitmap ( int16_t x,
int16_t y,
const uint8_t bitmap[],
int16_t w,
int16_t h,
uint16_t color )
inline

Definition at line 488 of file GxEPD2_BW.h.

489 {
490 // taken from Adafruit_GFX.cpp, modified
491 int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
492 uint8_t byte = 0;
493 for (int16_t j = 0; j < h; j++)
494 {
495 for (int16_t i = 0; i < w; i++ )
496 {
497 if (i & 7) byte <<= 1;
498 else
499 {
500#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
501 byte = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
502#else
503 byte = bitmap[j * byteWidth + i / 8];
504#endif
505 }
506 if (!(byte & 0x80))
507 {
508 drawPixel(x + i, y + j, color);
509 }
510 }
511 }
512 }

◆ drawNative()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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 )
inline

Definition at line 679 of file GxEPD2_BW.h.

680 {
681 epd2.drawNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
682 }

◆ drawPaged()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::drawPaged ( void(* drawCallback )(const void *),
const void * pv )
inline

Definition at line 407 of file GxEPD2_BW.h.

408 {
409 if (1 == _pages)
410 {
412 drawCallback(pv);
413 if (_using_partial_mode)
414 {
415 uint32_t offset = _reverse ? (HEIGHT - _pw_h) * _pw_w / 8 : 0;
416 epd2.writeImage(_buffer + offset, _pw_x, _pw_y, _pw_w, _pw_h);
417 epd2.refresh(_pw_x, _pw_y, _pw_w, _pw_h);
418 if (epd2.hasFastPartialUpdate)
419 {
420 epd2.writeImageAgain(_buffer + offset, _pw_x, _pw_y, _pw_w, _pw_h);
421 //epd2.refresh(_pw_x, _pw_y, _pw_w, _pw_h); // not needed
422 }
423 }
424 else // full update
425 {
426 epd2.writeImageForFullRefresh(_buffer, 0, 0, WIDTH, HEIGHT);
427 epd2.refresh(false);
428 if (epd2.hasFastPartialUpdate)
429 {
430 epd2.writeImageAgain(_buffer, 0, 0, WIDTH, HEIGHT);
431 //epd2.refresh(true); // not needed
432 epd2.powerOff();
433 }
434 }
435 return;
436 }
437 if (_using_partial_mode)
438 {
439 for (uint16_t phase = 1; phase <= 2; phase++)
440 {
441 for (_current_page = 0; _current_page < _pages; _current_page++)
442 {
443 uint16_t page_ys = _current_page * _page_height;
444 uint16_t page_ye = _current_page < (_pages - 1) ? page_ys + _page_height : HEIGHT;
445 uint16_t dest_ys = _pw_y + page_ys; // transposed
446 uint16_t dest_ye = gx_uint16_min(_pw_y + _pw_h, _pw_y + page_ye);
447 if (dest_ye > dest_ys)
448 {
450 drawCallback(pv);
451 uint32_t offset = _reverse ? (_page_height - (dest_ye - dest_ys)) * _pw_w / 8 : 0;
452 if (phase == 1) epd2.writeImage(_buffer + offset, _pw_x, dest_ys, _pw_w, dest_ye - dest_ys);
453 else epd2.writeImageAgain(_buffer + offset, _pw_x, dest_ys, _pw_w, dest_ye - dest_ys);
454 }
455 }
456 epd2.refresh(_pw_x, _pw_y, _pw_w, _pw_h);
457 if (!epd2.hasFastPartialUpdate) break;
458 // else make both controller buffers have equal content
459 }
460 }
461 else // full update
462 {
463 for (_current_page = 0; _current_page < _pages; _current_page++)
464 {
465 uint16_t page_ys = _current_page * _page_height;
467 drawCallback(pv);
468 epd2.writeImageForFullRefresh(_buffer, 0, page_ys, WIDTH, gx_uint16_min(_page_height, HEIGHT - page_ys));
469 }
470 epd2.refresh(false); // full update after first phase
471 if (epd2.hasFastPartialUpdate)
472 {
473 // make both controller buffers have equal content
474 for (_current_page = 0; _current_page < _pages; _current_page++)
475 {
476 uint16_t page_ys = _current_page * _page_height;
478 drawCallback(pv);
479 epd2.writeImageAgain(_buffer, 0, page_ys, WIDTH, gx_uint16_min(_page_height, HEIGHT - page_ys));
480 }
481 //epd2.refresh(true); // partial update after second phase // not needed
482 }
483 epd2.powerOff();
484 }
485 _current_page = 0;
486 }
#define GxEPD_WHITE
Definition GxEPD2.h:20
void fillScreen(uint16_t color)
Definition GxEPD2_BW.h:229

◆ drawPixel()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::drawPixel ( int16_t x,
int16_t y,
uint16_t color )
inline

Definition at line 117 of file GxEPD2_BW.h.

118 {
119 if ((x < 0) || (x >= width()) || (y < 0) || (y >= height())) return;
120 if (_mirror) x = width() - x - 1;
121 // check rotation, move pixel around if necessary
122 switch (getRotation())
123 {
124 case 1:
125 _swap_(x, y);
126 x = WIDTH - x - 1;
127 break;
128 case 2:
129 x = WIDTH - x - 1;
130 y = HEIGHT - y - 1;
131 break;
132 case 3:
133 _swap_(x, y);
134 y = HEIGHT - y - 1;
135 break;
136 }
137 // transpose partial window to 0,0
138 x -= _pw_x;
139 y -= _pw_y;
140 // clip to (partial) window
141 if ((x < 0) || (x >= int16_t(_pw_w)) || (y < 0) || (y >= int16_t(_pw_h))) return;
142 // adjust for current page
143 y -= _current_page * _page_height;
144 if (_reverse) y = _page_height - y - 1;
145 // check if in current page
146 if ((y < 0) || (y >= int16_t(_page_height))) return;
147 uint16_t i = x / 4 + y * (_pw_w / 4);
148 _buffer[i] = (_buffer[i] & (0xFF ^ (3 << 2 * (3 - x % 4))));
149 if (color > 0)
150 {
151 uint8_t brb = 0x03;
152 if (color != GxEPD_WHITE)
153 {
154 uint32_t brightness = (uint32_t(color & 0xF800) + uint32_t((color & 0x07E0) << 5) + uint32_t((color & 0x001F) << 11));
155 brb = uint8_t((brightness - 1) / 0xC000ul); // GxEPD_LIGHTGREY is one too high
156 }
157 _buffer[i] = (_buffer[i] | (brb << 2 * (3 - x % 4)));
158 }
159 }

◆ fillScreen()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::fillScreen ( uint16_t color)
inline

Definition at line 229 of file GxEPD2_BW.h.

230 {
231 uint32_t brightness = (uint32_t(color & 0xF800) + uint32_t((color & 0x07E0) << 5) + uint32_t((color & 0x001F) << 11));
232 uint8_t brb = uint8_t((brightness - 1) / 0xC000ul); // GxEPD_LIGHTGREY is one too high
233 uint8_t data = brb * 0b01010101;
234 for (uint16_t x = 0; x < sizeof(_buffer); x++)
235 {
236 _buffer[x] = data;
237 }
238 }

◆ firstPage()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::firstPage ( )
inline

Definition at line 303 of file GxEPD2_BW.h.

304 {
306 _current_page = 0;
307 _second_phase = false;
308 }

◆ hibernate()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::hibernate ( )
inline

Definition at line 698 of file GxEPD2_BW.h.

699 {
700 epd2.hibernate();
701 }

◆ init() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::init ( uint32_t serial_diag_bitrate,
bool initial,
uint16_t reset_duration,
bool pulldown_rst_mode,
SPIClass & spi,
SPISettings spi_settings )
inline

Definition at line 220 of file GxEPD2_BW.h.

221 {
222 epd2.selectSPI(spi, spi_settings);
223 epd2.init(serial_diag_bitrate, initial, reset_duration, pulldown_rst_mode);
224 _using_partial_mode = false;
225 _current_page = 0;
227 }

◆ init() [2/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::init ( uint32_t serial_diag_bitrate,
bool initial,
uint16_t reset_duration = 10,
bool pulldown_rst_mode = false )
inline

Definition at line 209 of file GxEPD2_BW.h.

210 {
211 epd2.init(serial_diag_bitrate, initial, reset_duration, pulldown_rst_mode);
212 _using_partial_mode = false;
213 _current_page = 0;
215 }

◆ init() [3/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::init ( uint32_t serial_diag_bitrate = 0)
inline

Definition at line 195 of file GxEPD2_BW.h.

196 {
197 epd2.init(serial_diag_bitrate);
198 _using_partial_mode = false;
199 _current_page = 0;
201 }

◆ mirror()

template<typename GxEPD2_Type , const uint16_t page_height>
bool GxEPD2_BW< GxEPD2_Type, page_height >::mirror ( bool m)
inline

Definition at line 111 of file GxEPD2_BW.h.

112 {
113 _swap_ (_mirror, m);
114 return m;
115 }

◆ nextPage()

template<typename GxEPD2_Type , const uint16_t page_height>
bool GxEPD2_BW< GxEPD2_Type, page_height >::nextPage ( )
inline

Definition at line 310 of file GxEPD2_BW.h.

311 {
312 if (1 == _pages)
313 {
314 if (_using_partial_mode)
315 {
316 uint32_t offset = _reverse ? (HEIGHT - _pw_h) * _pw_w / 8 : 0;
317 epd2.writeImage(_buffer + offset, _pw_x, _pw_y, _pw_w, _pw_h);
318 epd2.refresh(_pw_x, _pw_y, _pw_w, _pw_h);
319 if (epd2.hasFastPartialUpdate)
320 {
321 epd2.writeImageAgain(_buffer + offset, _pw_x, _pw_y, _pw_w, _pw_h);
322 //epd2.refresh(_pw_x, _pw_y, _pw_w, _pw_h); // not needed
323 }
324 }
325 else // full update
326 {
327 epd2.writeImageForFullRefresh(_buffer, 0, 0, WIDTH, HEIGHT);
328 epd2.refresh(false);
329 if (epd2.hasFastPartialUpdate)
330 {
331 epd2.writeImageAgain(_buffer, 0, 0, WIDTH, HEIGHT);
332 //epd2.refresh(true); // not needed
333 }
334 epd2.powerOff();
335 }
336 return false;
337 }
338 uint16_t page_ys = _current_page * _page_height;
339 if (_using_partial_mode)
340 {
341 //Serial.print(" nextPage("); Serial.print(_pw_x); Serial.print(", "); Serial.print(_pw_y); Serial.print(", ");
342 //Serial.print(_pw_w); Serial.print(", "); Serial.print(_pw_h); Serial.print(") P"); Serial.println(_current_page);
343 uint16_t page_ye = _current_page < int16_t(_pages - 1) ? page_ys + _page_height : HEIGHT;
344 uint16_t dest_ys = _pw_y + page_ys; // transposed
345 uint16_t dest_ye = gx_uint16_min(_pw_y + _pw_h, _pw_y + page_ye);
346 if (dest_ye > dest_ys)
347 {
348 //Serial.print("writeImage("); Serial.print(_pw_x); Serial.print(", "); Serial.print(dest_ys); Serial.print(", ");
349 //Serial.print(_pw_w); Serial.print(", "); Serial.print(dest_ye - dest_ys); Serial.println(")");
350 uint32_t offset = _reverse ? (_page_height - (dest_ye - dest_ys)) * _pw_w / 8 : 0;
351 if (!_second_phase) epd2.writeImage(_buffer + offset, _pw_x, dest_ys, _pw_w, dest_ye - dest_ys);
352 else epd2.writeImageAgain(_buffer + offset, _pw_x, dest_ys, _pw_w, dest_ye - dest_ys);
353 }
354 else
355 {
356 //Serial.print("writeImage("); Serial.print(_pw_x); Serial.print(", "); Serial.print(dest_ys); Serial.print(", ");
357 //Serial.print(_pw_w); Serial.print(", "); Serial.print(dest_ye - dest_ys); Serial.print(") skipped ");
358 //Serial.print(dest_ys); Serial.print(".."); Serial.println(dest_ye);
359 }
360 _current_page++;
361 if (_current_page == int16_t(_pages))
362 {
363 _current_page = 0;
364 if (!_second_phase)
365 {
366 epd2.refresh(_pw_x, _pw_y, _pw_w, _pw_h);
367 if (epd2.hasFastPartialUpdate)
368 {
369 _second_phase = true;
371 return true;
372 }
373 }
374 return false;
375 }
377 return true;
378 }
379 else // full update
380 {
381 if (!_second_phase) epd2.writeImageForFullRefresh(_buffer, 0, page_ys, WIDTH, gx_uint16_min(_page_height, HEIGHT - page_ys));
382 else epd2.writeImageAgain(_buffer, 0, page_ys, WIDTH, gx_uint16_min(_page_height, HEIGHT - page_ys));
383 _current_page++;
384 if (_current_page == int16_t(_pages))
385 {
386 _current_page = 0;
387 if (epd2.hasFastPartialUpdate)
388 {
389 if (!_second_phase)
390 {
391 epd2.refresh(false); // full update after first phase
392 _second_phase = true;
394 return true;
395 }
396 //else epd2.refresh(true); // partial update after second phase
397 } else epd2.refresh(false); // full update after only phase
398 epd2.powerOff();
399 return false;
400 }
402 return true;
403 }
404 }

◆ pageHeight()

template<typename GxEPD2_Type , const uint16_t page_height>
uint16_t GxEPD2_BW< GxEPD2_Type, page_height >::pageHeight ( )
inline

Definition at line 106 of file GxEPD2_BW.h.

107 {
108 return _page_height;
109 }

◆ pages()

template<typename GxEPD2_Type , const uint16_t page_height>
uint16_t GxEPD2_BW< GxEPD2_Type, page_height >::pages ( )
inline

Definition at line 101 of file GxEPD2_BW.h.

102 {
103 return _pages;
104 }

◆ powerOff()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::powerOff ( )
inline

Definition at line 693 of file GxEPD2_BW.h.

694 {
695 epd2.powerOff();
696 }

◆ refresh() [1/2]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::refresh ( bool partial_update_mode = false)
inline

Definition at line 683 of file GxEPD2_BW.h.

684 {
685 epd2.refresh(partial_update_mode);
686 if (!partial_update_mode) epd2.powerOff();
687 }

◆ refresh() [2/2]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::refresh ( int16_t x,
int16_t y,
int16_t w,
int16_t h )
inline

Definition at line 688 of file GxEPD2_BW.h.

689 {
690 epd2.refresh(x, y, w, h);
691 }

◆ setFullWindow()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::setFullWindow ( )
inline

Definition at line 275 of file GxEPD2_BW.h.

276 {
277 _using_partial_mode = false;
278 _pw_x = 0;
279 _pw_y = 0;
280 _pw_w = WIDTH;
281 _pw_h = HEIGHT;
282 }

◆ setPartialWindow()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::setPartialWindow ( uint16_t x,
uint16_t y,
uint16_t w,
uint16_t h )
inline

Definition at line 289 of file GxEPD2_BW.h.

290 {
291 _pw_x = gx_uint16_min(x, width());
292 _pw_y = gx_uint16_min(y, height());
293 _pw_w = gx_uint16_min(w, width() - _pw_x);
294 _pw_h = gx_uint16_min(h, height() - _pw_y);
295 _rotate(_pw_x, _pw_y, _pw_w, _pw_h);
296 _using_partial_mode = true;
297 // make _pw_x, _pw_w multiple of 8
298 _pw_w += _pw_x % 8;
299 if (_pw_w % 8 > 0) _pw_w += 8 - _pw_w % 8;
300 _pw_x -= _pw_x % 8;
301 }

◆ writeImage() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::writeImage ( const uint8_t * black,
const uint8_t * color,
int16_t x,
int16_t y,
int16_t w,
int16_t h )
inline

Definition at line 631 of file GxEPD2_BW.h.

632 {
633 epd2.writeImage(black, color, x, y, w, h, false, false, false);
634 }

◆ writeImage() [2/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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 )
inline

Definition at line 627 of file GxEPD2_BW.h.

628 {
629 epd2.writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
630 }

◆ writeImage() [3/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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 )
inline

Definition at line 618 of file GxEPD2_BW.h.

619 {
620 epd2.writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
621 }

◆ writeImagePart() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::writeImagePart ( const uint8_t * black,
const uint8_t * color,
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 )
inline

Definition at line 640 of file GxEPD2_BW.h.

642 {
643 epd2.writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, false, false, false);
644 }

◆ writeImagePart() [2/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::writeImagePart ( const uint8_t * black,
const uint8_t * color,
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,
bool mirror_y,
bool pgm )
inline

Definition at line 635 of file GxEPD2_BW.h.

637 {
638 epd2.writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
639 }

◆ writeImagePart() [3/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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 )
inline

Definition at line 622 of file GxEPD2_BW.h.

624 {
625 epd2.writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
626 }

◆ writeNative()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::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 )
inline

Definition at line 646 of file GxEPD2_BW.h.

647 {
648 epd2.writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
649 }

◆ writeScreenBuffer()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_BW< GxEPD2_Type, page_height >::writeScreenBuffer ( uint8_t value = 0xFF)
inline

Definition at line 613 of file GxEPD2_BW.h.

614 {
615 epd2.writeScreenBuffer(value);
616 }

Member Data Documentation

◆ epd2

template<typename GxEPD2_Type , const uint16_t page_height>
GxEPD2_Type GxEPD2_BW< GxEPD2_Type, page_height >::epd2

Definition at line 85 of file GxEPD2_BW.h.


The documentation for this class was generated from the following file: