Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved page refresh possibilities and page white #146

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/obp60task/PageWhite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ char mode = 'W'; // display mode (W)hite | (L)ogo | (M)FD logo
PageWhite(CommonData &common){
commonData = &common;
common.logger->logDebug(GwLog::LOG,"Instantiate PageWhite");
refreshtime = 15000;
}

virtual int handleKey(int key) {
Expand Down Expand Up @@ -53,7 +54,11 @@ char mode = 'W'; // display mode (W)hite | (L)ogo | (M)FD logo
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);
Expand All @@ -62,7 +67,10 @@ char mode = 'W'; // display mode (W)hite | (L)ogo | (M)FD logo
}

// Update display
getdisplay().nextPage(); // Partial update (fast)
getdisplay().nextPage();
if (mode == 'W') {
getdisplay().hibernate();
}

};
};
Expand Down
1 change: 1 addition & 0 deletions lib/obp60task/Pagedata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
17 changes: 13 additions & 4 deletions lib/obp60task/obp60task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down