Browse Source

Merge branch 'ThomasPohl-feature/offline-logo' into development03

pull/958/head
lumapu 1 year ago
parent
commit
67c1c10076
  1. 94
      src/plugins/Display/Display_ePaper.cpp
  2. 1
      src/plugins/Display/Display_ePaper.h

94
src/plugins/Display/Display_ePaper.cpp

@ -120,6 +120,28 @@ void DisplayEPaper::lastUpdatePaged() {
} while (_display->nextPage()); } while (_display->nextPage());
} }
//*************************************************************************** //***************************************************************************
void DisplayEPaper::offlineFooter() {
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 {
if (NULL != mUtcTs) {
snprintf(_fmtText, sizeof(_fmtText), "offline");
_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::actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod) { void DisplayEPaper::actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod) {
int16_t tbx, tby; int16_t tbx, tby;
uint16_t tbw, tbh, x, y; uint16_t tbw, tbh, x, y;
@ -139,38 +161,43 @@ void DisplayEPaper::actualPowerPaged(float _totalPower, float _totalYieldDay, fl
} else { } else {
snprintf(_fmtText, sizeof(_fmtText), "offline"); snprintf(_fmtText, sizeof(_fmtText), "offline");
} }
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); if (_totalPower == 0){
x = ((_display->width() - tbw) / 2) - tbx; _display->fillRect(0, mHeadFootPadding, 200,200, GxEPD_BLACK);
_display->setCursor(x, mHeadFootPadding + tbh + 10); _display->drawBitmap(0, 0, logo, 200, 200, GxEPD_WHITE);
_display->print(_fmtText); } else {
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
_display->setFont(&FreeSans12pt7b); x = ((_display->width() - tbw) / 2) - tbx;
y = _display->height() / 2; _display->setCursor(x, mHeadFootPadding + tbh + 10);
_display->setCursor(5, y); _display->print(_fmtText);
_display->print("today:");
snprintf(_fmtText, _display->width(), "%.0f", _totalYieldDay); _display->setFont(&FreeSans12pt7b);
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); y = _display->height() / 2;
x = ((_display->width() - tbw) / 2) - tbx; _display->setCursor(5, y);
_display->setCursor(x, y); _display->print("today:");
_display->print(_fmtText); snprintf(_fmtText, _display->width(), "%.0f", _totalYieldDay);
_display->setCursor(_display->width() - 38, y); _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
_display->println("Wh"); x = ((_display->width() - tbw) / 2) - tbx;
_display->setCursor(x, y);
y = y + tbh + 7; _display->print(_fmtText);
_display->setCursor(5, y); _display->setCursor(_display->width() - 38, y);
_display->print("total:"); _display->println("Wh");
snprintf(_fmtText, _display->width(), "%.1f", _totalYieldTotal);
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); y = y + tbh + 7;
x = ((_display->width() - tbw) / 2) - tbx; _display->setCursor(5, y);
_display->setCursor(x, y); _display->print("total:");
_display->print(_fmtText); snprintf(_fmtText, _display->width(), "%.1f", _totalYieldTotal);
_display->setCursor(_display->width() - 50, y); _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
_display->println("kWh"); x = ((_display->width() - tbw) / 2) - tbx;
_display->setCursor(x, y);
_display->setCursor(10, _display->height() - (mHeadFootPadding + 10)); _display->print(_fmtText);
snprintf(_fmtText, sizeof(_fmtText), "%d Inverter online", _isprod); _display->setCursor(_display->width() - 50, y);
_display->println(_fmtText); _display->println("kWh");
_display->setCursor(10, _display->height() - (mHeadFootPadding + 10));
snprintf(_fmtText, sizeof(_fmtText), "%d Inverter online", _isprod);
_display->println(_fmtText);
}
} while (_display->nextPage()); } while (_display->nextPage());
} }
//*************************************************************************** //***************************************************************************
@ -185,11 +212,12 @@ void DisplayEPaper::loop(float totalPower, float totalYieldDay, float totalYield
// call the PowerPage to change the PV Power Values // call the PowerPage to change the PV Power Values
actualPowerPaged(totalPower, totalYieldDay, totalYieldTotal, isprod); actualPowerPaged(totalPower, totalYieldDay, totalYieldTotal, isprod);
// if there was an change and the Inverter is producing set a new Timestam in the footline // if there was an change and the Inverter is producing set a new Timestamp in the footline
if ((isprod > 0) && (_changed)) { if ((isprod > 0) && (_changed)) {
_changed = false; _changed = false;
lastUpdatePaged(); lastUpdatePaged();
} } else if(totalPower==0)
offlineFooter();
_display->powerOff(); _display->powerOff();
} }

1
src/plugins/Display/Display_ePaper.h

@ -39,6 +39,7 @@ class DisplayEPaper {
void headlineIP(); void headlineIP();
void actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod); void actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod);
void lastUpdatePaged(); void lastUpdatePaged();
void offlineFooter();
uint8_t mDisplayRotation; uint8_t mDisplayRotation;
bool _changed = false; bool _changed = false;

Loading…
Cancel
Save