Paperd.Ink Library 0.0.5
Library for interacting with Paperd.Ink devices.
Loading...
Searching...
No Matches
GxEPD2_420 Class Reference

#include <GxEPD2_420.h>

Inheritance diagram for GxEPD2_420:
GxEPD2_EPD

Public Member Functions

 GxEPD2_420 (int16_t cs, int16_t dc, int16_t rst, int16_t busy)
 
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 writeImage_4G (const uint8_t bitmap[], uint8_t bpp, 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 writeImagePart_4G (const uint8_t bitmap[], uint8_t bpp, 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=false, bool mirror_y=false, bool pgm=false)
 
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=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 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 drawImage_4G (const uint8_t bitmap[], uint8_t bpp, 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 drawImagePart_4G (const uint8_t bitmap[], uint8_t bpp, 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=false, bool mirror_y=false, bool pgm=false)
 
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=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 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 Member Functions inherited from GxEPD2_EPD
 GxEPD2_EPD (int16_t cs, int16_t dc, int16_t rst, int16_t busy, int16_t busy_level, uint32_t busy_timeout, uint16_t w, uint16_t h, GxEPD2::Panel p, bool c, bool pu, bool fpu)
 
virtual void init (uint32_t serial_diag_bitrate=0)
 
virtual void init (uint32_t serial_diag_bitrate, bool initial, uint16_t reset_duration=10, bool pulldown_rst_mode=false)
 
virtual void writeImageForFullRefresh (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)
 
virtual void writeScreenBufferAgain (uint8_t value=0xFF)
 
virtual void writeImageAgain (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)
 
virtual void writeImagePartAgain (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)
 
virtual void setPaged ()
 
void setBusyCallback (void(*busyCallback)(const void *), const void *busy_callback_parameter=0)
 
void selectSPI (SPIClass &spi, SPISettings spi_settings)
 

Static Public Attributes

static const uint16_t WIDTH = 400
 
static const uint16_t HEIGHT = 300
 
static const GxEPD2::Panel panel = GxEPD2::GDEW042T2
 
static const bool hasColor = false
 
static const bool hasPartialUpdate = true
 
static const bool usePartialUpdateWindow = false
 
static const bool hasFastPartialUpdate = true
 
static const uint16_t power_on_time = 40
 
static const uint16_t power_off_time = 20
 
static const uint16_t full_refresh_time = 1600
 
static const uint16_t partial_refresh_time = 600
 

Additional Inherited Members

- Static Public Member Functions inherited from GxEPD2_EPD
static uint16_t gx_uint16_min (uint16_t a, uint16_t b)
 
static uint16_t gx_uint16_max (uint16_t a, uint16_t b)
 
- Public Attributes inherited from GxEPD2_EPD
const uint16_t WIDTH
 
const uint16_t HEIGHT
 
const GxEPD2::Panel panel
 
const bool hasColor
 
const bool hasPartialUpdate
 
const bool hasFastPartialUpdate
 
- Protected Member Functions inherited from GxEPD2_EPD
void _reset ()
 
void _waitWhileBusy (const char *comment=0, uint16_t busy_time=5000)
 
void _writeCommand (uint8_t c)
 
void _writeData (uint8_t d)
 
void _writeData (const uint8_t *data, uint16_t n)
 
void _writeDataPGM (const uint8_t *data, uint16_t n, int16_t fill_with_zeroes=0)
 
void _writeDataPGM_sCS (const uint8_t *data, uint16_t n, int16_t fill_with_zeroes=0)
 
void _writeCommandData (const uint8_t *pCommandData, uint8_t datalen)
 
void _writeCommandDataPGM (const uint8_t *pCommandData, uint8_t datalen)
 
void _startTransfer ()
 
void _transfer (uint8_t value)
 
void _endTransfer ()
 
- Protected Attributes inherited from GxEPD2_EPD
int16_t _cs
 
int16_t _dc
 
int16_t _rst
 
int16_t _busy
 
int16_t _busy_level
 
uint32_t _busy_timeout
 
bool _diag_enabled
 
bool _pulldown_rst_mode
 
SPIClass * _pSPIx
 
SPISettings _spi_settings
 
bool _initial_write
 
bool _initial_refresh
 
bool _power_is_on
 
bool _using_partial_mode
 
bool _hibernating
 
uint16_t _reset_duration
 
void(* _busy_callback )(const void *)
 
const void * _busy_callback_parameter
 

Detailed Description

Definition at line 20 of file GxEPD2_420.h.

Constructor & Destructor Documentation

◆ GxEPD2_420()

GxEPD2_420::GxEPD2_420 ( int16_t cs,
int16_t dc,
int16_t rst,
int16_t busy )

Definition at line 15 of file GxEPD2_420.cpp.

15 :
16 GxEPD2_EPD(cs, dc, rst, busy, LOW, 10000000, WIDTH, HEIGHT, panel, hasColor, hasPartialUpdate, hasFastPartialUpdate)
17{
18 _refresh_mode = full_refresh;
19}
static const bool hasColor
Definition GxEPD2_420.h:27
static const GxEPD2::Panel panel
Definition GxEPD2_420.h:26
static const bool hasPartialUpdate
Definition GxEPD2_420.h:28
static const uint16_t WIDTH
Definition GxEPD2_420.h:24
static const bool hasFastPartialUpdate
Definition GxEPD2_420.h:30
static const uint16_t HEIGHT
Definition GxEPD2_420.h:25
GxEPD2_EPD(int16_t cs, int16_t dc, int16_t rst, int16_t busy, int16_t busy_level, uint32_t busy_timeout, uint16_t w, uint16_t h, GxEPD2::Panel p, bool c, bool pu, bool fpu)

Member Function Documentation

◆ clearScreen()

void GxEPD2_420::clearScreen ( uint8_t value = 0xFF)
virtual

Implements GxEPD2_EPD.

Definition at line 21 of file GxEPD2_420.cpp.

22{
23 writeScreenBuffer(value);
24 refresh(true);
25 if (_refresh_mode != grey_refresh) writeScreenBuffer(value);
26}
void writeScreenBuffer(uint8_t value=0xFF)
void refresh(bool partial_update_mode=false)

◆ drawImage() [1/2]

void GxEPD2_420::drawImage ( const uint8_t * black,
const uint8_t * color,
int16_t x,
int16_t y,
int16_t w,
int16_t h,
bool invert = false,
bool mirror_y = false,
bool pgm = false )

Definition at line 418 of file GxEPD2_420.cpp.

419{
420 writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
421 refresh(x, y, w, h);
422 writeImage(black, color, x, y, w, h, invert, mirror_y, pgm);
423}
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)

◆ drawImage() [2/2]

void GxEPD2_420::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 )

