Improved page refresh possibilities and page white

This commit is contained in:
Thomas Hooge 2025-01-22 12:07:00 +01:00
parent 988e7ccbc7
commit 44cb8d35ce
3 changed files with 24 additions and 6 deletions

View File

@ -13,6 +13,7 @@ public:
PageWhite(CommonData &common){ PageWhite(CommonData &common){
commonData = &common; commonData = &common;
common.logger->logDebug(GwLog::LOG,"Instantiate PageWhite"); common.logger->logDebug(GwLog::LOG,"Instantiate PageWhite");
refreshtime = 15000;
} }
virtual int handleKey(int key) { virtual int handleKey(int key) {
@ -53,7 +54,11 @@ public:
int bgcolor = GxEPD_WHITE; int bgcolor = GxEPD_WHITE;
// Set display in partial refresh mode // 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') { if (mode == 'L') {
getdisplay().drawBitmap(0, 0, gImage_Logo_OBP_400x300_sw, getdisplay().width(), getdisplay().height(), commonData->fgcolor); getdisplay().drawBitmap(0, 0, gImage_Logo_OBP_400x300_sw, getdisplay().width(), getdisplay().height(), commonData->fgcolor);
@ -62,7 +67,10 @@ public:
} }
// Update display // Update display
getdisplay().nextPage(); // Partial update (fast) getdisplay().nextPage();
if (mode == 'W') {
getdisplay().hibernate();
}
}; };
}; };

View File

@ -100,6 +100,7 @@ class Page{
protected: protected:
CommonData *commonData; CommonData *commonData;
public: public:
int refreshtime = 1000;
virtual void displayPage(PageData &pageData)=0; virtual void displayPage(PageData &pageData)=0;
virtual void displayNew(PageData &pageData){} virtual void displayNew(PageData &pageData){}
virtual void setupKeys() { virtual void setupKeys() {

View File

@ -550,8 +550,10 @@ void OBP60Task(GwApi *api){
//#################################################################################### //####################################################################################
bool systemPage = false; bool systemPage = false;
Page *currentPage;
while (true){ while (true){
delay(100); // Delay 100ms (loop time) delay(100); // Delay 100ms (loop time)
bool keypressed = false;
// Undervoltage detection // Undervoltage detection
if(uvoltage == true){ if(uvoltage == true){
@ -593,8 +595,8 @@ void OBP60Task(GwApi *api){
int keyboardMessage=0; int keyboardMessage=0;
while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){ while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){
LOG_DEBUG(GwLog::LOG,"new key from keyboard %d",keyboardMessage); LOG_DEBUG(GwLog::LOG,"new key from keyboard %d",keyboardMessage);
keypressed = true;
Page *currentPage;
if (keyboardMessage == 12) { if (keyboardMessage == 12) {
LOG_DEBUG(GwLog::LOG, "Calling system page"); LOG_DEBUG(GwLog::LOG, "Calling system page");
systemPage = true; // System page is out of band systemPage = true; // System page is out of band
@ -725,9 +727,17 @@ void OBP60Task(GwApi *api){
} }
} }
// Refresh display data all 1s // Refresh display data, default all 1s
if(millis() > starttime3 + 1000){ 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(); starttime3 = millis();
//refresh data from api //refresh data from api
api->getBoatDataValues(boatValues.numValues,boatValues.allBoatValues); api->getBoatDataValues(boatValues.numValues,boatValues.allBoatValues);
api->getStatus(commonData.status); api->getStatus(commonData.status);
@ -749,7 +759,6 @@ void OBP60Task(GwApi *api){
syspage->displayPage(sysparams); syspage->displayPage(sysparams);
} }
else { else {
Page *currentPage = pages[pageNumber].page;
if (currentPage == NULL){ if (currentPage == NULL){
LOG_DEBUG(GwLog::ERROR,"page number %d not found", pageNumber); LOG_DEBUG(GwLog::ERROR,"page number %d not found", pageNumber);
// Error handling for missing page // Error handling for missing page