Просмотр исходного кода

Use STATIC_ITEM for LCD message display

Scott Lahteine 8 лет назад
Родитель
Сommit
982f10e6a0

+ 4
- 5
Marlin/dogm_lcd_implementation.h Просмотреть файл

@@ -473,14 +473,14 @@ 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
-#if ENABLED(LCD_INFO_MENU)
476
+#if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
477 477
 
478
-  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, const char* valstr=NULL, bool center=false) {
478
+  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, const char* valstr=NULL, bool center=true) {
479 479
     char c;
480 480
     int8_t n = LCD_WIDTH;
481 481
     u8g.setPrintPos(0, (row + 1) * (DOG_CHAR_HEIGHT));
482 482
     u8g.setColorIndex(1); // normal text
483
-    if (center) {
483
+    if (center && !valstr) {
484 484
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
485 485
       while (--pad >= 0) { lcd_print(' '); n--; }
486 486
     }
@@ -495,10 +495,9 @@ static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
495 495
     while (n-- > 0) lcd_print(' ');
496 496
   }
497 497
 
498
-#endif // LCD_INFO_MENU
498
+#endif // LCD_INFO_MENU || FILAMENT_CHANGE_FEATURE
499 499
 
500 500
 static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
501
-  UNUSED(pstr);
502 501
   UNUSED(pre_char);
503 502
 
504 503
   char c;

+ 51
- 28
Marlin/ultralcd.cpp Просмотреть файл

@@ -2048,9 +2048,6 @@ static void lcd_status_screen() {
2048 2048
 
2049 2049
   #if ENABLED(FILAMENT_CHANGE_FEATURE)
2050 2050
 
2051
-    static void lcd_filament_change_nothing() {
2052
-    }
2053
-    
2054 2051
     static void lcd_filament_change_resume_print() {
2055 2052
       filament_change_menu_response = FILAMENT_CHANGE_RESPONSE_RESUME_PRINT;
2056 2053
       lcdDrawUpdate = 2;
@@ -2063,7 +2060,9 @@ static void lcd_status_screen() {
2063 2060
 
2064 2061
     static void lcd_filament_change_option_menu() {
2065 2062
       START_MENU();
2066
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_HEADER, lcd_filament_change_nothing);
2063
+      #if LCD_HEIGHT > 2
2064
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_OPTION_HEADER);
2065
+      #endif
2067 2066
       MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_RESUME, lcd_filament_change_resume_print);
2068 2067
       MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_EXTRUDE, lcd_filament_change_extrude_more);
2069 2068
       END_MENU();
@@ -2071,55 +2070,79 @@ static void lcd_status_screen() {
2071 2070
 
2072 2071
     static void lcd_filament_change_init_message() {
2073 2072
       START_MENU();
2074
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_HEADER, lcd_filament_change_nothing);
2075
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_INIT_1, lcd_filament_change_nothing);
2076
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_INIT_2, lcd_filament_change_nothing);
2077
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_INIT_3, lcd_filament_change_nothing);
2073
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2074
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_1);
2075
+      #ifdef MSG_FILAMENT_CHANGE_INIT_2
2076
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_2);
2077
+      #endif
2078
+      #ifdef MSG_FILAMENT_CHANGE_INIT_3
2079
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_3);
2080
+      #endif
2078 2081
       END_MENU();
2079 2082
     }
2080 2083
 
2081 2084
     static void lcd_filament_change_unload_message() {
2082 2085
       START_MENU();
2083
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_HEADER, lcd_filament_change_nothing);
2084
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_UNLOAD_1, lcd_filament_change_nothing);
2085
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_UNLOAD_2, lcd_filament_change_nothing);
2086
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_UNLOAD_3, lcd_filament_change_nothing);
2086
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2087
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_1);
2088
+      #ifdef MSG_FILAMENT_CHANGE_UNLOAD_2
2089
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_2);
2090
+      #endif
2091
+      #ifdef MSG_FILAMENT_CHANGE_UNLOAD_3
2092
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_3);
2093
+      #endif
2087 2094
       END_MENU();
2088 2095
     }
2089 2096
 
2090 2097
     static void lcd_filament_change_insert_message() {
2091 2098
       START_MENU();
2092
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_HEADER, lcd_filament_change_nothing);
2093
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_INSERT_1, lcd_filament_change_nothing);
2094
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_INSERT_2, lcd_filament_change_nothing);
2095
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_INSERT_3, lcd_filament_change_nothing);
2099
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2100
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_1);
2101
+      #ifdef MSG_FILAMENT_CHANGE_INSERT_2
2102
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_2);
2103
+      #endif
2104
+      #ifdef MSG_FILAMENT_CHANGE_INSERT_3
2105
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_3);
2106
+      #endif
2096 2107
       END_MENU();
2097 2108
     }
2098 2109
 
2099 2110
     static void lcd_filament_change_load_message() {
2100 2111
       START_MENU();
2101
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_HEADER, lcd_filament_change_nothing);
2102
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_LOAD_1, lcd_filament_change_nothing);
2103
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_LOAD_2, lcd_filament_change_nothing);
2104
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_LOAD_3, lcd_filament_change_nothing);
2112
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2113
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_1);
2114
+      #ifdef MSG_FILAMENT_CHANGE_LOAD_2
2115
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_2);
2116
+      #endif
2117
+      #ifdef MSG_FILAMENT_CHANGE_LOAD_3
2118
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_3);
2119
+      #endif
2105 2120
       END_MENU();
2106 2121
     }
2107 2122
 
2108 2123
     static void lcd_filament_change_extrude_message() {
2109 2124
       START_MENU();
2110
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_HEADER, lcd_filament_change_nothing);
2111
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_EXTRUDE_1, lcd_filament_change_nothing);
2112
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_EXTRUDE_2, lcd_filament_change_nothing);
2113
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_EXTRUDE_3, lcd_filament_change_nothing);
2125
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2126
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_1);
2127
+      #ifdef MSG_FILAMENT_CHANGE_EXTRUDE_2
2128
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_2);
2129
+      #endif
2130
+      #ifdef MSG_FILAMENT_CHANGE_EXTRUDE_3
2131
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_3);
2132
+      #endif
2114 2133
       END_MENU();
2115 2134
     }
2116 2135
 
2117 2136
     static void lcd_filament_change_resume_message() {
2118 2137
       START_MENU();
2119
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_HEADER, lcd_filament_change_nothing);
2120
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_RESUME_1, lcd_filament_change_nothing);
2121
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_RESUME_2, lcd_filament_change_nothing);
2122
-      MENU_ITEM(function, MSG_FILAMENT_CHANGE_RESUME_3, lcd_filament_change_nothing);
2138
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2139
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_1);
2140
+      #ifdef MSG_FILAMENT_CHANGE_RESUME_2
2141
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_2);
2142
+      #endif
2143
+      #ifdef MSG_FILAMENT_CHANGE_RESUME_3
2144
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_3);
2145
+      #endif
2123 2146
       END_MENU();
2124 2147
     }
2125 2148
   

+ 3
- 3
Marlin/ultralcd_implementation_hitachi_HD44780.h Просмотреть файл

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

Загрузка…
Отмена
Сохранить