Definition at line 403 of file GxEPD2_420.cpp.

404{
405 writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
406 refresh(x, y, w, h);
407 writeImage(bitmap, x, y, w, h, invert, mirror_y, pgm);
408}

◆ drawImage_4G()

void GxEPD2_420::drawImage_4G ( const uint8_t bitmap[],
uint8_t bpp,
int16_t x,
int16_t y,
int16_t w,
int16_t h,
bool invert = false,
bool mirror_y = false,
bool pgm = false )

◆ drawImagePart() [1/2]

void GxEPD2_420::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 = false,
bool mirror_y = false,
bool pgm = false )

Definition at line 425 of file GxEPD2_420.cpp.

427{
428 writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
429 refresh(x, y, w, h);
430 writeImagePart(black, color, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
431}
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)

◆ drawImagePart() [2/2]

void GxEPD2_420::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 )

Definition at line 410 of file GxEPD2_420.cpp.

412{
413 writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
414 refresh(x, y, w, h);
415 writeImagePart(bitmap, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
416}

◆ drawImagePart_4G()

void GxEPD2_420::drawImagePart_4G ( const uint8_t bitmap[],
uint8_t bpp,
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 )

◆ drawNative()

void GxEPD2_420::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 )

Definition at line 433 of file GxEPD2_420.cpp.

434{
435 writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
436 refresh(x, y, w, h);
437 writeNative(data1, data2, x, y, w, h, invert, mirror_y, pgm);
438}
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)

◆ hibernate()

void GxEPD2_420::hibernate ( )
virtual

Implements GxEPD2_EPD.

Definition at line 482 of file GxEPD2_420.cpp.

483{
484 _PowerOff();
485 if (_rst >= 0)
486 {
487 _writeCommand(0x07); // deep sleep
488 _writeData(0xA5); // check code
489 _hibernating = true;
490 }
491}
void _writeCommand(uint8_t c)
void _writeData(uint8_t d)
int16_t _rst
Definition GxEPD2_EPD.h:112
bool _hibernating
Definition GxEPD2_EPD.h:118

