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_mmu2.cpp 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. #include "../../inc/MarlinConfig.h"
  23. #if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
  24. #include "../../feature/mmu2/mmu2.h"
  25. #include "menu_mmu2.h"
  26. #include "menu.h"
  27. uint8_t currentTool;
  28. bool mmuMenuWait;
  29. //
  30. // Load Filament
  31. //
  32. void _mmu2_load_filamentToNozzle(uint8_t index) {
  33. ui.reset_status();
  34. ui.return_to_status();
  35. ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
  36. if (mmu2.load_filament_to_nozzle(index)) ui.reset_status();
  37. }
  38. inline void action_mmu2_load_filament_to_nozzle(const uint8_t tool) {
  39. _mmu2_load_filamentToNozzle(tool);
  40. ui.return_to_status();
  41. }
  42. void _mmu2_load_filament(uint8_t index) {
  43. ui.return_to_status();
  44. ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
  45. mmu2.load_filament(index);
  46. ui.reset_status();
  47. }
  48. void action_mmu2_load_all() {
  49. LOOP_L_N(i, EXTRUDERS)
  50. _mmu2_load_filament(i);
  51. ui.return_to_status();
  52. }
  53. void menu_mmu2_load_filament() {
  54. START_MENU();
  55. BACK_ITEM(MSG_MMU2_MENU);
  56. ACTION_ITEM(MSG_MMU2_ALL, action_mmu2_load_all);
  57. LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_load_filament(MenuItemBase::itemIndex); });
  58. END_MENU();
  59. }
  60. void menu_mmu2_load_to_nozzle() {
  61. START_MENU();
  62. BACK_ITEM(MSG_MMU2_MENU);
  63. LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_load_filament_to_nozzle(MenuItemBase::itemIndex); });
  64. END_MENU();
  65. }
  66. //
  67. // Eject Filament
  68. //
  69. void _mmu2_eject_filament(uint8_t index) {
  70. ui.reset_status();
  71. ui.return_to_status();
  72. ui.status_printf_P(0, GET_TEXT(MSG_MMU2_EJECTING_FILAMENT), int(index + 1));
  73. if (mmu2.eject_filament(index, true)) ui.reset_status();
  74. }
  75. void action_mmu2_unload_filament() {
  76. ui.reset_status();
  77. ui.return_to_status();
  78. LCD_MESSAGEPGM(MSG_MMU2_UNLOADING_FILAMENT);
  79. idle();
  80. if (mmu2.unload()) ui.reset_status();
  81. }
  82. void menu_mmu2_eject_filament() {
  83. START_MENU();
  84. BACK_ITEM(MSG_MMU2_MENU);
  85. LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_eject_filament(MenuItemBase::itemIndex); });
  86. END_MENU();
  87. }
  88. //
  89. // MMU2 Menu
  90. //
  91. void action_mmu2_reset() {
  92. mmu2.init();
  93. ui.reset_status();
  94. }
  95. void menu_mmu2() {
  96. START_MENU();
  97. BACK_ITEM(MSG_MAIN);
  98. SUBMENU(MSG_MMU2_LOAD_FILAMENT, menu_mmu2_load_filament);
  99. SUBMENU(MSG_MMU2_LOAD_TO_NOZZLE, menu_mmu2_load_to_nozzle);
  100. SUBMENU(MSG_MMU2_EJECT_FILAMENT, menu_mmu2_eject_filament);
  101. ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_unload_filament);
  102. ACTION_ITEM(MSG_MMU2_RESET, action_mmu2_reset);
  103. END_MENU();
  104. }
  105. //
  106. // T* Choose Filament
  107. //
  108. inline void action_mmu2_choose(const uint8_t tool) {
  109. currentTool = tool;
  110. mmuMenuWait = false;
  111. }
  112. void menu_mmu2_choose_filament() {
  113. START_MENU();
  114. #if LCD_HEIGHT > 2
  115. STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_CENTER|SS_INVERT);
  116. #endif
  117. LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_choose(MenuItemBase::itemIndex); });
  118. END_MENU();
  119. }
  120. //
  121. // MMU2 Filament Runout
  122. //
  123. void menu_mmu2_pause() {
  124. currentTool = mmu2.get_current_tool();
  125. START_MENU();
  126. #if LCD_HEIGHT > 2
  127. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, SS_CENTER|SS_INVERT);
  128. #endif
  129. ACTION_ITEM(MSG_MMU2_RESUME, []{ mmuMenuWait = false; });
  130. ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, []{ mmu2.unload(); });
  131. ACTION_ITEM(MSG_MMU2_LOAD_FILAMENT, []{ mmu2.load_filament(currentTool); });
  132. ACTION_ITEM(MSG_MMU2_LOAD_TO_NOZZLE, []{ mmu2.load_filament_to_nozzle(currentTool); });
  133. END_MENU();
  134. }
  135. void mmu2_M600() {
  136. ui.defer_status_screen();
  137. ui.goto_screen(menu_mmu2_pause);
  138. mmuMenuWait = true;
  139. while (mmuMenuWait) idle();
  140. }
  141. uint8_t mmu2_choose_filament() {
  142. ui.defer_status_screen();
  143. ui.goto_screen(menu_mmu2_choose_filament);
  144. mmuMenuWait = true;
  145. while (mmuMenuWait) idle();
  146. ui.return_to_status();
  147. return currentTool;
  148. }
  149. #endif // HAS_LCD_MENU && ENABLED(PRUSA_MMU2_MENUS)