Skip to content

Commit

Permalink
Merge branch 'pagetask' into test
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas committed Jan 30, 2022
2 parents e3a2f7f + d88eeca commit 3ab2170
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/pagetask/ApparentWindPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ PageDescription registerApparentWindPage(
"apparentWind",
createPage,
0,
{"AWS","AWD"}
{"AWS","AWD"},
false
);
8 changes: 6 additions & 2 deletions lib/pagetask/Pagedata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Page* (CommonData &)> PageFunction;
Expand All @@ -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;
}
};
14 changes: 12 additions & 2 deletions lib/pagetask/Pagetask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class PageStruct{
public:
Page *page=NULL;
PageData parameters;
PageDescription *description=NULL;
};

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -190,17 +193,24 @@ 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;
if (currentPage == NULL){
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);
}

Expand Down

0 comments on commit 3ab2170

Please sign in to comment.