My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

menu_main.cpp 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2019 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. // Main Menu
  24. //
  25. #include "../../inc/MarlinConfigPre.h"
  26. #if HAS_LCD_MENU
  27. #include "menu.h"
  28. #include "../../module/temperature.h"
  29. #include "../../gcode/queue.h"
  30. #include "../../module/printcounter.h"
  31. #include "../../module/stepper.h"
  32. #if ENABLED(POWER_LOSS_RECOVERY)
  33. #include "../../feature/power_loss_recovery.h"
  34. #endif
  35. #if ENABLED(SDSUPPORT)
  36. #include "../../sd/cardreader.h"
  37. #endif
  38. #if ENABLED(HOST_ACTION_COMMANDS)
  39. #include "../../feature/host_actions.h"
  40. #endif
  41. #define MACHINE_CAN_STOP (ENABLED(SDSUPPORT) || ENABLED(HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
  42. #define MACHINE_CAN_PAUSE (ENABLED(SDSUPPORT) || ENABLED(HOST_PROMPT_SUPPORT) || ENABLED(PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
  43. #if MACHINE_CAN_PAUSE
  44. void lcd_pause_job() {
  45. #if ENABLED(POWER_LOSS_RECOVERY)
  46. if (recovery.enabled) recovery.save(true, false);
  47. #endif
  48. #if ENABLED(HOST_PROMPT_SUPPORT)
  49. host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("UI Pause"), PSTR("Resume"));
  50. #endif
  51. #if ENABLED(PARK_HEAD_ON_PAUSE)
  52. lcd_advanced_pause_show_message(ADVANCED_PAUSE_MESSAGE_INIT, ADVANCED_PAUSE_MODE_PAUSE_PRINT); // Show message immediately to let user know about pause in progress
  53. enqueue_and_echo_commands_P(PSTR("M25 P\nM24"));
  54. #elif ENABLED(SDSUPPORT)
  55. enqueue_and_echo_commands_P(PSTR("M25"));
  56. #elif defined(ACTION_ON_PAUSE)
  57. host_action_pause();
  58. #endif
  59. planner.synchronize();
  60. }
  61. void lcd_resume() {
  62. #if ENABLED(SDSUPPORT)
  63. if (card.isPaused()) enqueue_and_echo_commands_P(PSTR("M24"));
  64. #endif
  65. #ifdef ACTION_ON_RESUME
  66. host_action_resume();
  67. #endif
  68. }
  69. #endif // MACHINE_CAN_PAUSE
  70. #if MACHINE_CAN_STOP
  71. void lcd_abort_job() {
  72. #if ENABLED(SDSUPPORT)
  73. wait_for_heatup = wait_for_user = false;
  74. card.flag.abort_sd_printing = true;
  75. #endif
  76. #ifdef ACTION_ON_CANCEL
  77. host_action_cancel();
  78. #endif
  79. #if ENABLED(HOST_PROMPT_SUPPORT)
  80. host_prompt_open(PROMPT_INFO, PSTR("UI Abort"));
  81. #endif
  82. ui.set_status_P(PSTR(MSG_PRINT_ABORTED), -1);
  83. ui.return_to_status();
  84. }
  85. void menu_abort_confirm() {
  86. START_MENU();
  87. MENU_BACK(MSG_MAIN);
  88. MENU_ITEM(function, MSG_STOP_PRINT, lcd_abort_job);
  89. END_MENU();
  90. }
  91. #endif // MACHINE_CAN_STOP
  92. #if ENABLED(PRUSA_MMU2)
  93. #include "../../lcd/menu/menu_mmu2.h"
  94. #endif
  95. void menu_tune();
  96. void menu_motion();
  97. void menu_temperature();
  98. void menu_configuration();
  99. void menu_user();
  100. void menu_temp_e0_filament_change();
  101. void menu_change_filament();
  102. void menu_info();
  103. void menu_led();
  104. #if ENABLED(MIXING_EXTRUDER)
  105. void menu_mixer();
  106. #endif
  107. #if HAS_SERVICE_INTERVALS && ENABLED(PRINTCOUNTER)
  108. #if SERVICE_INTERVAL_1 > 0
  109. void menu_service1();
  110. #endif
  111. #if SERVICE_INTERVAL_2 > 0
  112. void menu_service2();
  113. #endif
  114. #if SERVICE_INTERVAL_3 > 0
  115. void menu_service3();
  116. #endif
  117. #endif
  118. void menu_main() {
  119. START_MENU();
  120. MENU_BACK(MSG_WATCH);
  121. const bool busy = printer_busy()
  122. #if ENABLED(SDSUPPORT)
  123. , card_detected = card.isDetected()
  124. , card_open = card_detected && card.isFileOpen()
  125. #endif
  126. ;
  127. if (busy) {
  128. #if MACHINE_CAN_PAUSE
  129. MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_pause_job);
  130. #endif
  131. #if MACHINE_CAN_STOP
  132. MENU_ITEM(submenu, MSG_STOP_PRINT, menu_abort_confirm);
  133. #endif
  134. MENU_ITEM(submenu, MSG_TUNE, menu_tune);
  135. }
  136. else {
  137. #if !HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
  138. //
  139. // Autostart
  140. //
  141. #if ENABLED(MENU_ADDAUTOSTART)
  142. if (!busy) MENU_ITEM(function, MSG_AUTOSTART, card.beginautostart);
  143. #endif
  144. if (card_detected) {
  145. if (!card_open) {
  146. MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
  147. #if !PIN_EXISTS(SD_DETECT)
  148. MENU_ITEM(gcode, MSG_CHANGE_SDCARD, PSTR("M21")); // SD-card changed by user
  149. #endif
  150. }
  151. }
  152. else {
  153. #if !PIN_EXISTS(SD_DETECT)
  154. MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually init SD-card
  155. #endif
  156. MENU_ITEM(function, MSG_NO_CARD, NULL);
  157. }
  158. #endif // !HAS_ENCODER_WHEEL && SDSUPPORT
  159. #if MACHINE_CAN_PAUSE
  160. const bool paused = (print_job_timer.isPaused()
  161. #if ENABLED(SDSUPPORT)
  162. || card.isPaused()
  163. #endif
  164. );
  165. if (paused) MENU_ITEM(function, MSG_RESUME_PRINT, lcd_resume);
  166. #endif
  167. MENU_ITEM(submenu, MSG_MOTION, menu_motion);
  168. }
  169. MENU_ITEM(submenu, MSG_TEMPERATURE, menu_temperature);
  170. #if ENABLED(MIXING_EXTRUDER)
  171. MENU_ITEM(submenu, MSG_MIXER, menu_mixer);
  172. #endif
  173. #if ENABLED(MMU2_MENUS)
  174. if (!busy) MENU_ITEM(submenu, MSG_MMU2_MENU, menu_mmu2);
  175. #endif
  176. MENU_ITEM(submenu, MSG_CONFIGURATION, menu_configuration);
  177. #if ENABLED(CUSTOM_USER_MENUS)
  178. MENU_ITEM(submenu, MSG_USER_MENU, menu_user);
  179. #endif
  180. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  181. #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  182. if (thermalManager.targetHotEnoughToExtrude(active_extruder))
  183. MENU_ITEM(gcode, MSG_FILAMENTCHANGE, PSTR("M600 B0"));
  184. else
  185. MENU_ITEM(submenu, MSG_FILAMENTCHANGE, menu_temp_e0_filament_change);
  186. #else
  187. MENU_ITEM(submenu, MSG_FILAMENTCHANGE, menu_change_filament);
  188. #endif
  189. #endif
  190. #if ENABLED(LCD_INFO_MENU)
  191. MENU_ITEM(submenu, MSG_INFO_MENU, menu_info);
  192. #endif
  193. #if ENABLED(LED_CONTROL_MENU)
  194. MENU_ITEM(submenu, MSG_LED_CONTROL, menu_led);
  195. #endif
  196. //
  197. // Switch power on/off
  198. //
  199. #if HAS_POWER_SWITCH
  200. if (powersupply_on)
  201. MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
  202. else
  203. MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
  204. #endif
  205. #if HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
  206. //
  207. // Autostart
  208. //
  209. #if ENABLED(MENU_ADDAUTOSTART)
  210. if (!busy) MENU_ITEM(function, MSG_AUTOSTART, card.beginautostart);
  211. #endif
  212. if (card_detected) {
  213. if (!card_open) {
  214. MENU_ITEM(submenu, MSG_CARD_MENU, menu_sdcard);
  215. #if !PIN_EXISTS(SD_DETECT)
  216. MENU_ITEM(gcode, MSG_CHANGE_SDCARD, PSTR("M21")); // SD-card changed by user
  217. #endif
  218. }
  219. }
  220. else {
  221. #if !PIN_EXISTS(SD_DETECT)
  222. MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually init SD-card
  223. #endif
  224. MENU_ITEM(function, MSG_NO_CARD, NULL);
  225. }
  226. #endif // HAS_ENCODER_WHEEL && SDSUPPORT
  227. #if HAS_SERVICE_INTERVALS && ENABLED(PRINTCOUNTER)
  228. #if SERVICE_INTERVAL_1 > 0
  229. MENU_ITEM(submenu, SERVICE_NAME_1, menu_service1);
  230. #endif
  231. #if SERVICE_INTERVAL_2 > 0
  232. MENU_ITEM(submenu, SERVICE_NAME_2, menu_service2);
  233. #endif
  234. #if SERVICE_INTERVAL_3 > 0
  235. MENU_ITEM(submenu, SERVICE_NAME_3, menu_service3);
  236. #endif
  237. #endif
  238. END_MENU();
  239. }
  240. #endif // HAS_LCD_MENU