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 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. #include "../../sd/cardreader.h"
  33. #if HAS_GAMES && DISABLED(LCD_INFO_MENU)
  34. #include "game/game.h"
  35. #endif
  36. #define MACHINE_CAN_STOP (EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
  37. #define MACHINE_CAN_PAUSE (ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
  38. #if MACHINE_CAN_STOP
  39. void menu_abort_confirm() {
  40. do_select_screen(GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK), ui.abort_print, ui.goto_previous_screen, GET_TEXT(MSG_STOP_PRINT), nullptr, PSTR("?"));
  41. }
  42. #endif // MACHINE_CAN_STOP
  43. #if ENABLED(PRUSA_MMU2)
  44. #include "../../lcd/menu/menu_mmu2.h"
  45. #endif
  46. void menu_tune();
  47. void menu_motion();
  48. void menu_temperature();
  49. void menu_configuration();
  50. #if ENABLED(CUSTOM_USER_MENUS)
  51. void menu_user();
  52. #endif
  53. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  54. void _menu_temp_filament_op(const PauseMode, const int8_t);
  55. void menu_change_filament();
  56. #endif
  57. #if ENABLED(LCD_INFO_MENU)
  58. void menu_info();
  59. #endif
  60. #if ENABLED(LED_CONTROL_MENU)
  61. void menu_led();
  62. #endif
  63. #if HAS_CUTTER
  64. #include "../../feature/spindle_laser.h"
  65. void menu_spindle_laser();
  66. #endif
  67. #if ENABLED(MIXING_EXTRUDER)
  68. void menu_mixer();
  69. #endif
  70. #if HAS_SERVICE_INTERVALS
  71. #if SERVICE_INTERVAL_1 > 0
  72. void menu_service1();
  73. #endif
  74. #if SERVICE_INTERVAL_2 > 0
  75. void menu_service2();
  76. #endif
  77. #if SERVICE_INTERVAL_3 > 0
  78. void menu_service3();
  79. #endif
  80. #endif
  81. void menu_main() {
  82. START_MENU();
  83. BACK_ITEM(MSG_WATCH);
  84. const bool busy = printingIsActive()
  85. #if ENABLED(SDSUPPORT)
  86. , card_detected = card.isMounted()
  87. , card_open = card_detected && card.isFileOpen()
  88. #endif
  89. ;
  90. if (busy) {
  91. #if MACHINE_CAN_PAUSE
  92. ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
  93. #endif
  94. #if MACHINE_CAN_STOP
  95. SUBMENU(MSG_STOP_PRINT, menu_abort_confirm);
  96. #endif
  97. SUBMENU(MSG_TUNE, menu_tune);
  98. }
  99. else {
  100. #if !HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
  101. //
  102. // Autostart
  103. //
  104. #if ENABLED(MENU_ADDAUTOSTART)
  105. if (!busy) ACTION_ITEM(MSG_AUTOSTART, card.beginautostart);
  106. #endif
  107. if (card_detected) {
  108. if (!card_open) {
  109. SUBMENU(MSG_MEDIA_MENU, menu_media);
  110. MENU_ITEM(gcode,
  111. #if PIN_EXISTS(SD_DETECT)
  112. MSG_CHANGE_MEDIA, PSTR("M21")
  113. #else
  114. MSG_RELEASE_MEDIA, PSTR("M22")
  115. #endif
  116. );
  117. }
  118. }
  119. else {
  120. #if PIN_EXISTS(SD_DETECT)
  121. ACTION_ITEM(MSG_NO_MEDIA, nullptr);
  122. #else
  123. GCODES_ITEM(MSG_INIT_MEDIA, PSTR("M21"));
  124. ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
  125. #endif
  126. }
  127. #endif // !HAS_ENCODER_WHEEL && SDSUPPORT
  128. #if MACHINE_CAN_PAUSE
  129. if (printingIsPaused()) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print);
  130. #endif
  131. SUBMENU(MSG_MOTION, menu_motion);
  132. }
  133. #if HAS_CUTTER
  134. SUBMENU(MSG_CUTTER(MENU), menu_spindle_laser);
  135. #endif
  136. SUBMENU(MSG_TEMPERATURE, menu_temperature);
  137. #if ENABLED(MIXING_EXTRUDER)
  138. SUBMENU(MSG_MIXER, menu_mixer);
  139. #endif
  140. #if ENABLED(MMU2_MENUS)
  141. if (!busy) SUBMENU(MSG_MMU2_MENU, menu_mmu2);
  142. #endif
  143. SUBMENU(MSG_CONFIGURATION, menu_configuration);
  144. #if ENABLED(CUSTOM_USER_MENUS)
  145. #ifdef CUSTOM_USER_MENU_TITLE
  146. #undef MSG_USER_MENU
  147. #define MSG_USER_MENU CUSTOM_USER_MENU_TITLE
  148. #endif
  149. SUBMENU(MSG_USER_MENU, menu_user);
  150. #endif
  151. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  152. #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  153. if (thermalManager.targetHotEnoughToExtrude(active_extruder))
  154. GCODES_ITEM(MSG_FILAMENTCHANGE, PSTR("M600 B0"));
  155. else
  156. SUBMENU(MSG_FILAMENTCHANGE, [](){ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 0); });
  157. #else
  158. SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament);
  159. #endif
  160. #endif
  161. #if ENABLED(LCD_INFO_MENU)
  162. SUBMENU(MSG_INFO_MENU, menu_info);
  163. #endif
  164. #if ENABLED(LED_CONTROL_MENU)
  165. SUBMENU(MSG_LED_CONTROL, menu_led);
  166. #endif
  167. //
  168. // Switch power on/off
  169. //
  170. #if HAS_POWER_SWITCH
  171. if (powersupply_on)
  172. GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81"));
  173. else
  174. GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80"));
  175. #endif
  176. #if HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
  177. //
  178. // Autostart
  179. //
  180. #if ENABLED(MENU_ADDAUTOSTART)
  181. if (!busy) ACTION_ITEM(MSG_AUTOSTART, card.beginautostart);
  182. #endif
  183. if (card_detected) {
  184. if (!card_open) {
  185. MENU_ITEM(gcode,
  186. #if PIN_EXISTS(SD_DETECT)
  187. MSG_CHANGE_MEDIA, PSTR("M21")
  188. #else
  189. MSG_RELEASE_MEDIA, PSTR("M22")
  190. #endif
  191. );
  192. SUBMENU(MSG_MEDIA_MENU, menu_media);
  193. }
  194. }
  195. else {
  196. #if PIN_EXISTS(SD_DETECT)
  197. ACTION_ITEM(MSG_NO_MEDIA, nullptr);
  198. #else
  199. GCODES_ITEM(MSG_INIT_MEDIA, PSTR("M21"));
  200. ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
  201. #endif
  202. }
  203. #endif // HAS_ENCODER_WHEEL && SDSUPPORT
  204. #if HAS_SERVICE_INTERVALS
  205. #if SERVICE_INTERVAL_1 > 0
  206. SUBMENU_P(PSTR(SERVICE_NAME_1), menu_service1);
  207. #endif
  208. #if SERVICE_INTERVAL_2 > 0
  209. SUBMENU_P(PSTR(SERVICE_NAME_2), menu_service2);
  210. #endif
  211. #if SERVICE_INTERVAL_3 > 0
  212. SUBMENU_P(PSTR(SERVICE_NAME_3), menu_service3);
  213. #endif
  214. #endif
  215. #if HAS_GAMES && DISABLED(LCD_INFO_MENU)
  216. #if ENABLED(GAMES_EASTER_EGG)
  217. SKIP_ITEM();
  218. SKIP_ITEM();
  219. #endif
  220. SUBMENU(MSG_GAMES, (
  221. #if HAS_GAME_MENU
  222. menu_game
  223. #elif ENABLED(MARLIN_BRICKOUT)
  224. brickout.enter_game
  225. #elif ENABLED(MARLIN_INVADERS)
  226. invaders.enter_game
  227. #elif ENABLED(MARLIN_SNAKE)
  228. snake.enter_game
  229. #elif ENABLED(MARLIN_MAZE)
  230. maze.enter_game
  231. #endif
  232. ));
  233. #endif
  234. END_MENU();
  235. }
  236. #endif // HAS_LCD_MENU