From a074713d6fd9a39222a579d7f96f72756d037723 Mon Sep 17 00:00:00 2001 From: neu-rah Date: Fri, 12 Dec 2014 01:43:14 -0100 Subject: [PATCH] tested menus after Print derivation, PASSED --- examples/gfx_menu/gfx_menu.ino | 1 + menu.cpp | 1 + menu.h | 7 ------- menuGFX.h | 17 ++++------------- menuLCD.h | 15 ++++----------- menuLCDs.h | 20 ++++++-------------- menuPrint.h | 14 ++++---------- 7 files changed, 20 insertions(+), 55 deletions(-) diff --git a/examples/gfx_menu/gfx_menu.ino b/examples/gfx_menu/gfx_menu.ino index 874b94b6..c1be1df4 100644 --- a/examples/gfx_menu/gfx_menu.ino +++ b/examples/gfx_menu/gfx_menu.ino @@ -1,6 +1,7 @@ /******************** Arduino generic menu system GFX menu - unsing adafruit gfx screens +tested on ATmega2560 http://www.r-site.net/?at=//op%5B%40id=%273090%27%5D Sept. 2014 Rui Azevedo - ruihfazevedo(@rrob@)gmail.com diff --git a/menu.cpp b/menu.cpp index fa7ac511..1781c023 100644 --- a/menu.cpp +++ b/menu.cpp @@ -74,6 +74,7 @@ void menu::activate(menuOut& p,Stream& c,bool canExit) { if (op>=0&&openabled) { + printMenu(p,canExit);//clearing old selection data[op]->activate(p,c,true); } } else if (op==-1) {//then exit diff --git a/menu.h b/menu.h index 1fb4aea5..033302e7 100644 --- a/menu.h +++ b/menu.h @@ -164,13 +164,6 @@ www.r-site.net virtual void clearLine(int ln)=0; virtual void clear()=0; virtual void setCursor(int x,int y)=0; - /*virtual void print(char ch)=0; - virtual void print(const char *text)=0; - virtual void println(const char *text="")=0; - virtual void print(unsigned long)=0; - virtual void println(unsigned long)=0; - virtual void print(double)=0; - virtual void println(double)=0;*/ virtual void printPrompt(prompt &o,bool selected,int idx,int posY,int width); virtual void printMenu(menu&,bool drawExit)=0; }; diff --git a/menuGFX.h b/menuGFX.h index b1a802df..337b93df 100644 --- a/menuGFX.h +++ b/menuGFX.h @@ -61,34 +61,25 @@ www.r-site.net setCursor(0,0); } virtual void setCursor(int x,int y) {gfx.setCursor(x*resX,y*resY);} - virtual void print(char ch) {gfx.print(ch);} - virtual void print(const char *text) {gfx.print(text);} - virtual void println(const char *text="") {gfx.println(text);}; - virtual void print(unsigned long i) {gfx.print(i);}; - virtual void println(unsigned long i) {gfx.println(i);}; - virtual void print(double i) {gfx.print(i);}; - virtual void println(double i) {gfx.println(i);}; - virtual void print(prompt &o,bool selected,int idx,int posY,int width) { + virtual size_t write(uint8_t ch) {return gfx.write(ch);} + virtual void printPrompt(prompt &o,bool selected,int idx,int posY,int width) { gfx.fillRect(0,posY*resY,maxX*resX,resY,selected?hiliteColor:bgColor); gfx.setTextColor(o.enabled?enabledColor:disabledColor); setCursor(0,posY); o.printTo(*this); - //println(); } virtual void printMenu(menu& m,bool drawExit) { if (drawn!=&m) clear();//clear all screen when changing menu if (m.sel-top>=maxY) top=m.sel-maxY+1;//selected option outside device (bottom) else if (m.sel=top)&&((i-top)=maxY) break; if (needRedraw(m,i)) { - print(*m.data[i],i==m.sel,i+1,i-top,m.width); + printPrompt(*m.data[i],i==m.sel,i+1,i-top,m.width); } - //} } if (drawExit&&i-top=top)&&((i-top)=maxY) break; if (needRedraw(m,i)) { - print(*m.data[i],i==m.sel,i+1,i-top,m.width); + printPrompt(*m.data[i],i==m.sel,i+1,i-top,m.width); } } } if (drawExit&&i-top=top)&&((i-top)=maxY) break; - if (needRedraw(m,i)) - print(*m.data[i],i==m.sel,i+1,i-top,m.width); - //} + if(i-top>=maxY) break; + if (needRedraw(m,i)) + printPrompt(*m.data[i],i==m.sel,i+1,i-top,m.width); } if (drawExit&&i-top