◆ powerOff()

void GxEPD2_420::powerOff ( void )
virtual

Implements GxEPD2_EPD.

Definition at line 477 of file GxEPD2_420.cpp.

478{
479 _PowerOff();
480}

◆ refresh() [1/2]

void GxEPD2_420::refresh ( bool partial_update_mode = false)
virtual

Implements GxEPD2_EPD.

Definition at line 440 of file GxEPD2_420.cpp.

441{
442 if (partial_update_mode) refresh(0, 0, WIDTH, HEIGHT);
443 else
444 {
445 if (_refresh_mode == forced_full_refresh) _refresh_mode = full_refresh;
446 if (_refresh_mode == fast_refresh) _Init_Full();
447 if (_refresh_mode == grey_refresh) _Update_4G();
448 else _Update_Full();
449 _initial_refresh = false; // initial full update done
450 }
451}
bool _initial_refresh
Definition GxEPD2_EPD.h:117

◆ refresh() [2/2]

void GxEPD2_420::refresh ( int16_t x,
int16_t y,
int16_t w,
int16_t h )
virtual

Implements GxEPD2_EPD.

Definition at line 453 of file GxEPD2_420.cpp.

454{
455 if (_initial_refresh) return refresh(false); // initial update needs be full update
456 if (_refresh_mode == forced_full_refresh) return refresh(false);
457 // intersection with screen
458 int16_t w1 = x < 0 ? w + x : w; // reduce
459 int16_t h1 = y < 0 ? h + y : h; // reduce
460 int16_t x1 = x < 0 ? 0 : x; // limit
461 int16_t y1 = y < 0 ? 0 : y; // limit
462 w1 = x1 + w1 < int16_t(WIDTH) ? w1 : int16_t(WIDTH) - x1; // limit
463 h1 = y1 + h1 < int16_t(HEIGHT) ? h1 : int16_t(HEIGHT) - y1; // limit
464 if ((w1 <= 0) || (h1 <= 0)) return;
465 // make x1, w1 multiple of 8
466 w1 += x1 % 8;
467 if (w1 % 8 > 0) w1 += 8 - w1 % 8;
468 x1 -= x1 % 8;
469 if (_refresh_mode == full_refresh) _Init_Part();
470 if (usePartialUpdateWindow) _writeCommand(0x91); // partial in
471 _setPartialRamArea(x1, y1, w1, h1);
472 if (_refresh_mode == grey_refresh) _Update_4G();
473 else _Update_Part();
474 if (usePartialUpdateWindow) _writeCommand(0x92); // partial out
475}
static const bool usePartialUpdateWindow
Definition GxEPD2_420.h:29

◆ writeImage() [1/2]

void GxEPD2_420::writeImage ( const uint8_t * black,
const uint8_t * color,
int16_t x,
int16_t y,
int16_t w,
int16_t h,
bool invert = false,
bool mirror_y = false,
bool pgm = false )

Definition at line 378 of file GxEPD2_420.cpp.

379{
380 if (black)
381 {
382 writeImage(black, x, y, w, h, invert, mirror_y, pgm);
383 }
384}

◆ writeImage() [2/2]

void GxEPD2_420::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 )
virtual

Implements GxEPD2_EPD.

Definition at line 51 of file GxEPD2_420.cpp.

