|  | @ -1,9 +1,9 @@ | 
			
		
	
		
		
			
				
					|  |  | #include "Display_ePaper.h" |  |  | #include "Display_ePaper.h" | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | #ifdef ESP8266 |  |  | #ifdef ESP8266 | 
			
		
	
		
		
			
				
					
					|  |  |     #include <ESP8266WiFi.h> |  |  | #include <ESP8266WiFi.h> | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | #elif defined(ESP32) |  |  | #elif defined(ESP32) | 
			
		
	
		
		
			
				
					
					|  |  |     #include <WiFi.h> |  |  | #include <WiFi.h> | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | #endif |  |  | #endif | 
			
		
	
		
		
			
				
					|  |  | #include "../../utils/helper.h" |  |  | #include "../../utils/helper.h" | 
			
		
	
		
		
			
				
					|  |  | #include "imagedata.h" |  |  | #include "imagedata.h" | 
			
		
	
	
		
		
			
				
					|  | @ -21,7 +21,6 @@ DisplayEPaper::DisplayEPaper() { | 
			
		
	
		
		
			
				
					|  |  |     mHeadFootPadding = 16; |  |  |     mHeadFootPadding = 16; | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  | //***************************************************************************
 |  |  | //***************************************************************************
 | 
			
		
	
		
		
			
				
					|  |  | void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, uint32_t *utcTs, const char *version) { |  |  | void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, uint32_t *utcTs, const char *version) { | 
			
		
	
		
		
			
				
					|  |  |     mUtcTs = utcTs; |  |  |     mUtcTs = utcTs; | 
			
		
	
	
		
		
			
				
					|  | @ -54,6 +53,9 @@ void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, u | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         headlineIP(); |  |  |         headlineIP(); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         _version = version; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         versionFooter(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         // call the PowerPage to change the PV Power Values
 |  |  |         // call the PowerPage to change the PV Power Values
 | 
			
		
	
		
		
			
				
					|  |  |         actualPowerPaged(0, 0, 0, 0); |  |  |         actualPowerPaged(0, 0, 0, 0); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
	
		
		
			
				
					|  | @ -123,6 +125,26 @@ void DisplayEPaper::lastUpdatePaged() { | 
			
		
	
		
		
			
				
					|  |  |     } while (_display->nextPage()); |  |  |     } while (_display->nextPage()); | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | //***************************************************************************
 |  |  | //***************************************************************************
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | void DisplayEPaper::versionFooter() { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     int16_t tbx, tby; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     uint16_t tbw, tbh; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     _display->setFont(&FreeSans9pt7b); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     _display->setTextColor(GxEPD_WHITE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     _display->setPartialWindow(0, _display->height() - mHeadFootPadding, _display->width(), mHeadFootPadding); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     _display->fillScreen(GxEPD_BLACK); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     do { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         snprintf(_fmtText, sizeof(_fmtText), "Version: %s", _version); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         uint16_t x = ((_display->width() - tbw) / 2) - tbx; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         _display->setCursor(x, (_display->height() - 3)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         _display->println(_fmtText); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } while (_display->nextPage()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | //***************************************************************************
 | 
			
		
	
		
		
			
				
					|  |  | void DisplayEPaper::offlineFooter() { |  |  | void DisplayEPaper::offlineFooter() { | 
			
		
	
		
		
			
				
					|  |  |     int16_t tbx, tby; |  |  |     int16_t tbx, tby; | 
			
		
	
		
		
			
				
					|  |  |     uint16_t tbw, tbh; |  |  |     uint16_t tbw, tbh; | 
			
		
	
	
		
		
			
				
					|  | @ -154,9 +176,11 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     _display->setPartialWindow(0, mHeadFootPadding, _display->width(), _display->height() - (mHeadFootPadding * 2)); |  |  |     _display->setPartialWindow(0, mHeadFootPadding, _display->width(), _display->height() - (mHeadFootPadding * 2)); | 
			
		
	
		
		
			
				
					|  |  |     _display->fillScreen(GxEPD_WHITE); |  |  |     _display->fillScreen(GxEPD_WHITE); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     do { |  |  |     do { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // actual Production
 | 
			
		
	
		
		
			
				
					|  |  |         if (totalPower > 9999) { |  |  |         if (totalPower > 9999) { | 
			
		
	
		
		
			
				
					
					|  |  |             snprintf(_fmtText, sizeof(_fmtText), "%.1f kW", (totalPower / 10000)); |  |  |             snprintf(_fmtText, sizeof(_fmtText), "%.1f kW", (totalPower / 1000)); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |             _changed = true; |  |  |             _changed = true; | 
			
		
	
		
		
			
				
					|  |  |         } else if ((totalPower > 0) && (totalPower <= 9999)) { |  |  |         } else if ((totalPower > 0) && (totalPower <= 9999)) { | 
			
		
	
		
		
			
				
					|  |  |             snprintf(_fmtText, sizeof(_fmtText), "%.0f W", totalPower); |  |  |             snprintf(_fmtText, sizeof(_fmtText), "%.0f W", totalPower); | 
			
		
	
	
		
		
			
				
					|  | @ -164,8 +188,9 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa | 
			
		
	
		
		
			
				
					|  |  |         } else { |  |  |         } else { | 
			
		
	
		
		
			
				
					|  |  |             snprintf(_fmtText, sizeof(_fmtText), "offline"); |  |  |             snprintf(_fmtText, sizeof(_fmtText), "offline"); | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |         if (totalPower == 0){ |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             _display->fillRect(0, mHeadFootPadding, 200,200, GxEPD_BLACK); |  |  |         if ((totalPower == 0) && (mEnPowerSafe)) { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |             _display->fillRect(0, mHeadFootPadding, 200, 200, GxEPD_BLACK); | 
			
		
	
		
		
			
				
					|  |  |             _display->drawBitmap(0, 0, logo, 200, 200, GxEPD_WHITE); |  |  |             _display->drawBitmap(0, 0, logo, 200, 200, GxEPD_WHITE); | 
			
		
	
		
		
			
				
					|  |  |         } else { |  |  |         } else { | 
			
		
	
		
		
			
				
					|  |  |             _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); |  |  |             _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); | 
			
		
	
	
		
		
			
				
					|  | @ -173,33 +198,70 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa | 
			
		
	
		
		
			
				
					|  |  |             _display->setCursor(x, mHeadFootPadding + tbh + 10); |  |  |             _display->setCursor(x, mHeadFootPadding + tbh + 10); | 
			
		
	
		
		
			
				
					|  |  |             _display->print(_fmtText); |  |  |             _display->print(_fmtText); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if ((totalYieldDay > 0) && (totalYieldTotal > 0)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 // Today Production
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 _display->setFont(&FreeSans18pt7b); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 y = _display->height() / 2; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 _display->setCursor(5, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (totalYieldDay > 9999) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     snprintf(_fmtText, _display->width(), "%.1f", (totalYieldDay / 1000)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->drawInvertedBitmap(5, y - ((tbh + 30) / 2), myToday, 30, 30, GxEPD_BLACK); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     x = ((_display->width() - tbw - 20) / 2) - tbx; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setCursor(x, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->print(_fmtText); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setCursor(_display->width() - 50, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setFont(&FreeSans12pt7b); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->println("kWh"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } else if (totalYieldDay <= 9999) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     snprintf(_fmtText, _display->width(), "%.0f", (totalYieldDay)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->drawInvertedBitmap(5, y - tbh, myToday, 30, 30, GxEPD_BLACK); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     x = ((_display->width() - tbw - 20) / 2) - tbx; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setCursor(x, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->print(_fmtText); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setCursor(_display->width() - 38, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setFont(&FreeSans12pt7b); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->println("Wh"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 y = y + tbh + 15; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 // Total Production
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 _display->setFont(&FreeSans18pt7b); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 _display->setCursor(5, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (totalYieldTotal > 9999) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     snprintf(_fmtText, _display->width(), "%.1f", (totalYieldTotal / 1000)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->drawInvertedBitmap(5, y - tbh, mySigma, 30, 30, GxEPD_BLACK); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     x = ((_display->width() - tbw - 20) / 2) - tbx; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setCursor(x, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->print(_fmtText); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setCursor(_display->width() - 59, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setFont(&FreeSans12pt7b); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->println("MWh"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } else if (totalYieldTotal <= 9999) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     snprintf(_fmtText, _display->width(), "%.0f", (totalYieldTotal)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->drawInvertedBitmap(5, y - tbh, mySigma, 30, 30, GxEPD_BLACK); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     x = ((_display->width() - tbw - 20) / 2) - tbx; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setCursor(x, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->print(_fmtText); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setCursor(_display->width() - 50, y); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->setFont(&FreeSans12pt7b); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     _display->println("kWh"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             // Inverter online
 | 
			
		
	
		
		
			
				
					|  |  |             _display->setFont(&FreeSans12pt7b); |  |  |             _display->setFont(&FreeSans12pt7b); | 
			
		
	
		
		
			
				
					
					|  |  |             y = _display->height() / 2; |  |  |             y = _display->height() - (mHeadFootPadding + 10); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             _display->setCursor(5, y); |  |  |             snprintf(_fmtText, sizeof(_fmtText), " %d online", isprod); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |             _display->print("today:"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             snprintf(_fmtText, _display->width(), "%.0f", totalYieldDay); |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |             _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); |  |  |             _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); | 
			
		
	
		
		
			
				
					
					|  |  |             x = ((_display->width() - tbw) / 2) - tbx; |  |  |             _display->drawInvertedBitmap(10, y - tbh, myWR, 20, 20, GxEPD_BLACK); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |             x = ((_display->width() - tbw - 20) / 2) - tbx; | 
			
		
	
		
		
			
				
					|  |  |             _display->setCursor(x, y); |  |  |             _display->setCursor(x, y); | 
			
		
	
		
		
			
				
					|  |  |             _display->print(_fmtText); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->setCursor(_display->width() - 38, y); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->println("Wh"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             y = y + tbh + 7; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->setCursor(5, y); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->print("total:"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             snprintf(_fmtText, _display->width(), "%.1f", totalYieldTotal); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             x = ((_display->width() - tbw) / 2) - tbx; |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->setCursor(x, y); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->print(_fmtText); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->setCursor(_display->width() - 50, y); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->println("kWh"); |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->setCursor(10, _display->height() - (mHeadFootPadding + 10)); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             snprintf(_fmtText, sizeof(_fmtText), "%d Inverter online", isprod); |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             _display->println(_fmtText); |  |  |             _display->println(_fmtText); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |     } while (_display->nextPage()); |  |  |     } while (_display->nextPage()); | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | @ -219,10 +281,10 @@ void DisplayEPaper::loop(float totalPower, float totalYieldDay, float totalYield | 
			
		
	
		
		
			
				
					|  |  |     if ((isprod > 0) && (_changed)) { |  |  |     if ((isprod > 0) && (_changed)) { | 
			
		
	
		
		
			
				
					|  |  |         _changed = false; |  |  |         _changed = false; | 
			
		
	
		
		
			
				
					|  |  |         lastUpdatePaged(); |  |  |         lastUpdatePaged(); | 
			
		
	
		
		
			
				
					
					|  |  |     } else if((0 == totalPower) && (mEnPowerSafe)) |  |  |     } else if ((0 == totalPower) && (mEnPowerSafe)) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         offlineFooter(); |  |  |         offlineFooter(); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     _display->powerOff(); |  |  |     _display->powerOff(); | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | //***************************************************************************
 |  |  | //***************************************************************************
 | 
			
		
	
		
		
			
				
					
					|  |  | #endif // ESP32
 |  |  | #endif  // ESP32
 | 
			
				
				
			
		
	
		
		
	
	
		
		
			
				
					|  | 
 |