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.3KB

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