11/* *******************
22Sept. 2014 Rui Azevedo - ruihfazevedo(@rrob@)gmail.com
33creative commons license 3.0: Attribution-ShareAlike CC BY-SA
4- This software is furnished "as is", without technical support, and with no
4+ This software is furnished "as is", without technical support, and with no
55warranty, express or implied, as to its usefulness for any purpose.
6-
6+
77Thread Safe: No
88Extensible: Yes
99
1010Use graphics screens as menu output, based on U8GLIB graphic display
1111www.r-site.net
12-
12+
1313 printPrompt(), Added posX to take into account ox via menu.ox and setPosition(ox,oy), need to update other files to support that.
14-
14+
1515***/
1616#ifndef RSITE_ARDUINOP_MENU_U8G
1717 #define RSITE_ARDUINOP_MENU_U8G
18- // #include <U8glib.h>
19- #include < U8g_teensy.h>
18+ #include < U8glib.h>
19+ // #include <U8g_teensy.h>
2020 #include " menu.h"
2121
2222 class menuU8G :public menuOut {
@@ -25,7 +25,9 @@ www.r-site.net
2525 unsigned char bgColor;
2626 unsigned char enabledColor;
2727 unsigned char disabledColor;
28-
28+ unsigned char enabledColorHi;
29+ unsigned char disabledColorHi;
30+
2931 U8GLIB& gfx;
3032 menuU8G (
3133 U8GLIB& gfx,
@@ -41,6 +43,8 @@ www.r-site.net
4143 enabledColor(enabledColor),
4244 disabledColor(disabledColor),
4345 hiliteColor(hiliteColor),
46+ enabledColorHi(bgColor),
47+ disabledColorHi(bgColor),
4448 menuOut(gfx.getWidth()/resX,gfx.getHeight()/resY,resX,resY)
4549 {
4650 // Small typefaces used to draw the menu, do not forget to report resX and resY
@@ -52,13 +56,13 @@ www.r-site.net
5256 gfx.setFont (u8g_font_04b_03); // Good result
5357 gfx.setFontPosBottom (); // U8Glib font positioning
5458 }
55-
59+
5660 virtual void clearLine (int ln) {
5761 // No need to clear, the U8Glib display loop clear screen on each refresh
5862 // setCursor(0,ln);
5963 }
6064 virtual void clear () {
61- // No need to clear, the U8Glib display loop clear screen on each refresh
65+ // No need to clear, the U8Glib display loop clear screen on each refresh
6266 }
6367 virtual void setCursor (int x,int y) {
6468 unsigned char xPxTextOffset = 4 ; // offset in pixels on text on x againt hightlight bar
@@ -69,22 +73,22 @@ www.r-site.net
6973 return 1 ;
7074 }
7175 virtual void printPrompt (prompt &o,bool selected,int idx,int posX,int posY,int width) {
72- gfx.setColorIndex (selected?disabledColor :bgColor);
76+ gfx.setColorIndex (selected?hiliteColor :bgColor);
7377 gfx.drawBox (posX*resX,posY*resY,maxX*resX,resY);
74- gfx.setColorIndex (selected?hiliteColor: disabledColor);
78+ gfx.setColorIndex (selected?(o. enabled ?enabledColorHi:disabledColorHi):(o. enabled ?enabledColor: disabledColor) );
7579 setCursor (posX,posY+1 ); // +1 compensate the height of the font and the way how U8Glib works
7680 o.printTo (*this );
7781 }
7882 virtual void printMenu (menu& m,bool drawExit) {
7983 // if (drawn!=&m) clear();//clear all screen when changing menu - not ok for U8Glib
80-
84+
8185 if (m.sel -top >= maxY)
8286 top = m.sel - maxY + resY + 1 ; // selected option outside device (bottom)
8387 else if (m.sel < top)
8488 top = m.sel + resY; // selected option outside device (top)
85-
89+
8690 int i = top;
87-
91+
8892 for (; i < m.sz ; i++)
8993 {
9094 if (i-top >= maxY)
@@ -100,4 +104,3 @@ www.r-site.net
100104 }
101105 };
102106#endif RSITE_ARDUINOP_MENU_LCD
103-
0 commit comments