浏览代码

Move Main Menu to its own file

Scott Lahteine 6 年前
父节点
当前提交
829effc1fe
共有 2 个文件被更改,包括 166 次插入133 次删除
  1. 0
    133
      Marlin/src/lcd/menu/menu.cpp
  2. 166
    0
      Marlin/src/lcd/menu/menu_main.cpp

+ 0
- 133
Marlin/src/lcd/menu/menu.cpp 查看文件

256
 ///////////////// Menu Tree ////////////////
256
 ///////////////// Menu Tree ////////////////
257
 ////////////////////////////////////////////
257
 ////////////////////////////////////////////
258
 
258
 
259
-void menu_tune();
260
-void menu_movement();
261
-void menu_configuration();
262
-void menu_temperature();
263
 void menu_advanced_settings();
259
 void menu_advanced_settings();
264
 
260
 
265
 #if DISABLED(SLIM_LCD_MENUS)
261
 #if DISABLED(SLIM_LCD_MENUS)
277
   #endif
273
   #endif
278
   void menu_info_thermistors();
274
   void menu_info_thermistors();
279
   void menu_info_board();
275
   void menu_info_board();
280
-  void menu_info();
281
-#endif
282
-
283
-#if ENABLED(LED_CONTROL_MENU)
284
-  void menu_led();
285
 #endif
276
 #endif
286
 
277
 
287
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
278
 #if ENABLED(ADVANCED_PAUSE_FEATURE)
497
   line_to_current_z();
488
   line_to_current_z();
498
 }
489
 }
499
 
490
 
500
-#if ENABLED(SDSUPPORT)
501
-
502
-  void lcd_sdcard_pause() {
503
-    card.pauseSDPrint();
504
-    print_job_timer.pause();
505
-    #if ENABLED(PARK_HEAD_ON_PAUSE)
506
-      enqueue_and_echo_commands_P(PSTR("M125"));
507
-    #endif
508
-    lcd_reset_status();
509
-  }
510
-
511
-  void lcd_sdcard_resume() {
512
-    #if ENABLED(PARK_HEAD_ON_PAUSE)
513
-      enqueue_and_echo_commands_P(PSTR("M24"));
514
-    #else
515
-      card.startFileprint();
516
-      print_job_timer.start();
517
-    #endif
518
-    lcd_reset_status();
519
-  }
520
-
521
-  void lcd_sdcard_stop() {
522
-    wait_for_heatup = wait_for_user = false;
523
-    card.abort_sd_printing = true;
524
-    lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
525
-    lcd_return_to_status();
526
-  }
527
-
528
-#endif // SDSUPPORT
529
-
530
 #if ENABLED(POWER_LOSS_RECOVERY)
491
 #if ENABLED(POWER_LOSS_RECOVERY)
531
 
492
 
