Skip to content

Commit

Permalink
add keyboard handler to page
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas committed Jan 30, 2022
1 parent 210206c commit e4087fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/pagetask/Pagedata.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Page{
public:
virtual void display(CommonData &commonData, PageData &pageData)=0;
virtual void displayNew(CommonData &commonData, PageData &pageData){}
//return -1 if handled by the page
virtual int handleKey(int key){return key;}
};

typedef std::function<Page* (CommonData &)> PageFunction;
Expand Down
6 changes: 6 additions & 0 deletions lib/pagetask/Pagetask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ typedef struct {
int page0=0;
QueueHandle_t queue;
} MyData;

void keyboardTask(void *param){
MyData *data=(MyData *)param;
int page=data->page0;
Expand Down Expand Up @@ -184,7 +185,12 @@ void pageTask(GwApi *api){
int keyboardMessage=-1;
if (xQueueReceive(allParameters.queue,&keyboardMessage,0)){
LOG_DEBUG(GwLog::LOG,"new page from keyboard %d",keyboardMessage);
Page *currentPage=pages[pageNumber].page;
if (currentPage ){
keyboardMessage=currentPage->handleKey(keyboardMessage);
}
if (keyboardMessage >= 0 && keyboardMessage < numPages){

pageNumber=keyboardMessage;
}
LOG_DEBUG(GwLog::LOG,"set pagenumber to %d",pageNumber);
Expand Down

0 comments on commit e4087fb

Please sign in to comment.