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

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