diff --git a/lib/pagetask/ApparentWindPage.cpp b/lib/pagetask/ApparentWindPage.cpp index ed24727d..f0e82607 100644 --- a/lib/pagetask/ApparentWindPage.cpp +++ b/lib/pagetask/ApparentWindPage.cpp @@ -41,5 +41,6 @@ PageDescription registerApparentWindPage( "apparentWind", createPage, 0, - {"AWS","AWD"} + {"AWS","AWD"}, + false ); \ No newline at end of file diff --git a/lib/pagetask/Pagedata.h b/lib/pagetask/Pagedata.h index 3708c33f..3a655d22 100644 --- a/lib/pagetask/Pagedata.h +++ b/lib/pagetask/Pagedata.h @@ -29,6 +29,7 @@ typedef struct{ class Page{ public: virtual void display(CommonData &commonData, PageData &pageData)=0; + virtual void displayNew(CommonData &commonData, PageData &pageData){} }; typedef std::function PageFunction; @@ -48,15 +49,18 @@ class PageDescription{ int userParam=0; StringList fixedParam; PageFunction creator; - PageDescription(String name, PageFunction creator,int userParam,StringList fixedParam){ + bool header=true; + PageDescription(String name, PageFunction creator,int userParam,StringList fixedParam,bool header=true){ this->pageName=name; this->userParam=userParam; this->fixedParam=fixedParam; this->creator=creator; + this->header=header; } - PageDescription(String name, PageFunction creator,int userParam){ + PageDescription(String name, PageFunction creator,int userParam,bool header=true){ this->pageName=name; this->userParam=userParam; this->creator=creator; + this->header=header; } }; diff --git a/lib/pagetask/Pagetask.cpp b/lib/pagetask/Pagetask.cpp index 0f6550cb..90a0f4ca 100644 --- a/lib/pagetask/Pagetask.cpp +++ b/lib/pagetask/Pagetask.cpp @@ -85,6 +85,7 @@ class PageStruct{ public: Page *page=NULL; PageData parameters; + PageDescription *description=NULL; }; /** @@ -143,6 +144,7 @@ void pageTask(GwApi *api){ LOG_DEBUG(GwLog::ERROR,"page description for %s not found",pageType.c_str()); continue; } + pages[i].description=description; pages[i].page=description->creator(commonData); pages[i].parameters.pageName=pageType; LOG_DEBUG(GwLog::DEBUG,"found page %s for number %d",pageType.c_str(),i); @@ -175,6 +177,7 @@ void pageTask(GwApi *api){ //loop LOG_DEBUG(GwLog::LOG,"pagetask: start mainloop"); int pageNumber=0; + int lastPage=pageNumber; while (true){ delay(1000); //check if there is a keyboard message @@ -190,8 +193,11 @@ void pageTask(GwApi *api){ api->getBoatDataValues(boatValues.numValues,boatValues.allBoatValues); api->getStatus(commonData.status); - //handle the page + //handle the pag + if (pages[pageNumber].description && pages[pageNumber].description->header){ + //build some header and footer using commonData + } //.... //call the particular page Page *currentPage=pages[pageNumber].page; @@ -199,8 +205,12 @@ void pageTask(GwApi *api){ LOG_DEBUG(GwLog::ERROR,"page number %d not found",pageNumber); } else{ + if (lastPage != pageNumber){ + currentPage->displayNew(commonData,pages[pageNumber].parameters); + lastPage=pageNumber; + } //call the page code - LOG_DEBUG(GwLog::DEBUG,"calling page %d type %s",currentPage); + LOG_DEBUG(GwLog::DEBUG,"calling page %d type %s"); currentPage->display(commonData,pages[pageNumber].parameters); }