Skip to content

Commit 0cc280d

Browse files
committed
added color for field value
1 parent 332da71 commit 0cc280d

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

src/menu.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,14 @@ v2.1 - Add full support of SetPosition(x,y) to move the menu inside the screen (
125125
:text(text),action(action),enabled(true) {}
126126
inline void enable() {enabled=true;}
127127
inline void disable() {enabled=false;}
128+
virtual void printName(menuOut& p) {print_P(p,text);}
129+
virtual void printValue(menuOut& p) {}
130+
virtual void printUnit(menuOut& p) {}
128131
virtual void printTo(menuOut& p) {
129-
//p.print(text);
130-
print_P(p,text);
131-
}
132+
printName(p);
133+
printValue(p);
134+
printUnit(p);
135+
}
132136
virtual bool needRedraw(menuOut&,bool) {return false;}
133137
virtual promptFeedback activate(menuOut& p,Stream&c,bool) {
134138
return action(*this,p,c);

src/menuFields.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,17 @@ v2.0 - Calling action on every elements
6868
return true;
6969
}*/
7070
}
71-
virtual void printTo(menuOut& p) {
71+
virtual void printName(menuOut& p) {
7272
print_P(p,text);
7373
p.print(activeNode==this?(tunning?'>':':'):' ');
74-
p.print(value);
75-
print_P(p,units);
74+
}
75+
virtual void printValue(menuOut& p) {p.print(value);}
76+
virtual void printUnit(menuOut& p) {print_P(p,units);}
77+
virtual void printTo(menuOut& p) {
78+
printName(p);
79+
p.print(activeNode==this?(tunning?'>':':'):' ');
80+
printValue(p);
81+
printUnit(p);
7682
}
7783
void clamp() {
7884
if (value<low) value=low;

src/menuU8G.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ www.r-site.net
2727
unsigned char disabledColor;
2828
unsigned char enabledColorHi;
2929
unsigned char disabledColorHi;
30+
unsigned char valueColor;
31+
unsigned char valueColorHi;
3032

3133
U8GLIB& gfx;
3234
menuU8G(
@@ -35,6 +37,8 @@ www.r-site.net
3537
unsigned char bgColor=0,
3638
unsigned char enabledColor=2,
3739
unsigned char disabledColor=1,
40+
unsigned char valueColor=2,
41+
unsigned char valueColorHi=2,
3842
uint8_t resX = 7,//6 font width
3943
uint8_t resY = 9 //9 font height + 2 pixels of spacing
4044
)
@@ -45,6 +49,8 @@ www.r-site.net
4549
hiliteColor(hiliteColor),
4650
enabledColorHi(bgColor),
4751
disabledColorHi(bgColor),
52+
valueColor(enabledColor),
53+
valueColorHi(enabledColor),
4854
menuOut(gfx.getWidth()/resX,gfx.getHeight()/resY,resX,resY)
4955
{
5056
// Small typefaces used to draw the menu, do not forget to report resX and resY
@@ -77,7 +83,11 @@ www.r-site.net
7783
gfx.drawBox(posX*resX,posY*resY,maxX*resX,resY);
7884
gfx.setColorIndex(selected?(o.enabled?enabledColorHi:disabledColorHi):(o.enabled?enabledColor:disabledColor));
7985
setCursor(posX,posY+1); //+1 compensate the height of the font and the way how U8Glib works
80-
o.printTo(*this);
86+
//o.printTo(*this);
87+
o.printName(*this);
88+
gfx.setColorIndex(selected?valueColorHi:valueColor);
89+
o.printValue(*this);
90+
o.printUnit(*this);
8191
}
8292
virtual void printMenu(menu& m,bool drawExit) {
8393
//Serial<<"printing menu "<<m<<" top:"<<top<<endl;

0 commit comments

Comments
 (0)