52{
53 writeImage_4G(bitmap, GxEPD_BPP, x, y, w, h, invert, mirror_y, pgm);
54
55// if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
56// delay(1); // yield() to avoid WDT on ESP8266 and ESP32
57// int16_t wb = (w + 7) / 8; // width bytes, bitmaps are padded
58// x -= x % 8; // byte boundary
59// w = wb * 8; // byte boundary
60// int16_t x1 = x < 0 ? 0 : x; // limit
61// int16_t y1 = y < 0 ? 0 : y; // limit
62// int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
63// int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
64// int16_t dx = x1 - x;
65// int16_t dy = y1 - y;
66// w1 -= dx;
67// h1 -= dy;
68// if ((w1 <= 0) || (h1 <= 0)) return;
69// if (_refresh_mode == grey_refresh) _Force_Init_Full();
70// else if (_refresh_mode == full_refresh) _Init_Part();
71// //uint32_t start = micros();
72// _writeCommand(0x91); // partial in
73// _setPartialRamArea(x1, y1, w1, h1);
74// _writeCommand(0x13);
75// _startTransfer();
76// for (int16_t i = 0; i < h1; i++)
77// {
78// for (int16_t j = 0; j < w1 / 8; j++)
79// {
80// uint8_t data;
81// // use wb, h of bitmap for index!
82// int16_t idx = mirror_y ? j + dx / 8 + ((h - 1 - (i + dy))) * wb : j + dx / 8 + (i + dy) * wb;
83// if (pgm)
84// {
85//#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
86// data = pgm_read_byte(&bitmap[idx]);
87//#else
88// data = bitmap[idx];
89//#endif
90// }
91// else
92// {
93// data = bitmap[idx];
94// }
95// if (invert) data = ~data;
96// _transfer(data);
97// }
98// }
99// _endTransfer();
100// _writeCommand(0x92); // partial out
101// //Serial.print("GxEPD2_420::writeImage took "); Serial.println(micros() - start);
102// delay(1); // yield() to avoid WDT on ESP8266 and ESP32
103}
#define GxEPD_BPP
Definition GxEPD2_420.h:18
void writeImage_4G(const uint8_t bitmap[], uint8_t bpp, int16_t x, int16_t y, int16_t w, int16_t h, bool invert=false, bool mirror_y=false, bool pgm=false)

◆ writeImage_4G()

void GxEPD2_420::writeImage_4G ( const uint8_t bitmap[],
uint8_t bpp,
int16_t x,
int16_t y,
int16_t w,
int16_t h,
bool invert = false,
bool mirror_y = false,
bool pgm = false )

Definition at line 105 of file GxEPD2_420.cpp.

106{
107 uint16_t ppb = (bpp == 2 ? 4 : (bpp == 4 ? 2 : (bpp == 8 ? 1 : 0)));
108 uint8_t mask = (bpp == 2 ? 0xC0 : (bpp == 4 ? 0xF0 : 0xFF));
109 uint8_t grey1 = (bpp == 2 ? 0x80 : 0xA0); // demo limit for 4bpp
110 if (ppb == 0) return;
111 if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
112 delay(1); // yield() to avoid WDT on ESP8266 and ESP32
113 int16_t wbc = (w + 7) / 8; // width bytes on controller
114 x -= x % 8; // byte boundary on controller
115 w = wbc * 8; // byte boundary on controller
116 int16_t wb = (w + ppb - 1) / ppb; // width bytes of bitmap, bitmaps are padded
117 int16_t x1 = x < 0 ? 0 : x; // limit
118 int16_t y1 = y < 0 ? 0 : y; // limit
119 uint16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
120 uint16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
121 int16_t dx = x1 - x;
122 int16_t dy = y1 - y;
123 w1 -= dx;
124 h1 -= dy;
125 if ((w1 <= 0) || (h1 <= 0)) return;
126 _Init_4G();
127 _writeCommand(0x91); // partial in
128 _setPartialRamArea(x1, y1, w1, h1);
129 _writeCommand(0x10);
130 for (uint16_t i = 0; i < h1; i++) // lines
131 {
132 for (uint16_t j = 0; j < w1 / ppb; j += bpp) // out bytes
133 {
134 uint8_t out_byte = 0;
135 for (uint16_t k = 0; k < bpp; k++) // in bytes (bpp per out byte)
136 {
137 uint8_t in_byte;
138 // use wb, h of bitmap for index!
139 uint32_t idx = mirror_y ? j + k + dx / ppb + uint32_t((h - 1 - (i + dy))) * wb : j + k + dx / ppb + uint32_t(i + dy) * wb;
140 if (pgm)
141 {
142#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
143 in_byte = pgm_read_byte(&bitmap[idx]);
144#else
145 in_byte = bitmap[idx];
146#endif
147 }
148 else
149 {
150 in_byte = bitmap[idx];
151 }
152 if (invert) in_byte = ~in_byte;
153 for (uint16_t n = 0; n < ppb; n++) // bits, nibbles (ppb per in byte)
154 {
155 out_byte <<= 1;
156 uint8_t nibble = in_byte & mask;
157 if (nibble == mask) out_byte |= 0x01;//white
158 else if (nibble == 0x00) out_byte |= 0x00; //black
159 else if (nibble >= grey1) out_byte |= 0x01; //gray1
160 else out_byte |= 0x00; //gray2
161 in_byte <<= bpp;
162 }
163 }
164 _writeData(out_byte);
165 }
166 }
167 _writeCommand(0x13);
168 for (uint16_t i = 0; i < h1; i++) // lines
169 {
170 for (uint16_t j = 0; j < w1 / ppb; j += bpp) // out bytes
171 {
172 uint8_t out_byte = 0;
173 for (uint16_t k = 0; k < bpp; k++) // in bytes (bpp per out byte)
174 {
175 uint8_t in_byte;
176 // use wb, h of bitmap for index!
177 uint32_t idx = mirror_y ? j + k + dx / ppb + uint32_t((h - 1 - (i + dy))) * wb : j + k + dx / ppb + uint32_t(i + dy) * wb;
178 if (pgm)
179 {
180#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
181 in_byte = pgm_read_byte(&bitmap[idx]);
182#else
183 in_byte = bitmap[idx];
184#endif
185 }
186 else
187 {
188 in_byte = bitmap[idx];
189 }
190 if (invert) in_byte = ~in_byte;
191 for (uint16_t n = 0; n < ppb; n++) // bits, nibbles (ppb per in byte)
192 {
193 out_byte <<= 1;
194 uint8_t nibble = in_byte & mask;
195 if (nibble == mask) out_byte |= 0x01;//white
196 else if (nibble == 0x00) out_byte |= 0x00; //black
197 else if (nibble >= grey1) out_byte |= 0x00; //gray1
198 else out_byte |= 0x01; //gray2
199 in_byte <<= bpp;
200 }
201 }
202 _writeData(out_byte);
203 }
204 }
205 _writeCommand(0x92); // partial out
206 delay(1); // yield() to avoid WDT on ESP8266 and ESP32
207}
bool _initial_write
Definition GxEPD2_EPD.h:117

