@@ -33,13 +33,14 @@ void EPaper::begin(uint8_t tc)
3333void EPaper::update ()
3434{
3535 wake ();
36- EPD_SET_WINDOW (0 , 0 , (_width - 1 ), (_height - 1 ));
3736
3837 if (!_grayLevel)
3938 {
4039 #ifdef EPD_HORIZONTAL_MIRROR
40+ EPD_PUSH_OLD_COLORS_FLIP (_width, _height, _img8);
4141 EPD_PUSH_NEW_COLORS_FLIP (_width, _height, _img8);
4242 #else
43+ EPD_PUSH_OLD_COLORS (_width, _height, _img8);
4344 EPD_PUSH_NEW_COLORS (_width, _height, _img8);
4445 #endif
4546 EPD_UPDATE ();
@@ -58,7 +59,46 @@ void EPaper::update()
5859 sleep ();
5960}
6061
62+ #ifdef USE_PARTIAL_EPAPER
63+ void EPaper::updataPartial (uint16_t x, uint16_t y, uint16_t w, uint16_t h)
64+ {
65+ uint16_t x0 = x & ~7 ;
66+ uint16_t x1 = (x + w + 7 ) & ~7 ;
67+ uint16_t w_aligned = x1 - x0;
68+
69+ uint16_t stride = _width >> 3 ;
70+ uint16_t win_bytes_per_row = w_aligned >> 3 ;
71+
72+ const uint8_t * src0 = _img8 + (y * stride) + (x0 >> 3 );
73+
74+ size_t win_size = (size_t )win_bytes_per_row * h;
75+ uint8_t * winbuf = (uint8_t *)malloc (win_size);
76+ if (!winbuf) return ;
77+
78+
79+ for (uint16_t row = 0 ; row < h; row++) {
80+ memcpy (winbuf + row * win_bytes_per_row,
81+ src0 + row * stride,
82+ win_bytes_per_row);
83+ }
84+
85+ if (_sleep) { EPD_WAKEUP_PARTIAL (); _sleep = false ; }
86+
87+ #ifdef EPD_HORIZONTAL_MIRROR
88+ EPD_SET_WINDOW (x0, y, x0 + w_aligned - 1 , y + h - 1 );
89+ EPD_PUSH_NEW_COLORS_PART_FLIP (w_aligned, h, winbuf);
90+ #else
91+ EPD_SET_WINDOW (x0, y, x0 + w_aligned - 1 , y + h - 1 );
92+ EPD_PUSH_NEW_COLORS_PART (w_aligned, h, winbuf);
93+ #endif
94+ EPD_UPDATE ();
6195
96+ free (winbuf);
97+ sleep ();
98+ }
99+
100+
101+ #endif
62102
63103void EPaper::update (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t *data)
64104{
@@ -77,7 +117,6 @@ void EPaper::update(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t *da
77117 pushImage (x, y, w, h / 2 , (uint16_t *)p);
78118 else
79119 pushImage (x, y, w, h , (uint16_t *)p);
80- EPD_SET_WINDOW (x, y, (x + w - 1 ), (y + h - 1 ));
81120#ifdef EPD_HORIZONTAL_MIRROR
82121 EPD_PUSH_NEW_COLORS_FLIP (w, h, p);
83122#else
0 commit comments