@@ -42,6 +42,8 @@ class LcdMenu {
4242
4343 int _leftArrow = 3 ;
4444 int _rightArrow = 4 ;
45+ int _upArrow = 5 ;
46+ int _downArrow = 6 ;
4547
4648 public:
4749 // Create a new menu, using the given LCD screen and using the given number of LCD display columns
@@ -54,6 +56,8 @@ class LcdMenu {
5456 _columns = cols;
5557 lcd->createChar (_leftArrow, LeftArr);
5658 lcd->createChar (_rightArrow, RightArr);
59+ lcd->createChar (_upArrow, UpArr);
60+ lcd->createChar (_downArrow, DownArr);
5761 }
5862
5963 // Find a menu item by its ID
@@ -90,6 +94,11 @@ class LcdMenu {
9094 _activeId = id;
9195 }
9296
97+ // Pass throu utility function
98+ void setCursor (int col, int row){
99+ _lcd->setCursor (col,row);
100+ }
101+
93102 // Go to the next menu item from currently active one
94103 void setNextActive () {
95104 // If the last item is active, go to the first.
@@ -137,7 +146,7 @@ class LcdMenu {
137146 // For non-active items, pad with a space.
138147 itemString = " " + item->display () + " " ;
139148 }
140-
149+
141150 menuString += itemString;
142151 offset += itemString.length ();
143152 item = item->nextItem ();
@@ -159,11 +168,11 @@ class LcdMenu {
159168 while (displayString.length () < _columns) {
160169 displayString += " " ;
161170 }
162-
171+
163172 printMenu (displayString);
164173 }
165174
166- // Prints a string to the LCD at the current cursor position, using a printf() style call
175+ // Prints a string to the LCD at the current cursor position, using a printf() style call
167176 void printMenuArg (const char * input, ...) {
168177 va_list args;
169178 va_start (args, input);
@@ -177,6 +186,12 @@ class LcdMenu {
177186 else if (*i == ' <' ) {
178187 _lcd->write (_leftArrow);
179188 }
189+ else if (*i == ' ^' ) {
190+ _lcd->write (_upArrow);
191+ }
192+ else if (*i == ' ~' ) {
193+ _lcd->write (_downArrow);
194+ }
180195 else {
181196 _lcd->print (*i);
182197 }
@@ -189,7 +204,7 @@ class LcdMenu {
189204 case ' c' :
190205 {
191206 byte b = (byte) (va_arg (args, int ) && 0x00FF );
192- _lcd->write (( byte)b );
207+ _lcd->write (byte (b) );
193208 }
194209 break ;
195210 case ' s' : _lcd->print (va_arg (args, char *)); break ;
@@ -200,7 +215,7 @@ class LcdMenu {
200215 }
201216 va_end (args);
202217
203- // Since we don't know exaclty how many characters teh var_args printed we know the
218+ // Since we don't know exaclty how many characters teh var_args printed we know the
204219 // least count printed and just pad from that (extra spaces are ignored by the LCD).
205220 while (leastCount < _columns) {
206221 _lcd->print (" " );
@@ -219,6 +234,12 @@ class LcdMenu {
219234 else if (line[i] == ' <' ) {
220235 _lcd->write (_leftArrow);
221236 }
237+ else if (line[i] == ' ^' ) {
238+ _lcd->write (_upArrow);
239+ }
240+ else if (line[i] == ' ~' ) {
241+ _lcd->write (_downArrow);
242+ }
222243 else {
223244 _lcd->print (line[i]);
224245 }
@@ -255,4 +276,25 @@ class LcdMenu {
255276 B00000
256277 };
257278
279+ byte UpArr[8 ] = {
280+ B00100,
281+ B01110,
282+ B11111,
283+ B00100,
284+ B00100,
285+ B00100,
286+ B00100,
287+ B00100
288+ };
289+
290+ byte DownArr[8 ] = {
291+ B000100,
292+ B000100,
293+ B000100,
294+ B000100,
295+ B000100,
296+ B011111,
297+ B001110,
298+ B000100
299+ };
258300};
0 commit comments