@@ -44,14 +44,17 @@ void GxEPDDisplay::turnOff() {
4444void GxEPDDisplay::clear () {
4545 display.fillScreen (GxEPD_WHITE);
4646 display.setTextColor (GxEPD_BLACK);
47+ display_crc.reset ();
4748}
4849
4950void GxEPDDisplay::startFrame (Color bkg) {
5051 display.fillScreen (GxEPD_WHITE);
5152 display.setTextColor (_curr_color = GxEPD_BLACK);
53+ display_crc.reset ();
5254}
5355
5456void GxEPDDisplay::setTextSize (int sz) {
57+ display_crc.update <int >(sz);
5558 switch (sz) {
5659 case 1 : // Small
5760 display.setFont (&FreeSans9pt7b);
@@ -69,6 +72,7 @@ void GxEPDDisplay::setTextSize(int sz) {
6972}
7073
7174void GxEPDDisplay::setColor (Color c) {
75+ display_crc.update <Color> (c);
7276 // colours need to be inverted for epaper displays
7377 if (c == DARK) {
7478 display.setTextColor (_curr_color = GxEPD_WHITE);
@@ -78,22 +82,38 @@ void GxEPDDisplay::setColor(Color c) {
7882}
7983
8084void GxEPDDisplay::setCursor (int x, int y) {
85+ display_crc.update <int >(x);
86+ display_crc.update <int >(y);
8187 display.setCursor (x*SCALE_X, (y+10 )*SCALE_Y);
8288}
8389
8490void GxEPDDisplay::print (const char * str) {
91+ display_crc.update <char >(str, strlen (str));
8592 display.print (str);
8693}
8794
8895void GxEPDDisplay::fillRect (int x, int y, int w, int h) {
96+ display_crc.update <int >(x);
97+ display_crc.update <int >(y);
98+ display_crc.update <int >(w);
99+ display_crc.update <int >(h);
89100 display.fillRect (x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _curr_color);
90101}
91102
92103void GxEPDDisplay::drawRect (int x, int y, int w, int h) {
104+ display_crc.update <int >(x);
105+ display_crc.update <int >(y);
106+ display_crc.update <int >(w);
107+ display_crc.update <int >(h);
93108 display.drawRect (x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _curr_color);
94109}
95110
96111void GxEPDDisplay::drawXbm (int x, int y, const uint8_t * bits, int w, int h) {
112+ display_crc.update <int >(x);
113+ display_crc.update <int >(y);
114+ display_crc.update <int >(w);
115+ display_crc.update <int >(h);
116+ display_crc.update <uint8_t >(bits, w * h / 8 );
97117 // Calculate the base position in display coordinates
98118 uint16_t startX = x * SCALE_X;
99119 uint16_t startY = y * SCALE_Y;
@@ -137,5 +157,9 @@ uint16_t GxEPDDisplay::getTextWidth(const char* str) {
137157}
138158
139159void GxEPDDisplay::endFrame () {
140- display.display (true );
160+ uint32_t crc = display_crc.finalize ();
161+ if (crc != last_display_crc_value) {
162+ display.display (true );
163+ last_display_crc_value = crc;
164+ }
141165}
0 commit comments