Browse Source

0.8.131

* improved refresh routine of ePaper, full refresh each 12h #1107 #1706
main
lumapu 5 months ago
parent
commit
55e45c7ffb
  1. 3
      src/CHANGES.md
  2. 4
      src/app.cpp
  3. 2
      src/defines.h
  4. 10
      src/plugins/Display/Display.h
  5. 40
      src/plugins/Display/Display_ePaper.cpp
  6. 4
      src/plugins/Display/Display_ePaper.h

3
src/CHANGES.md

@ -1,5 +1,8 @@
# Development Changes # Development Changes
## 0.8.131 - 2024-08-08
* improved refresh routine of ePaper, full refresh each 12h #1107 #1706
## 0.8.130 - 2024-08-04 ## 0.8.130 - 2024-08-04
* fix message `ERR_DUPLICATE_INVERTER` #1705, #1700 * fix message `ERR_DUPLICATE_INVERTER` #1705, #1700
* merge PR: Power limit command accelerated #1704 * merge PR: Power limit command accelerated #1704

4
src/app.cpp

@ -142,6 +142,10 @@ void app::loop(void) {
if (mMqttEnabled && mNetworkConnected) if (mMqttEnabled && mNetworkConnected)
mMqtt.loop(); mMqtt.loop();
#endif #endif
#if defined(PLUGIN_DISPLAY)
mDisplay.loop();
#endif
yield(); yield();
} }

2
src/defines.h