◆ writeImagePart() [1/2]

void GxEPD2_420::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 = false,
bool mirror_y = false,
bool pgm = false )

Definition at line 386 of file GxEPD2_420.cpp.

388{
389 if (black)
390 {
391 writeImagePart(black, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
392 }
393}

◆ writeImagePart() [2/2]

void GxEPD2_420::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 )
virtual

Implements GxEPD2_EPD.

Definition at line 209 of file GxEPD2_420.cpp.

211{
212 writeImagePart_4G(bitmap, GxEPD_BPP, x_part, y_part, w_bitmap, h_bitmap, x, y, w, h, invert, mirror_y, pgm);
213// if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
214// delay(1); // yield() to avoid WDT on ESP8266 and ESP32
215// if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
216// if ((x_part < 0) || (x_part >= w_bitmap)) return;
217// if ((y_part < 0) || (y_part >= h_bitmap)) return;
218// int16_t wb_bitmap = (w_bitmap + 7) / 8; // width bytes, bitmaps are padded
219// x_part -= x_part % 8; // byte boundary
220// w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
221// h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
222// x -= x % 8; // byte boundary
223// w = 8 * ((w + 7) / 8); // byte boundary, bitmaps are padded
224// int16_t x1 = x < 0 ? 0 : x; // limit
225// int16_t y1 = y < 0 ? 0 : y; // limit
226// int16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
227// int16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
228// int16_t dx = x1 - x;
229// int16_t dy = y1 - y;
230// w1 -= dx;
231// h1 -= dy;
232// if ((w1 <= 0) || (h1 <= 0)) return;
233// if (_refresh_mode == grey_refresh) _Force_Init_Full();
234// else if (_refresh_mode == full_refresh) _Init_Part();
235// _writeCommand(0x91); // partial in
236// _setPartialRamArea(x1, y1, w1, h1);
237// _writeCommand(0x13);
238// _startTransfer();
239// for (int16_t i = 0; i < h1; i++)
240// {
241// for (int16_t j = 0; j < w1 / 8; j++)
242// {
243// uint8_t data;
244// // use wb_bitmap, h_bitmap of bitmap for index!
245// 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;
246// if (pgm)
247// {
248//#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
249// data = pgm_read_byte(&bitmap[idx]);
250//#else
251// data = bitmap[idx];
252//#endif
253// }
254// else
255// {
256// data = bitmap[idx];
257// }
258// if (invert) data = ~data;
259// _transfer(data);
260// }
261// }
262// _endTransfer();
263// _writeCommand(0x92); // partial out
264// delay(1); // yield() to avoid WDT on ESP8266 and ESP32
265}
void writeImagePart_4G(const uint8_t bitmap[], uint8_t bpp, 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)