532
   static void lcd_power_loss_recovery_resume() {
493
   static void lcd_power_loss_recovery_resume() {
781
 
742
 
782
 /**
743
 /**
783
  *
744
  *
784
- * "Main" menu
785
- *
786
- */
787
-
788
-#if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
789
-
790
-  void lcd_autostart_sd() { card.beginautostart(); }
791
-
792
-#endif
793
-
794
-void menu_main() {
795
-  START_MENU();
796
-  MENU_BACK(MSG_WATCH);
797
-
798
-  #if ENABLED(SDSUPPORT)
799
-    if (card.cardOK) {
800
-      if (card.isFileOpen()) {
801
-        if (card.sdprinting)
802
-          MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
803
-        else
804
-          MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
805
-        MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop);
806
-      }
807
-      else {
808
-        MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
809
-        #if !PIN_EXISTS(SD_DETECT)
810
-          MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21"));  // SD-card changed by user
811
-        #endif
812
-      }
813
-    }
814
-    else {
815
-      MENU_ITEM(submenu, MSG_NO_CARD, menu_sdcard);
816
-      #if !PIN_EXISTS(SD_DETECT)
817
-        MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
818
-      #endif
819
-    }
820
-  #endif // SDSUPPORT
821
-
822
-  const bool busy = printer_busy();
823
-  if (busy)
824
-    MENU_ITEM(submenu, MSG_TUNE, menu_tune);
825
-  else {
826
-    MENU_ITEM(submenu, MSG_MOTION, menu_movement);
827
-    MENU_ITEM(submenu, MSG_TEMPERATURE, menu_temperature);
828
-  }
829
-
830
-  MENU_ITEM(submenu, MSG_CONFIGURATION, menu_configuration);
831
-
832
-  #if ENABLED(CUSTOM_USER_MENUS)
833
-    MENU_ITEM(submenu, MSG_USER_MENU, _menu_user);
834
-  #endif
835
-
836
-  #if ENABLED(ADVANCED_PAUSE_FEATURE)
837
-    #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
838
-      if (thermalManager.targetHotEnoughToExtrude(active_extruder))
839
-        MENU_ITEM(gcode, MSG_FILAMENTCHANGE, PSTR("M600 B0"));
840
-      else
841
-        MENU_ITEM(submenu, MSG_FILAMENTCHANGE, menu_temp_e0_filament_change);
842
-    #else
843
-      MENU_ITEM(submenu, MSG_FILAMENTCHANGE, menu_change_filament);
844
-    #endif
845
-  #endif
846
-
847
-  #if ENABLED(LCD_INFO_MENU)
848
-    MENU_ITEM(submenu, MSG_INFO_MENU, menu_info);
849
-  #endif
850
-
851
-  #if ENABLED(LED_CONTROL_MENU)
852
-    MENU_ITEM(submenu, MSG_LED_CONTROL, menu_led);
853
-  #endif
854
-
855
-  //
856
-  // Switch power on/off
857
-  //
858
-  #if HAS_POWER_SWITCH
859
-    if (powersupply_on)
860
-      MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
861
-    else
862
-      MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
863
-  #endif
864
-
865
-  //
866
-  // Autostart
867
-  //
868
-  #if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
869
-    if (!busy)
870
-      MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
871
-  #endif
872
-
873
-  END_MENU();
874
-}
875
-
876
-/**
877
- *
878
  * "Tune" submenu items
745
  * "Tune" submenu items
879
  *
746
  *
880
  */
747
  */

+ 166
- 0
Marlin/src/lcd/menu/menu_main.cpp 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+//
24
+// Main Menu
25
+//
26
+
27
+#include "../../inc/MarlinConfigPre.h"
28
+
29
+#if HAS_LCD_MENU
30
+
31
+#include "menu.h"
32
+#include "../../module/temperature.h"
33
+
34
+#if ENABLED(SDSUPPORT)
35
+
36
+  #include "../../sd/cardreader.h"
37
+  #include "../../gcode/queue.h"
38
+  #include "../../module/printcounter.h"
39
+
40
+  void lcd_sdcard_pause() {
41
+    card.pauseSDPrint();
42
+    print_job_timer.pause();
43
+    #if ENABLED(PARK_HEAD_ON_PAUSE)
44
+      enqueue_and_echo_commands_P(PSTR("M125"));
45
+    #endif
46
+    lcd_reset_status();
47
+  }
48
+
49
+  void lcd_sdcard_resume() {
50
+    #if ENABLED(PARK_HEAD_ON_PAUSE)
51
+      enqueue_and_echo_commands_P(PSTR("M24"));
52
+    #else
53
+      card.startFileprint();
54
+      print_job_timer.start();
55
+    #endif
56
+    lcd_reset_status();
57
+  }
58
+
59
+  void lcd_sdcard_stop() {
60
+    wait_for_heatup = wait_for_user = false;
61
+    card.abort_sd_printing = true;
62
+    lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
63
+    lcd_return_to_status();
64
+  }
65
+
66
+  #if ENABLED(MENU_ADDAUTOSTART)
67
+
68
+    void lcd_autostart_sd() { card.beginautostart(); }
69
+
70
+  #endif
71
+
72
+#endif // SDSUPPORT
73
+
74
+void menu_tune();
75
+void menu_movement();
76
+void menu_temperature();
77
+void menu_configuration();
78
+void _menu_user();
79
+void menu_temp_e0_filament_change();
80
+void menu_change_filament();
81
+void menu_info();
82
+void menu_led();
83
+
84
+void menu_main() {
85
+  START_MENU();
86
+  MENU_BACK(MSG_WATCH);
87
+
88
+  #if ENABLED(SDSUPPORT)
89
+    if (card.cardOK) {
90
+      if (card.isFileOpen()) {
91
+        if (card.sdprinting)
92
+          MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause);
93
+        else
94
+          MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
95
+        MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop);
96
+      }
97
+      else {
98
+        MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
99
+        #if !PIN_EXISTS(SD_DETECT)
100
+          MENU_ITEM(gcode, MSG_CHANGE_SDCARD, PSTR("M21"));  // SD-card changed by user
101
+        #endif
102
+      }
103
+    }
104
+    else {
105
+      MENU_ITEM(submenu, MSG_NO_CARD, menu_sdcard);
106
+      #if !PIN_EXISTS(SD_DETECT)
107
+        MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
108
+      #endif
109
+    }
110
+  #endif // SDSUPPORT
111
+
112
+  const bool busy = printer_busy();
113
+  if (busy)
114
+    MENU_ITEM(submenu, MSG_TUNE, menu_tune);
115
+  else {
116
+    MENU_ITEM(submenu, MSG_MOTION, menu_movement);
117
+    MENU_ITEM(submenu, MSG_TEMPERATURE, menu_temperature);
118
+  }
119
+
120
+  MENU_ITEM(submenu, MSG_CONFIGURATION, menu_configuration);
121
+
122
+  #if ENABLED(CUSTOM_USER_MENUS)
123
+    MENU_ITEM(submenu, MSG_USER_MENU, _menu_user);
124
+  #endif
125
+
126
+  #if ENABLED(ADVANCED_PAUSE_FEATURE)
127
+    #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
128
+      if (thermalManager.targetHotEnoughToExtrude(active_extruder))
129
+        MENU_ITEM(gcode, MSG_FILAMENTCHANGE, PSTR("M600 B0"));
130
+      else
131
+        MENU_ITEM(submenu, MSG_FILAMENTCHANGE, menu_temp_e0_filament_change);
132
+    #else
133
+      MENU_ITEM(submenu, MSG_FILAMENTCHANGE, menu_change_filament);
134
+    #endif
135
+  #endif
136
+
137
+  #if ENABLED(LCD_INFO_MENU)
138
+    MENU_ITEM(submenu, MSG_INFO_MENU, menu_info);
139
+  #endif
140
+
141
+  #if ENABLED(LED_CONTROL_MENU)
142
+    MENU_ITEM(submenu, MSG_LED_CONTROL, menu_led);
143
+  #endif
144
+
145
+  //
146
+  // Switch power on/off
147
+  //
148
+  #if HAS_POWER_SWITCH
149
+    if (powersupply_on)
150
+      MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
151
+    else
152
+      MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
153
+  #endif
154
+
155
+  //
156
+  // Autostart
157
+  //
158
+  #if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
159
+    if (!busy)
160
+      MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
161
+  #endif
162
+
163
+  END_MENU();
164
+}
165
+
166
+#endif // HAS_LCD_MENU

正在加载...
取消
保存