@ -13,7 +13,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_PATCH 130 #define VERSION_PATCH 131
//------------------------------------- //-------------------------------------
typedef struct { typedef struct {
uint8_t ch; uint8_t ch;

10
src/plugins/Display/Display.h

@ -72,6 +72,14 @@ class Display {
} }
void loop() {
#if defined(ESP32) && !defined(ETHERNET)
if (DISP_TYPE_T10_EPAPER == mCfg->type) {
mEpaper.refreshLoop();
}
#endif
}
void payloadEventListener(uint8_t cmd) { void payloadEventListener(uint8_t cmd) {
mNewPayload = true; mNewPayload = true;
} }
@ -190,7 +198,7 @@ class Display {
mEpaper.loop((totalPower), totalYieldDay, totalYieldTotal, nrprod); mEpaper.loop((totalPower), totalYieldDay, totalYieldTotal, nrprod);
mRefreshCycle++; mRefreshCycle++;
if (mRefreshCycle > 480) { if (mRefreshCycle > 2880) { // 15 * 2280 = 44300s = 12h
mEpaper.fullRefresh(); mEpaper.fullRefresh();
mRefreshCycle = 0; mRefreshCycle = 0;
} }

40
src/plugins/Display/Display_ePaper.cpp

@ -26,14 +26,13 @@ void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, u
mRefreshState = RefreshStatus::LOGO; mRefreshState = RefreshStatus::LOGO;
mSecondCnt = 0; mSecondCnt = 0;
mLogoDisplayed = false;
if (DISP_TYPE_T10_EPAPER == type) { if (DISP_TYPE_T10_EPAPER == type) {
Serial.begin(115200); #if defined(SPI_HAL)
#if defined(SPI_HAL)
hal.init(_MOSI, _DC, _SCK, _CS, _RST, _BUSY); hal.init(_MOSI, _DC, _SCK, _CS, _RST, _BUSY);
_display = new GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT>(GxEPD2_150_BN(&hal)); _display = new GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT>(GxEPD2_150_BN(&hal));
#else #else
_display = new GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT>(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); _display = new GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT>(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY));
#if defined(USE_HSPI_FOR_EPD) #if defined(USE_HSPI_FOR_EPD)
hspi.begin(_SCK, _BUSY, _MOSI, _CS); hspi.begin(_SCK, _BUSY, _MOSI, _CS);
@ -41,8 +40,8 @@ void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, u
#elif defined(PLUGIN_DISPLAY) #elif defined(PLUGIN_DISPLAY)
_display->epd2.init(_SCK, _MOSI, 115200, true, 20, false); _display->epd2.init(_SCK, _MOSI, 115200, true, 20, false);
#endif #endif
#endif #endif
_display->init(115200, true, 20, false); _display->init(0, true, 20, false);
_display->setRotation(mDisplayRotation); _display->setRotation(mDisplayRotation);
_display->setFullWindow(); _display->setFullWindow();
_version = version; _version = version;
@ -58,7 +57,8 @@ void DisplayEPaper::config(uint8_t rotation, bool enPowerSave) {
void DisplayEPaper::fullRefresh() { void DisplayEPaper::fullRefresh() {
if(RefreshStatus::DONE != mRefreshState) if(RefreshStatus::DONE != mRefreshState)
return; return;
mSecondCnt = 2; if(mLogoDisplayed)
return; // no refresh during logo display
mRefreshState = RefreshStatus::BLACK; mRefreshState = RefreshStatus::BLACK;
} }
@ -67,22 +67,29 @@ void DisplayEPaper::refreshLoop() {
switch(mRefreshState) { switch(mRefreshState) {
case RefreshStatus::LOGO: case RefreshStatus::LOGO:
_display->fillScreen(GxEPD_BLACK); _display->fillScreen(GxEPD_BLACK);
_display->firstPage();
_display->drawBitmap(0, 0, logo, 200, 200, GxEPD_WHITE); _display->drawBitmap(0, 0, logo, 200, 200, GxEPD_WHITE);
mSecondCnt = 2; mSecondCnt = 4;
mNextRefreshState = RefreshStatus::PARTITIALS; mNextRefreshState = RefreshStatus::LOGO_WAIT;
mRefreshState = RefreshStatus::WAIT; mRefreshState = RefreshStatus::WAIT;
break; break;
case RefreshStatus::LOGO_WAIT:
if(0 != mSecondCnt)
break;
mRefreshState = RefreshStatus::BLACK;
break;
case RefreshStatus::BLACK: case RefreshStatus::BLACK:
_display->fillScreen(GxEPD_BLACK); _display->fillScreen(GxEPD_BLACK);
_display->firstPage();
mNextRefreshState = RefreshStatus::WHITE; mNextRefreshState = RefreshStatus::WHITE;
mRefreshState = RefreshStatus::WAIT; mRefreshState = RefreshStatus::WAIT;
break; break;
case RefreshStatus::WHITE: case RefreshStatus::WHITE:
if(0 != mSecondCnt)
break;
_display->fillScreen(GxEPD_WHITE); _display->fillScreen(GxEPD_WHITE);
_display->firstPage();
mNextRefreshState = RefreshStatus::PARTITIALS; mNextRefreshState = RefreshStatus::PARTITIALS;
mRefreshState = RefreshStatus::WAIT; mRefreshState = RefreshStatus::WAIT;
break; break;
@ -93,11 +100,8 @@ void DisplayEPaper::refreshLoop() {
break; break;
case RefreshStatus::PARTITIALS: case RefreshStatus::PARTITIALS:
if(0 != mSecondCnt)
break;
headlineIP(); headlineIP();
versionFooter(); versionFooter();
mSecondCnt = 4; // display Logo time during boot up
mNextRefreshState = RefreshStatus::DONE; mNextRefreshState = RefreshStatus::DONE;
mRefreshState = RefreshStatus::WAIT; mRefreshState = RefreshStatus::WAIT;
break; break;
@ -219,7 +223,12 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa
if ((totalPower == 0) && (mEnPowerSave)) { if ((totalPower == 0) && (mEnPowerSave)) {
_display->fillRect(0, mHeadFootPadding, 200, 200, GxEPD_BLACK); _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);
mLogoDisplayed = true;
} else { } else {
if(mLogoDisplayed) {
mLogoDisplayed = false;
fullRefresh();
}
_display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh); _display->getTextBounds(_fmtText, 0, 0, &tbx, &tby, &tbw, &tbh);
x = ((_display->width() - tbw) / 2) - tbx; x = ((_display->width() - tbw) / 2) - tbx;
_display->setCursor(x, mHeadFootPadding + tbh + 10); _display->setCursor(x, mHeadFootPadding + tbh + 10);
@ -306,8 +315,7 @@ void DisplayEPaper::loop(float totalPower, float totalYieldDay, float totalYield
//*************************************************************************** //***************************************************************************
void DisplayEPaper::tickerSecond() { void DisplayEPaper::tickerSecond() {
if(mSecondCnt != 0) if(mSecondCnt > 0)
mSecondCnt--; mSecondCnt--;
refreshLoop();
} }
#endif // ESP32 #endif // ESP32

4
src/plugins/Display/Display_ePaper.h

@ -50,7 +50,8 @@ class DisplayEPaper {
WHITE, WHITE,
WAIT, WAIT,
PARTITIALS, PARTITIALS,
LOGO LOGO,
LOGO_WAIT
}; };
uint8_t mDisplayRotation; uint8_t mDisplayRotation;
@ -64,6 +65,7 @@ class DisplayEPaper {
const char* _version; const char* _version;
RefreshStatus mRefreshState, mNextRefreshState; RefreshStatus mRefreshState, mNextRefreshState;
uint8_t mSecondCnt; uint8_t mSecondCnt;
bool mLogoDisplayed;
#if defined(SPI_HAL) #if defined(SPI_HAL)
epdHal hal; epdHal hal;
#endif #endif

Loading…
Cancel
Save