◆ writeImagePart_4G()

void GxEPD2_420::writeImagePart_4G ( const uint8_t bitmap[],
uint8_t bpp,
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 )

Definition at line 267 of file GxEPD2_420.cpp.

269{
270 uint16_t ppb = (bpp == 2 ? 4 : (bpp == 4 ? 2 : (bpp == 8 ? 1 : 0)));
271 uint8_t mask = (bpp == 2 ? 0xC0 : (bpp == 4 ? 0xF0 : 0xFF));
272 uint8_t grey1 = (bpp == 2 ? 0x80 : 0xA0); // demo limit for 4bpp
273 if (ppb == 0) return;
274 if (_initial_write) writeScreenBuffer(); // initial full screen buffer clean
275 delay(1); // yield() to avoid WDT on ESP8266 and ESP32
276 if ((w_bitmap < 0) || (h_bitmap < 0) || (w < 0) || (h < 0)) return;
277 if ((x_part < 0) || (x_part >= w_bitmap)) return;
278 if ((y_part < 0) || (y_part >= h_bitmap)) return;
279 int16_t wb_bitmap = (w_bitmap + ppb - 1) / ppb; // width bytes, bitmaps are padded
280 x_part -= x_part % ppb; // byte boundary
281 w = w_bitmap - x_part < w ? w_bitmap - x_part : w; // limit
282 h = h_bitmap - y_part < h ? h_bitmap - y_part : h; // limit
283 int16_t wbc = (w + 7) / 8; // width bytes on controller
284 x -= x % 8; // byte boundary on controller
285 w = wbc * 8; // byte boundary on controller
286 int16_t x1 = x < 0 ? 0 : x; // limit
287 int16_t y1 = y < 0 ? 0 : y; // limit
288 uint16_t w1 = x + w < int16_t(WIDTH) ? w : int16_t(WIDTH) - x; // limit
289 uint16_t h1 = y + h < int16_t(HEIGHT) ? h : int16_t(HEIGHT) - y; // limit
290 int16_t dx = x1 - x;
291 int16_t dy = y1 - y;
292 w1 -= dx;
293 h1 -= dy;
294 if ((w1 <= 0) || (h1 <= 0)) return;
295 _Init_4G();
296 _writeCommand(0x91); // partial in
297 _setPartialRamArea(x1, y1, w1, h1);
298 _writeCommand(0x10);
299 for (uint16_t i = 0; i < h1; i++) // lines
300 {
301 for (uint16_t j = 0; j < w1 / ppb; j += bpp) // out bytes
302 {
303 uint8_t out_byte = 0;
304 for (uint16_t k = 0; k < bpp; k++) // in bytes (bpp per out byte)
305 {
306 uint8_t in_byte;
307 // use wb_bitmap, h_bitmap of bitmap for index!
308 uint32_t idx = mirror_y ? x_part / ppb + j + k + dx / ppb + uint32_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / ppb + j + k + dx / ppb + uint32_t(y_part + i + dy) * wb_bitmap;
309 if (pgm)
310 {
311#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
312 in_byte = pgm_read_byte(&bitmap[idx]);
313#else
314 in_byte = bitmap[idx];
315#endif
316 }
317 else
318 {
319 in_byte = bitmap[idx];
320 }
321 if (invert) in_byte = ~in_byte;
322 for (uint16_t n = 0; n < ppb; n++) // bits, nibbles (ppb per in byte)
323 {
324 out_byte <<= 1;
325 uint8_t nibble = in_byte & mask;
326 if (nibble == mask) out_byte |= 0x01;//white
327 else if (nibble == 0x00) out_byte |= 0x00; //black
328 else if (nibble >= grey1) out_byte |= 0x01; //gray1
329 else out_byte |= 0x00; //gray2
330 in_byte <<= bpp;
331 }
332 }
333 _writeData(out_byte);
334 }
335 }
336 _writeCommand(0x13);
337 for (uint16_t i = 0; i < h1; i++) // lines
338 {
339 for (uint16_t j = 0; j < w1 / ppb; j += bpp) // out bytes
340 {
341 uint8_t out_byte = 0;
342 for (uint16_t k = 0; k < bpp; k++) // in bytes (bpp per out byte)
343 {
344 uint8_t in_byte;
345 // use wb_bitmap, h_bitmap of bitmap for index!
346 uint32_t idx = mirror_y ? x_part / ppb + j + k + dx / ppb + uint32_t((h_bitmap - 1 - (y_part + i + dy))) * wb_bitmap : x_part / ppb + j + k + dx / ppb + uint32_t(y_part + i + dy) * wb_bitmap;
347 if (pgm)
348 {
349#if defined(__AVR) || defined(ESP8266) || defined(ESP32)
350 in_byte = pgm_read_byte(&bitmap[idx]);
351#else
352 in_byte = bitmap[idx];
353#endif
354 }
355 else
356 {
357 in_byte = bitmap[idx];
358 }
359 if (invert) in_byte = ~in_byte;
360 for (uint16_t n = 0; n < ppb; n++) // bits, nibbles (ppb per in byte)
361 {
362 out_byte <<= 1;
363 uint8_t nibble = in_byte & mask;
364 if (nibble == mask) out_byte |= 0x01;//white
365 else if (nibble == 0x00) out_byte |= 0x00; //black
366 else if (nibble >= grey1) out_byte |= 0x00; //gray1
367 else out_byte |= 0x01; //gray2
368 in_byte <<= bpp;
369 }
370 }
371 _writeData(out_byte);
372 }
373 }
374 _writeCommand(0x92); // partial out
375 delay(1); // yield() to avoid WDT on ESP8266 and ESP32
376}

