My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

menu_main.cpp 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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_MARLINUI_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 ENABLED(PSU_CONTROL)
  34. #include "../../feature/power.h"
  35. #endif
  36. #if HAS_GAMES && DISABLED(LCD_INFO_MENU)
  37. #include "game/game.h"
  38. #endif
  39. #if EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL)
  40. #define MACHINE_CAN_STOP 1
  41. #endif
  42. #if ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE)
  43. #define MACHINE_CAN_PAUSE 1
  44. #endif
  45. #if ENABLED(MMU2_MENUS)
  46. #include "menu_mmu2.h"
  47. #endif
  48. #if ENABLED(PASSWORD_FEATURE)
  49. #include "../../feature/password/password.h"
  50. #endif
  51. #if (ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START)) || (ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION))
  52. #include "../../feature/host_actions.h"
  53. #endif
  54. #if ENABLED(GCODE_REPEAT_MARKERS)
  55. #include "../../feature/repeat.h"
  56. #endif
  57. void menu_tune();
  58. void menu_cancelobject();
  59. void menu_motion();
  60. void menu_temperature();
  61. void menu_configuration();
  62. #if HAS_POWER_MONITOR
  63. void menu_power_monitor();
  64. #endif
  65. #if ENABLED(MIXING_EXTRUDER)
  66. void menu_mixer();
  67. #endif
  68. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  69. void menu_change_filament();
  70. #endif
  71. #if ENABLED(LCD_INFO_MENU)
  72. void menu_info();
  73. #endif
  74. #if EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU)
  75. void menu_led();
  76. #endif
  77. #if HAS_CUTTER
  78. void menu_spindle_laser();
  79. #endif
  80. #if ENABLED(PREHEAT_SHORTCUT_MENU_ITEM)
  81. void menu_preheat_only();
  82. #endif
  83. #if HAS_MULTI_LANGUAGE
  84. void menu_language();
  85. #endif
  86. #if ENABLED(CUSTOM_MENU_MAIN)
  87. void _lcd_custom_menu_main_gcode(FSTR_P const fstr) {
  88. queue.inject(fstr);
  89. TERN_(CUSTOM_MENU_MAIN_SCRIPT_AUDIBLE_FEEDBACK, ui.completion_feedback());
  90. TERN_(CUSTOM_MENU_MAIN_SCRIPT_RETURN, ui.return_to_status());
  91. }
  92. void custom_menus_main() {
  93. START_MENU();
  94. BACK_ITEM(MSG_MAIN);
  95. #define HAS_CUSTOM_ITEM_MAIN(N) (defined(MAIN_MENU_ITEM_##N##_DESC) && defined(MAIN_MENU_ITEM_##N##_GCODE))
  96. #ifdef CUSTOM_MENU_MAIN_SCRIPT_DONE
  97. #define _DONE_SCRIPT "\n" CUSTOM_MENU_MAIN_SCRIPT_DONE
  98. #else
  99. #define _DONE_SCRIPT ""
  100. #endif
  101. #define GCODE_LAMBDA_MAIN(N) []{ _lcd_custom_menu_main_gcode(F(MAIN_MENU_ITEM_##N##_GCODE _DONE_SCRIPT)); }
  102. #define _CUSTOM_ITEM_MAIN(N) ACTION_ITEM_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), GCODE_LAMBDA_MAIN(N));
  103. #define _CUSTOM_ITEM_MAIN_CONFIRM(N) \
  104. SUBMENU_P(PSTR(MAIN_MENU_ITEM_##N##_DESC), []{ \
  105. MenuItem_confirm::confirm_screen( \
  106. GCODE_LAMBDA_MAIN(N), nullptr, \
  107. PSTR(MAIN_MENU_ITEM_##N##_DESC "?") \
  108. ); \
  109. })
  110. #define CUSTOM_ITEM_MAIN(N) do{ \
  111. constexpr char c = MAIN_MENU_ITEM_##N##_GCODE[strlen(MAIN_MENU_ITEM_##N##_GCODE) - 1]; \
  112. static_assert(c != '\n' && c != '\r', "MAIN_MENU_ITEM_" STRINGIFY(N) "_GCODE cannot have a newline at the end. Please remove it."); \
  113. if (ENABLED(MAIN_MENU_ITEM_##N##_CONFIRM)) \
  114. _CUSTOM_ITEM_MAIN_CONFIRM(N); \
  115. else \
  116. _CUSTOM_ITEM_MAIN(N); \
  117. }while(0)
  118. #if HAS_CUSTOM_ITEM_MAIN(1)
  119. CUSTOM_ITEM_MAIN(1);
  120. #endif
  121. #if HAS_CUSTOM_ITEM_MAIN(2)
  122. CUSTOM_ITEM_MAIN(2);
  123. #endif
  124. #if HAS_CUSTOM_ITEM_MAIN(3)
  125. CUSTOM_ITEM_MAIN(3);
  126. #endif
  127. #if HAS_CUSTOM_ITEM_MAIN(4)
  128. CUSTOM_ITEM_MAIN(4);
  129. #endif
  130. #if HAS_CUSTOM_ITEM_MAIN(5)
  131. CUSTOM_ITEM_MAIN(5);
  132. #endif
  133. #if HAS_CUSTOM_ITEM_MAIN(6)
  134. CUSTOM_ITEM_MAIN(6);
  135. #endif
  136. #if HAS_CUSTOM_ITEM_MAIN(7)
  137. CUSTOM_ITEM_MAIN(7);
  138. #endif
  139. #if HAS_CUSTOM_ITEM_MAIN(8)
  140. CUSTOM_ITEM_MAIN(8);
  141. #endif
  142. #if HAS_CUSTOM_ITEM_MAIN(9)
  143. CUSTOM_ITEM_MAIN(9);
  144. #endif
  145. #if HAS_CUSTOM_ITEM_MAIN(10)
  146. CUSTOM_ITEM_MAIN(10);
  147. #endif
  148. #if HAS_CUSTOM_ITEM_MAIN(11)
  149. CUSTOM_ITEM_MAIN(11);
  150. #endif
  151. #if HAS_CUSTOM_ITEM_MAIN(12)
  152. CUSTOM_ITEM_MAIN(12);
  153. #endif
  154. #if HAS_CUSTOM_ITEM_MAIN(13)
  155. CUSTOM_ITEM_MAIN(13);
  156. #endif
  157. #if HAS_CUSTOM_ITEM_MAIN(14)
  158. CUSTOM_ITEM_MAIN(14);
  159. #endif
  160. #if HAS_CUSTOM_ITEM_MAIN(15)
  161. CUSTOM_ITEM_MAIN(15);
  162. #endif
  163. #if HAS_CUSTOM_ITEM_MAIN(16)
  164. CUSTOM_ITEM_MAIN(16);
  165. #endif
  166. #if HAS_CUSTOM_ITEM_MAIN(17)
  167. CUSTOM_ITEM_MAIN(17);
  168. #endif
  169. #if HAS_CUSTOM_ITEM_MAIN(18)
  170. CUSTOM_ITEM_MAIN(18);
  171. #endif
  172. #if HAS_CUSTOM_ITEM_MAIN(19)
  173. CUSTOM_ITEM_MAIN(19);
  174. #endif
  175. #if HAS_CUSTOM_ITEM_MAIN(20)
  176. CUSTOM_ITEM_MAIN(20);
  177. #endif
  178. #if HAS_CUSTOM_ITEM_MAIN(21)
  179. CUSTOM_ITEM_MAIN(21);
  180. #endif
  181. #if HAS_CUSTOM_ITEM_MAIN(22)
  182. CUSTOM_ITEM_MAIN(22);
  183. #endif
  184. #if HAS_CUSTOM_ITEM_MAIN(23)
  185. CUSTOM_ITEM_MAIN(23);
  186. #endif
  187. #if HAS_CUSTOM_ITEM_MAIN(24)
  188. CUSTOM_ITEM_MAIN(24);
  189. #endif
  190. #if HAS_CUSTOM_ITEM_MAIN(25)
  191. CUSTOM_ITEM_MAIN(25);
  192. #endif
  193. END_MENU();
  194. }
  195. #endif // CUSTOM_MENU_MAIN
  196. void menu_main() {
  197. const bool busy = printingIsActive()
  198. #if ENABLED(SDSUPPORT)
  199. , card_detected = card.isMounted()
  200. , card_open = card_detected && card.isFileOpen()
  201. #endif
  202. ;
  203. START_MENU();
  204. BACK_ITEM(MSG_INFO_SCREEN);
  205. #if ENABLED(SDSUPPORT)
  206. #if !defined(MEDIA_MENU_AT_TOP) && !HAS_ENCODER_WHEEL
  207. #define MEDIA_MENU_AT_TOP
  208. #endif
  209. auto sdcard_menu_items = [&]{
  210. #if ENABLED(MENU_ADDAUTOSTART)
  211. ACTION_ITEM(MSG_RUN_AUTO_FILES, card.autofile_begin); // Run Auto Files
  212. #endif
  213. if (card_detected) {
  214. if (!card_open) {
  215. #if PIN_EXISTS(SD_DETECT)
  216. GCODES_ITEM(MSG_CHANGE_MEDIA, PSTR("M21")); // M21 Change Media
  217. #else // - or -
  218. ACTION_ITEM(MSG_RELEASE_MEDIA, []{ // M22 Release Media
  219. queue.inject(PSTR("M22"));
  220. #if ENABLED(TFT_COLOR_UI)
  221. // Menu display issue on item removal with multi language selection menu
  222. if (encoderTopLine > 0) encoderTopLine--;
  223. ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
  224. #endif
  225. });
  226. #endif
  227. SUBMENU(MSG_MEDIA_MENU, MEDIA_MENU_GATEWAY); // Media Menu (or Password First)
  228. }
  229. }
  230. else {
  231. #if PIN_EXISTS(SD_DETECT)
  232. ACTION_ITEM(MSG_NO_MEDIA, nullptr); // "No Media"
  233. #else
  234. GCODES_ITEM(MSG_ATTACH_MEDIA, PSTR("M21")); // M21 Attach Media
  235. #endif
  236. }
  237. };
  238. #endif
  239. if (busy) {
  240. #if MACHINE_CAN_PAUSE
  241. ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
  242. #endif
  243. #if MACHINE_CAN_STOP
  244. SUBMENU(MSG_STOP_PRINT, []{
  245. MenuItem_confirm::select_screen(
  246. GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
  247. ui.abort_print, nullptr,
  248. GET_TEXT(MSG_STOP_PRINT), (const char *)nullptr, PSTR("?")
  249. );
  250. });
  251. #endif
  252. #if ENABLED(GCODE_REPEAT_MARKERS)
  253. if (repeat.is_active())
  254. ACTION_ITEM(MSG_END_LOOPS, repeat.cancel);
  255. #endif
  256. SUBMENU(MSG_TUNE, menu_tune);
  257. #if ENABLED(CANCEL_OBJECTS) && DISABLED(SLIM_LCD_MENUS)
  258. SUBMENU(MSG_CANCEL_OBJECT, []{ editable.int8 = -1; ui.goto_screen(menu_cancelobject); });
  259. #endif
  260. }
  261. else {
  262. #if BOTH(SDSUPPORT, MEDIA_MENU_AT_TOP)
  263. sdcard_menu_items();
  264. #endif
  265. if (TERN0(MACHINE_CAN_PAUSE, printingIsPaused()))
  266. ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print);
  267. #if ENABLED(HOST_START_MENU_ITEM) && defined(ACTION_ON_START)
  268. ACTION_ITEM(MSG_HOST_START_PRINT, hostui.start);
  269. #endif
  270. #if ENABLED(PREHEAT_SHORTCUT_MENU_ITEM)
  271. SUBMENU(MSG_PREHEAT_CUSTOM, menu_preheat_only);
  272. #endif
  273. SUBMENU(MSG_MOTION, menu_motion);
  274. }
  275. #if HAS_CUTTER
  276. SUBMENU(MSG_CUTTER(MENU), STICKY_SCREEN(menu_spindle_laser));
  277. #endif
  278. #if HAS_TEMPERATURE
  279. SUBMENU(MSG_TEMPERATURE, menu_temperature);
  280. #endif
  281. #if HAS_POWER_MONITOR
  282. SUBMENU(MSG_POWER_MONITOR, menu_power_monitor);
  283. #endif
  284. #if ENABLED(MIXING_EXTRUDER)
  285. SUBMENU(MSG_MIXER, menu_mixer);
  286. #endif
  287. #if ENABLED(MMU2_MENUS)
  288. if (!busy) SUBMENU(MSG_MMU2_MENU, menu_mmu2);
  289. #endif
  290. SUBMENU(MSG_CONFIGURATION, menu_configuration);
  291. #if ENABLED(CUSTOM_MENU_MAIN)
  292. if (TERN1(CUSTOM_MENU_MAIN_ONLY_IDLE, !busy)) {
  293. #ifdef CUSTOM_MENU_MAIN_TITLE
  294. SUBMENU_P(PSTR(CUSTOM_MENU_MAIN_TITLE), custom_menus_main);
  295. #else
  296. SUBMENU(MSG_CUSTOM_COMMANDS, custom_menus_main);
  297. #endif
  298. }
  299. #endif
  300. #if ENABLED(ADVANCED_PAUSE_FEATURE)
  301. #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
  302. YESNO_ITEM(MSG_FILAMENTCHANGE,
  303. menu_change_filament, nullptr,
  304. GET_TEXT(MSG_FILAMENTCHANGE), (const char *)nullptr, PSTR("?")
  305. );
  306. #else
  307. SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament);
  308. #endif
  309. #endif
  310. #if ENABLED(LCD_INFO_MENU)
  311. SUBMENU(MSG_INFO_MENU, menu_info);
  312. #endif
  313. #if EITHER(LED_CONTROL_MENU, CASE_LIGHT_MENU)
  314. SUBMENU(MSG_LEDS, menu_led);
  315. #endif
  316. //
  317. // Switch power on/off
  318. //
  319. #if ENABLED(PSU_CONTROL)
  320. if (powerManager.psu_on)
  321. #if ENABLED(PS_OFF_CONFIRM)
  322. CONFIRM_ITEM(MSG_SWITCH_PS_OFF,
  323. MSG_YES, MSG_NO,
  324. ui.poweroff, nullptr,
  325. GET_TEXT(MSG_SWITCH_PS_OFF), (const char *)nullptr, PSTR("?")
  326. );
  327. #else
  328. ACTION_ITEM(MSG_SWITCH_PS_OFF, ui.poweroff);
  329. #endif
  330. else
  331. GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80"));
  332. #endif
  333. #if ENABLED(SDSUPPORT) && DISABLED(MEDIA_MENU_AT_TOP)
  334. sdcard_menu_items();
  335. #endif
  336. #if HAS_SERVICE_INTERVALS
  337. static auto _service_reset = [](const int index) {
  338. print_job_timer.resetServiceInterval(index);
  339. ui.completion_feedback();
  340. ui.reset_status();
  341. ui.return_to_status();
  342. };
  343. #if SERVICE_INTERVAL_1 > 0
  344. CONFIRM_ITEM_P(PSTR(SERVICE_NAME_1),
  345. MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
  346. []{ _service_reset(1); }, nullptr,
  347. GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_1), PSTR("?")
  348. );
  349. #endif
  350. #if SERVICE_INTERVAL_2 > 0
  351. CONFIRM_ITEM_P(PSTR(SERVICE_NAME_2),
  352. MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
  353. []{ _service_reset(2); }, nullptr,
  354. GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_2), PSTR("?")
  355. );
  356. #endif
  357. #if SERVICE_INTERVAL_3 > 0
  358. CONFIRM_ITEM_P(PSTR(SERVICE_NAME_3),
  359. MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
  360. []{ _service_reset(3); }, nullptr,
  361. GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_3), PSTR("?")
  362. );
  363. #endif
  364. #endif
  365. #if HAS_GAMES && DISABLED(LCD_INFO_MENU)
  366. #if ENABLED(GAMES_EASTER_EGG)
  367. SKIP_ITEM();
  368. SKIP_ITEM();
  369. SKIP_ITEM();
  370. #endif
  371. // Game sub-menu or the individual game
  372. {
  373. SUBMENU(
  374. #if HAS_GAME_MENU
  375. MSG_GAMES, menu_game
  376. #elif ENABLED(MARLIN_BRICKOUT)
  377. MSG_BRICKOUT, brickout.enter_game
  378. #elif ENABLED(MARLIN_INVADERS)
  379. MSG_INVADERS, invaders.enter_game
  380. #elif ENABLED(MARLIN_SNAKE)
  381. MSG_SNAKE, snake.enter_game
  382. #elif ENABLED(MARLIN_MAZE)
  383. MSG_MAZE, maze.enter_game
  384. #endif
  385. );
  386. }
  387. #endif
  388. #if HAS_MULTI_LANGUAGE
  389. SUBMENU(LANGUAGE, menu_language);
  390. #endif
  391. #if ENABLED(HOST_SHUTDOWN_MENU_ITEM) && defined(SHUTDOWN_ACTION)
  392. SUBMENU(MSG_HOST_SHUTDOWN, []{
  393. MenuItem_confirm::select_screen(
  394. GET_TEXT(MSG_BUTTON_PROCEED), GET_TEXT(MSG_BUTTON_CANCEL),
  395. []{ ui.return_to_status(); hostui.shutdown(); }, nullptr,
  396. GET_TEXT(MSG_HOST_SHUTDOWN), (const char *)nullptr, PSTR("?")
  397. );
  398. });
  399. #endif
  400. END_MENU();
  401. }
  402. #endif // HAS_MARLINUI_MENU