Browse Source

Static menu items take an optional string, LJ by default

Scott Lahteine 8 years ago
parent
commit
439e78147d
2 changed files with 43 additions and 27 deletions
  1. 22
    14
      Marlin/dogm_lcd_implementation.h
  2. 21
    13
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 22
- 14
Marlin/dogm_lcd_implementation.h View File

@@ -473,21 +473,29 @@ static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
473 473
   u8g.setPrintPos((START_ROW) * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
474 474
 }
475 475
 
476
-static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true) {
477
-  char c;
478
-  uint8_t n = LCD_WIDTH;
479
-  u8g.setPrintPos(0, (row + 1) * (DOG_CHAR_HEIGHT));
480
-  u8g.setColorIndex(1); // normal text
481
-  if (center) {
482
-    int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
483
-    while (--pad >= 0) { lcd_print(' '); n--; }
484
-  }
485
-  while (c = pgm_read_byte(pstr)) {
486
-    n -= lcd_print(c);
487
-    pstr++;
476
+#if ENABLED(LCD_INFO_MENU)
477
+
478
+  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, const char* valstr=NULL, bool center=false) {
479
+    char c;
480
+    int8_t n = LCD_WIDTH;
481
+    u8g.setPrintPos(0, (row + 1) * (DOG_CHAR_HEIGHT));
482
+    u8g.setColorIndex(1); // normal text
483
+    if (center) {
484
+      int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
485
+      while (--pad >= 0) { lcd_print(' '); n--; }
486
+    }
487
+    while (c = pgm_read_byte(pstr)) {
488
+      n -= lcd_print(c);
489
+      pstr++;
490
+    }
491
+    if (valstr) {
492
+      lcd_print(valstr);
493
+      n -= lcd_strlen(valstr);
494
+    }
495
+    while (n-- > 0) lcd_print(' ');
488 496
   }
489
-  while (n--) lcd_print(' ');
490
-}
497
+
498
+#endif // LCD_INFO_MENU
491 499
 
492 500
 static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
493 501
   UNUSED(pstr);

+ 21
- 13
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

@@ -815,20 +815,28 @@ static void lcd_implementation_status_screen() {
815 815
   lcd_print(lcd_status_message);
816 816
 }
817 817
 
818
-static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true) {
819
-  char c;
820
-  uint8_t n = LCD_WIDTH;
821
-  lcd.setCursor(0, row);
822
-  if (center) {
823
-    int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
824
-    while (--pad >= 0) { lcd.print(' '); n--; }
825
-  }
826
-  while ((c = pgm_read_byte(pstr)) && n > 0) {
827
-    n -= lcd_print(c);
828
-    pstr++;
818
+#if ENABLED(LCD_INFO_MENU)
819
+
820
+  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, const char *valstr=NULL, bool center=true) {
821
+    char c;
822
+    int8_t n = LCD_WIDTH;
823
+    lcd.setCursor(0, row);
824
+    if (center) {
825
+      int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
826
+      while (--pad >= 0) { lcd.print(' '); n--; }
827
+    }
828
+    while ((c = pgm_read_byte(pstr)) && n > 0) {
829
+      n -= lcd_print(c);
830
+      pstr++;
831
+    }
832
+    if (valstr) {
833
+      lcd_print(valstr);
834
+      n -= lcd_strlen(valstr);
835
+    }
836
+    while (n-- > 0) lcd.print(' ');
829 837
   }
830
-  while (n--) lcd.print(' ');
831
-}
838
+
839
+#endif // LCD_INFO_MENU
832 840
 
833 841
 static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char post_char) {
834 842
   char c;

Loading…
Cancel
Save