◆ writeNative()

void GxEPD2_420::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 )

Definition at line 395 of file GxEPD2_420.cpp.

396{
397 if (data1)
398 {
399 writeImage(data1, x, y, w, h, invert, mirror_y, pgm);
400 }
401}

◆ writeScreenBuffer()

void GxEPD2_420::writeScreenBuffer ( uint8_t value = 0xFF)
virtual

Implements GxEPD2_EPD.

Definition at line 28 of file GxEPD2_420.cpp.

29{
30 _initial_write = false; // initial full screen buffer clean done
31 if (_refresh_mode == full_refresh) _Init_Part();
32 if (_initial_refresh || (_refresh_mode == grey_refresh))
33 {
34 _writeCommand(0x10); // init old data
36 for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(HEIGHT) / 8; i++)
37 {
38 _transfer(value);
39 }
41 }
42 _writeCommand(0x13);
44 for (uint32_t i = 0; i < uint32_t(WIDTH) * uint32_t(HEIGHT) / 8; i++)
45 {
46 _transfer(value);
47 }
49}
void _endTransfer()
void _startTransfer()
void _transfer(uint8_t value)

Member Data Documentation

◆ full_refresh_time

const uint16_t GxEPD2_420::full_refresh_time = 1600
static

Definition at line 33 of file GxEPD2_420.h.

◆ hasColor

const bool GxEPD2_420::hasColor = false
static

Definition at line 27 of file GxEPD2_420.h.

◆ hasFastPartialUpdate

const bool GxEPD2_420::hasFastPartialUpdate = true
static

Definition at line 30 of file GxEPD2_420.h.

◆ hasPartialUpdate

const bool GxEPD2_420::hasPartialUpdate = true
static

Definition at line 28 of file GxEPD2_420.h.

◆ HEIGHT

const uint16_t GxEPD2_420::HEIGHT = 300
static

Definition at line 25 of file GxEPD2_420.h.

◆ panel

const GxEPD2::Panel GxEPD2_420::panel = GxEPD2::GDEW042T2
static

Definition at line 26 of file GxEPD2_420.h.

◆ partial_refresh_time

const uint16_t GxEPD2_420::partial_refresh_time = 600
static

Definition at line 34 of file GxEPD2_420.h.

◆ power_off_time

const uint16_t GxEPD2_420::power_off_time = 20
static

Definition at line 32 of file GxEPD2_420.h.

◆ power_on_time

const uint16_t GxEPD2_420::power_on_time = 40
static

Definition at line 31 of file GxEPD2_420.h.

◆ usePartialUpdateWindow

const bool GxEPD2_420::usePartialUpdateWindow = false
static

Definition at line 29 of file GxEPD2_420.h.

◆ WIDTH

const uint16_t GxEPD2_420::WIDTH = 400
static

Definition at line 24 of file GxEPD2_420.h.


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