From 44cb8d35ce5dedf2c0bfbd8de055b2b599ffbe13 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Wed, 22 Jan 2025 12:07:00 +0100 Subject: [PATCH] Improved page refresh possibilities and page white --- lib/obp60task/PageWhite.cpp | 12 ++++++++++-- lib/obp60task/Pagedata.h | 1 + lib/obp60task/obp60task.cpp | 17 +++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/obp60task/PageWhite.cpp b/lib/obp60task/PageWhite.cpp index a2b6737..e40a3ac 100644 --- a/lib/obp60task/PageWhite.cpp +++ b/lib/obp60task/PageWhite.cpp @@ -13,6 +13,7 @@ public: PageWhite(CommonData &common){ commonData = &common; common.logger->logDebug(GwLog::LOG,"Instantiate PageWhite"); + refreshtime = 15000; } virtual int handleKey(int key) { @@ -53,7 +54,11 @@ public: int bgcolor = GxEPD_WHITE; // Set display in partial refresh mode - getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update + if (mode == 'W') { + getdisplay().setFullWindow(); + } else { + getdisplay().setPartialWindow(0, 0, getdisplay().width(), getdisplay().height()); // Set partial update + } if (mode == 'L') { getdisplay().drawBitmap(0, 0, gImage_Logo_OBP_400x300_sw, getdisplay().width(), getdisplay().height(), commonData->fgcolor); @@ -62,7 +67,10 @@ public: } // Update display - getdisplay().nextPage(); // Partial update (fast) + getdisplay().nextPage(); + if (mode == 'W') { + getdisplay().hibernate(); + } }; }; diff --git a/lib/obp60task/Pagedata.h b/lib/obp60task/Pagedata.h index cc4c45b..b385b5c 100644 --- a/lib/obp60task/Pagedata.h +++ b/lib/obp60task/Pagedata.h @@ -100,6 +100,7 @@ class Page{ protected: CommonData *commonData; public: + int refreshtime = 1000; virtual void displayPage(PageData &pageData)=0; virtual void displayNew(PageData &pageData){} virtual void setupKeys() { diff --git a/lib/obp60task/obp60task.cpp b/lib/obp60task/obp60task.cpp index 662942e..e56aaaf 100644 --- a/lib/obp60task/obp60task.cpp +++ b/lib/obp60task/obp60task.cpp @@ -550,8 +550,10 @@ void OBP60Task(GwApi *api){ //#################################################################################### bool systemPage = false; + Page *currentPage; while (true){ delay(100); // Delay 100ms (loop time) + bool keypressed = false; // Undervoltage detection if(uvoltage == true){ @@ -593,8 +595,8 @@ void OBP60Task(GwApi *api){ int keyboardMessage=0; while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){ LOG_DEBUG(GwLog::LOG,"new key from keyboard %d",keyboardMessage); + keypressed = true; - Page *currentPage; if (keyboardMessage == 12) { LOG_DEBUG(GwLog::LOG, "Calling system page"); systemPage = true; // System page is out of band @@ -725,9 +727,17 @@ void OBP60Task(GwApi *api){ } } - // Refresh display data all 1s - if(millis() > starttime3 + 1000){ + // Refresh display data, default all 1s + currentPage = pages[pageNumber].page; + int pagetime = 1000; + if ((lastPage == pageNumber) and (!keypressed)) { + // same page we use page defined time + pagetime = currentPage->refreshtime; + } + if(millis() > starttime3 + pagetime){ + LOG_DEBUG(GwLog::DEBUG,"Page with refreshtime=%d", pagetime); starttime3 = millis(); + //refresh data from api api->getBoatDataValues(boatValues.numValues,boatValues.allBoatValues); api->getStatus(commonData.status); @@ -749,7 +759,6 @@ void OBP60Task(GwApi *api){ syspage->displayPage(sysparams); } else { - Page *currentPage = pages[pageNumber].page; if (currentPage == NULL){ LOG_DEBUG(GwLog::ERROR,"page number %d not found", pageNumber); // Error handling for missing page