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

#include <GxEPD2_3C.h>

Inheritance diagram for GxEPD2_3C< GxEPD2_Type, page_height >:

Public Member Functions

 GxEPD2_3C (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 init (uint32_t serial_diag_bitrate=0)
 
void init (uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration=20, 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 displayWindowBW (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 ()
 
bool nextPageBW ()
 
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 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_3C< GxEPD2_Type, page_height >

Definition at line 54 of file GxEPD2_3C.h.

Constructor & Destructor Documentation

◆ GxEPD2_3C()

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

Definition at line 61 of file GxEPD2_3C.h.

61 : GxEPD2_GFX_BASE_CLASS(GxEPD2_Type::WIDTH_VISIBLE, GxEPD2_Type::HEIGHT), epd2(epd2_instance)
62#endif
63 {
64 _page_height = page_height;
65 _pages = (HEIGHT / _page_height) + ((HEIGHT % _page_height) > 0);
66 _mirror = false;
67 _using_partial_mode = false;
68 _current_page = 0;
70 }
#define GxEPD2_GFX_BASE_CLASS
Definition GxEPD2_3C.h:29
void setFullWindow()
Definition GxEPD2_3C.h:209
GxEPD2_Type epd2
Definition GxEPD2_3C.h:57

Member Function Documentation

◆ clearScreen()

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

Definition at line 464 of file GxEPD2_3C.h.

465 {
466 epd2.clearScreen(value);
467 }

◆ display()

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

Definition at line 173 of file GxEPD2_3C.h.

174 {
175 epd2.writeImage(_black_buffer, _color_buffer, 0, 0, GxEPD2_Type::WIDTH, _page_height);
176 epd2.refresh(partial_update_mode);
177 if (!partial_update_mode) epd2.powerOff();
178 }

◆ displayWindow()

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

Definition at line 186 of file GxEPD2_3C.h.

187 {
188 x = gx_uint16_min(x, width());
189 y = gx_uint16_min(y, height());
190 w = gx_uint16_min(w, width() - x);
191 h = gx_uint16_min(h, height() - y);
192 _rotate(x, y, w, h);
193 epd2.writeImagePart(_black_buffer, _color_buffer, x, y, GxEPD2_Type::WIDTH, _page_height, x, y, w, h);
194 epd2.refresh(x, y, w, h);
195 }

◆ displayWindowBW()

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

Definition at line 197 of file GxEPD2_3C.h.

198 {
199 x = gx_uint16_min(x, width());
200 y = gx_uint16_min(y, height());
201 w = gx_uint16_min(w, width() - x);
202 h = gx_uint16_min(h, height() - y);
203 _rotate(x, y, w, h);
204 epd2.writeImagePartNew(_black_buffer, x, y, GxEPD2_Type::WIDTH, _page_height, x, y, w, h);
205 epd2.refresh_bw(x, y, w, h);
206 epd2.writeImagePartPrevious(_black_buffer, x, y, GxEPD2_Type::WIDTH, _page_height, x, y, w, h);
207 }

◆ drawImage() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 519 of file GxEPD2_3C.h.

520 {
521 epd2.drawImage(black, color, x, y, w, h, false, false, false);
522 }

◆ drawImage() [2/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 515 of file GxEPD2_3C.h.

516 {
517 epd2.drawImage(black, color, x, y, w, h, invert, mirror_y, pgm);
518 }

◆ drawImage() [3/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 506 of file GxEPD2_3C.h.

507 {
508 epd2.drawImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
509 }

◆ drawImagePart() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 528 of file GxEPD2_3C.h.

530 {
531 epd2.drawImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, false, false, false);
532 }

◆ drawImagePart() [2/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 523 of file GxEPD2_3C.h.

525 {
526 epd2.drawImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
527 }

◆ drawImagePart() [3/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 510 of file GxEPD2_3C.h.

512 {
513 epd2.drawImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
514 }

◆ drawInvertedBitmap()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 437 of file GxEPD2_3C.h.

438 {
439 // taken from Adafruit_GFX.cpp, modified
440 int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
441 uint8_t byte = 0;
442 for (int16_t j = 0; j < h; j++)
443 {
444 for (int16_t i = 0; i < w; i++ )
445 {
446 if (i & 7) byte <<= 1;
447 else
448 {
449#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
450 byte = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
451#else
452 byte = bitmap[j * byteWidth + i / 8];
453#endif
454 }
455 if (!(byte & 0x80))
456 {
457 drawPixel(x + i, y + j, color);
458 }
459 }
460 }
461 }
void drawPixel(int16_t x, int16_t y, uint16_t color)
Definition GxEPD2_3C.h:88

◆ drawNative()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 534 of file GxEPD2_3C.h.

535 {
536 epd2.drawNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
537 }

◆ drawPaged()

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

Definition at line 392 of file GxEPD2_3C.h.

393 {
394 if (_using_partial_mode)
395 {
396 for (_current_page = 0; _current_page < _pages; _current_page++)
397 {
398 uint16_t page_ys = _current_page * _page_height;
399 uint16_t page_ye = _current_page < (_pages - 1) ? page_ys + _page_height : HEIGHT;
400 uint16_t dest_ys = _pw_y + page_ys; // transposed
401 uint16_t dest_ye = gx_uint16_min(_pw_y + _pw_h, _pw_y + page_ye);
402 if (dest_ye > dest_ys)
403 {
405 drawCallback(pv);
406 epd2.writeImage(_black_buffer, _color_buffer, _pw_x, dest_ys, _pw_w, dest_ye - dest_ys);
407 }
408 }
409 epd2.refresh(_pw_x, _pw_y, _pw_w, _pw_h);
410 }
411 else // full update
412 {
413 epd2.setPaged(); // for GxEPD2_154c paged workaround
414 for (_current_page = 0; _current_page < _pages; _current_page++)
415 {
416 uint16_t page_ys = _current_page * _page_height;
418 drawCallback(pv);
419 epd2.writeImage(_black_buffer, _color_buffer, 0, page_ys, GxEPD2_Type::WIDTH, gx_uint16_min(_page_height, HEIGHT - page_ys));
420 }
421 if (epd2.panel == GxEPD2::GDEW0154Z04)
422 { // GxEPD2_154c paged workaround: write color part
423 for (_current_page = 0; _current_page < _pages; _current_page++)
424 {
425 uint16_t page_ys = _current_page * _page_height;
427 drawCallback(pv);
428 epd2.writeImage(_black_buffer, _color_buffer, 0, page_ys, GxEPD2_Type::WIDTH, gx_uint16_min(_page_height, HEIGHT - page_ys));
429 }
430 }
431 epd2.refresh(false); // full update
432 epd2.powerOff();
433 }
434 _current_page = 0;
435 }
#define GxEPD_WHITE
Definition GxEPD2.h:20
void fillScreen(uint16_t color)
Definition GxEPD2_3C.h:158
@ GDEW0154Z04
Definition GxEPD2.h:80

◆ drawPixel()

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

Definition at line 88 of file GxEPD2_3C.h.

89 {
90 if ((x < 0) || (x >= width()) || (y < 0) || (y >= height())) return;
91 if (_mirror) x = width() - x - 1;
92 // check rotation, move pixel around if necessary
93 switch (getRotation())
94 {
95 case 1:
96 _swap_(x, y);
97 x = WIDTH - x - 1;
98 break;
99 case 2:
100 x = WIDTH - x - 1;
101 y = HEIGHT - y - 1;
102 break;
103 case 3:
104 _swap_(x, y);
105 y = HEIGHT - y - 1;
106 break;
107 }
108 // transpose partial window to 0,0
109 x -= _pw_x;
110 y -= _pw_y;
111 // clip to (partial) window
112 if ((x < 0) || (x >= int16_t(_pw_w)) || (y < 0) || (y >= int16_t(_pw_h))) return;
113 // adjust for current page
114 y -= _current_page * _page_height;
115 // check if in current page
116 if ((y < 0) || (y >= int16_t(_page_height))) return;
117 uint16_t i = x / 8 + y * (_pw_w / 8);
118 _black_buffer[i] = (_black_buffer[i] | (1 << (7 - x % 8))); // white
119 _color_buffer[i] = (_color_buffer[i] | (1 << (7 - x % 8)));
120 if (color == GxEPD_WHITE) return;
121 else if (color == GxEPD_BLACK) _black_buffer[i] = (_black_buffer[i] & (0xFF ^ (1 << (7 - x % 8))));
122 else if ((color == GxEPD_RED) || (color == GxEPD_YELLOW)) _color_buffer[i] = (_color_buffer[i] & (0xFF ^ (1 << (7 - x % 8))));
123 }
#define GxEPD_RED
Definition GxEPD2.h:25
#define GxEPD_BLACK
Definition GxEPD2.h:19
#define GxEPD_YELLOW
Definition GxEPD2.h:26

◆ fillScreen()

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

Definition at line 158 of file GxEPD2_3C.h.

159 {
160 uint8_t black = 0xFF;
161 uint8_t red = 0xFF;
162 if (color == GxEPD_WHITE);
163 else if (color == GxEPD_BLACK) black = 0x00;
164 else if ((color == GxEPD_RED) || (color == GxEPD_YELLOW)) red = 0x00;
165 for (uint16_t x = 0; x < sizeof(_black_buffer); x++)
166 {
167 _black_buffer[x] = black;
168 _color_buffer[x] = red;
169 }
170 }

◆ firstPage()

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

Definition at line 238 of file GxEPD2_3C.h.

239 {
241 _current_page = 0;
242 _second_phase = false;
243 epd2.setPaged(); // for GxEPD2_154c paged workaround
244 }

◆ hibernate()

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

Definition at line 553 of file GxEPD2_3C.h.

554 {
555 epd2.hibernate();
556 }

◆ init() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 149 of file GxEPD2_3C.h.

150 {
151 epd2.selectSPI(spi, spi_settings);
152 epd2.init(serial_diag_bitrate, initial, reset_duration, pulldown_rst_mode);
153 _using_partial_mode = false;
154 _current_page = 0;
156 }

◆ init() [2/3]

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

Definition at line 138 of file GxEPD2_3C.h.

139 {
140 epd2.init(serial_diag_bitrate, initial, reset_duration, pulldown_rst_mode);
141 _using_partial_mode = false;
142 _current_page = 0;
144 }

◆ init() [3/3]

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

Definition at line 125 of file GxEPD2_3C.h.

126 {
127 epd2.init(serial_diag_bitrate);
128 _using_partial_mode = false;
129 _current_page = 0;
131 }

◆ mirror()

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

Definition at line 82 of file GxEPD2_3C.h.

83 {
84 _swap_ (_mirror, m);
85 return m;
86 }

◆ nextPage()

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

Definition at line 246 of file GxEPD2_3C.h.

247 {
248 uint16_t page_ys = _current_page * _page_height;
249 if (_using_partial_mode)
250 {
251 //Serial.print(" nextPage("); Serial.print(_pw_x); Serial.print(", "); Serial.print(_pw_y); Serial.print(", ");
252 //Serial.print(_pw_w); Serial.print(", "); Serial.print(_pw_h); Serial.print(") P"); Serial.println(_current_page);
253 uint16_t page_ye = _current_page < int16_t(_pages - 1) ? page_ys + _page_height : HEIGHT;
254 uint16_t dest_ys = _pw_y + page_ys; // transposed
255 uint16_t dest_ye = gx_uint16_min(_pw_y + _pw_h, _pw_y + page_ye);
256 if (dest_ye > dest_ys)
257 {
258 //Serial.print("writeImage("); Serial.print(_pw_x); Serial.print(", "); Serial.print(dest_ys); Serial.print(", ");
259 //Serial.print(_pw_w); Serial.print(", "); Serial.print(dest_ye - dest_ys); Serial.println(")");
260 epd2.writeImage(_black_buffer, _color_buffer, _pw_x, dest_ys, _pw_w, dest_ye - dest_ys);
261 }
262 else
263 {
264 //Serial.print("writeImage("); Serial.print(_pw_x); Serial.print(", "); Serial.print(dest_ys); Serial.print(", ");
265 //Serial.print(_pw_w); Serial.print(", "); Serial.print(dest_ye - dest_ys); Serial.print(") skipped ");
266 //Serial.print(dest_ys); Serial.print(".."); Serial.println(dest_ye);
267 }
268 _current_page++;
269 if (_current_page == int16_t(_pages))
270 {
271 _current_page = 0;
272 if (!_second_phase)
273 {
274 epd2.refresh(_pw_x, _pw_y, _pw_w, _pw_h);
275 if (epd2.hasFastPartialUpdate)
276 {
277 _second_phase = true;
278 return true;
279 }
280 }
281 return false;
282 }
284 return true;
285 }
286 else // full update
287 {
288 epd2.writeImage(_black_buffer, _color_buffer, 0, page_ys, GxEPD2_Type::WIDTH, gx_uint16_min(_page_height, HEIGHT - page_ys));
289 _current_page++;
290 if (_current_page == int16_t(_pages))
291 {
292 _current_page = 0;
293 if ((epd2.panel == GxEPD2::GDEW0154Z04) && (_pages > 1))
294 {
295 if (!_second_phase)
296 {
297 epd2.refresh(false); // full update after first phase
298 _second_phase = true;
300 return true;
301 }
302 else epd2.refresh(true); // partial update after second phase
303 } else epd2.refresh(false); // full update after only phase
304 epd2.powerOff();
305 return false;
306 }
308 return true;
309 }
310 }

◆ nextPageBW()

template<typename GxEPD2_Type , const uint16_t page_height>
bool GxEPD2_3C< GxEPD2_Type, page_height >::nextPageBW ( )
inline

Definition at line 312 of file GxEPD2_3C.h.

313 {
314 if (1 == _pages)
315 {
316 if (_using_partial_mode)
317 {
318 epd2.writeImageNew(_black_buffer, _pw_x, _pw_y, _pw_w, _pw_h);
319 epd2.refresh_bw(_pw_x, _pw_y, _pw_w, _pw_h);
320 epd2.writeImagePrevious(_black_buffer, _pw_x, _pw_y, _pw_w, _pw_h);
321 }
322 else // full update
323 {
324 epd2.writeImage(_black_buffer, 0, 0, GxEPD2_Type::WIDTH, HEIGHT);
325 epd2.refresh(false);
326 epd2.writeImagePrevious(_black_buffer, 0, 0, GxEPD2_Type::WIDTH, HEIGHT);
327 epd2.powerOff();
328 }
329 return false;
330 }
331 uint16_t page_ys = _current_page * _page_height;
332 if (_using_partial_mode)
333 {
334 //Serial.print(" nextPage("); Serial.print(_pw_x); Serial.print(", "); Serial.print(_pw_y); Serial.print(", ");
335 //Serial.print(_pw_w); Serial.print(", "); Serial.print(_pw_h); Serial.print(") P"); Serial.println(_current_page);
336 uint16_t page_ye = _current_page < (_pages - 1) ? page_ys + _page_height : HEIGHT;
337 uint16_t dest_ys = _pw_y + page_ys; // transposed
338 uint16_t dest_ye = gx_uint16_min(_pw_y + _pw_h, _pw_y + page_ye);
339 if (dest_ye > dest_ys)
340 {
341 //Serial.print("writeImage("); Serial.print(_pw_x); Serial.print(", "); Serial.print(dest_ys); Serial.print(", ");
342 //Serial.print(_pw_w); Serial.print(", "); Serial.print(dest_ye - dest_ys); Serial.println(")");
343 if (!_second_phase) epd2.writeImageNew(_black_buffer, _pw_x, dest_ys, _pw_w, dest_ye - dest_ys);
344 else epd2.writeImagePrevious(_black_buffer, _pw_x, dest_ys, _pw_w, dest_ye - dest_ys);
345 }
346 else
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.print(") skipped ");
350 //Serial.print(dest_ys); Serial.print(".."); Serial.println(dest_ye);
351 }
352 _current_page++;
353 if (_current_page == _pages)
354 {
355 _current_page = 0;
356 if (!_second_phase)
357 {
358 epd2.refresh_bw(_pw_x, _pw_y, _pw_w, _pw_h);
359 _second_phase = true;
361 return true;
362 }
363 return false;
364 }
366 return true;
367 }
368 else // full update
369 {
370 if (!_second_phase) epd2.writeImage(_black_buffer, 0, page_ys, GxEPD2_Type::WIDTH, gx_uint16_min(_page_height, HEIGHT - page_ys));
371 else epd2.writeImagePrevious(_black_buffer, 0, page_ys, GxEPD2_Type::WIDTH, gx_uint16_min(_page_height, HEIGHT - page_ys));
372 _current_page++;
373 if (_current_page == _pages)
374 {
375 _current_page = 0;
376 if (!_second_phase)
377 {
378 epd2.refresh(false); // full update after first phase
379 _second_phase = true;
381 return true;
382 }
383 epd2.powerOff();
384 return false;
385 }
387 return true;
388 }
389 }

◆ pageHeight()

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

Definition at line 77 of file GxEPD2_3C.h.

78 {
79 return _page_height;
80 }

◆ pages()

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

Definition at line 72 of file GxEPD2_3C.h.

73 {
74 return _pages;
75 }

◆ powerOff()

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

Definition at line 548 of file GxEPD2_3C.h.

549 {
550 epd2.powerOff();
551 }

◆ refresh() [1/2]

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

Definition at line 538 of file GxEPD2_3C.h.

539 {
540 epd2.refresh(partial_update_mode);
541 if (!partial_update_mode) epd2.powerOff();
542 }

◆ refresh() [2/2]

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

Definition at line 543 of file GxEPD2_3C.h.

544 {
545 epd2.refresh(x, y, w, h);
546 }

◆ setFullWindow()

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

Definition at line 209 of file GxEPD2_3C.h.

210 {
211 _using_partial_mode = false;
212 _pw_x = 0;
213 _pw_y = 0;
214 _pw_w = GxEPD2_Type::WIDTH;
215 _pw_h = HEIGHT;
216 }

◆ setPartialWindow()

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

Definition at line 223 of file GxEPD2_3C.h.

224 {
225 if (!epd2.hasPartialUpdate) return;
226 _pw_x = gx_uint16_min(x, width());
227 _pw_y = gx_uint16_min(y, height());
228 _pw_w = gx_uint16_min(w, width() - _pw_x);
229 _pw_h = gx_uint16_min(h, height() - _pw_y);
230 _rotate(_pw_x, _pw_y, _pw_w, _pw_h);
231 _using_partial_mode = true;
232 // make _pw_x, _pw_w multiple of 8
233 _pw_w += _pw_x % 8;
234 if (_pw_w % 8 > 0) _pw_w += 8 - _pw_w % 8;
235 _pw_x -= _pw_x % 8;
236 }

◆ writeImage() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 486 of file GxEPD2_3C.h.

487 {
488 epd2.writeImage(black, color, x, y, w, h, false, false, false);
489 }

◆ writeImage() [2/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 482 of file GxEPD2_3C.h.

483 {
484 epd2.writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
485 }

◆ writeImage() [3/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 473 of file GxEPD2_3C.h.

474 {
475 epd2.writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
476 }

◆ writeImagePart() [1/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 495 of file GxEPD2_3C.h.

497 {
498 epd2.writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, false, false, false);
499 }

◆ writeImagePart() [2/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 490 of file GxEPD2_3C.h.

492 {
493 epd2.writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
494 }

◆ writeImagePart() [3/3]

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 477 of file GxEPD2_3C.h.

479 {
480 epd2.writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
481 }

◆ writeNative()

template<typename GxEPD2_Type , const uint16_t page_height>
void GxEPD2_3C< 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 501 of file GxEPD2_3C.h.

502 {
503 epd2.writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
504 }

◆ writeScreenBuffer()

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

Definition at line 468 of file GxEPD2_3C.h.

469 {
470 epd2.writeScreenBuffer(value);
471 }

Member Data Documentation

◆ epd2

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

Definition at line 57 of file GxEPD2_3C.h.


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