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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. #include "../../inc/MarlinConfig.h"
  23. #if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
  24. #include "../../feature/prusa_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. for (uint8_t i = 0; i < EXTRUDERS; i++)
  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. ACTION_ITEM(MSG_MMU2_FILAMENT0, [](){ _mmu2_load_filament(0); });
  58. ACTION_ITEM(MSG_MMU2_FILAMENT1, [](){ _mmu2_load_filament(1); });
  59. ACTION_ITEM(MSG_MMU2_FILAMENT2, [](){ _mmu2_load_filament(2); });
  60. ACTION_ITEM(MSG_MMU2_FILAMENT3, [](){ _mmu2_load_filament(3); });
  61. ACTION_ITEM(MSG_MMU2_FILAMENT4, [](){ _mmu2_load_filament(4); });
  62. END_MENU();
  63. }
  64. void menu_mmu2_load_to_nozzle() {
  65. START_MENU();
  66. BACK_ITEM(MSG_MMU2_MENU);
  67. ACTION_ITEM(MSG_MMU2_FILAMENT0, [](){ action_mmu2_load_filament_to_nozzle(0); });
  68. ACTION_ITEM(MSG_MMU2_FILAMENT1, [](){ action_mmu2_load_filament_to_nozzle(1); });
  69. ACTION_ITEM(MSG_MMU2_FILAMENT2, [](){ action_mmu2_load_filament_to_nozzle(2); });
  70. ACTION_ITEM(MSG_MMU2_FILAMENT3, [](){ action_mmu2_load_filament_to_nozzle(3); });
  71. ACTION_ITEM(MSG_MMU2_FILAMENT4, [](){ action_mmu2_load_filament_to_nozzle(4); });
  72. END_MENU();
  73. }
  74. //
  75. // Eject Filament
  76. //
  77. void _mmu2_eject_filament(uint8_t index) {
  78. ui.reset_status();
  79. ui.return_to_status();
  80. ui.status_printf_P(0, GET_TEXT(MSG_MMU2_EJECTING_FILAMENT), int(index + 1));
  81. if (mmu2.eject_filament(index, true)) ui.reset_status();
  82. }
  83. void action_mmu2_unload_filament() {
  84. ui.reset_status();
  85. ui.return_to_status();
  86. LCD_MESSAGEPGM(MSG_MMU2_UNLOADING_FILAMENT);
  87. idle();
  88. if (mmu2.unload()) ui.reset_status();
  89. }
  90. void menu_mmu2_eject_filament() {
  91. START_MENU();
  92. BACK_ITEM(MSG_MMU2_MENU);
  93. ACTION_ITEM(MSG_MMU2_FILAMENT0, [](){ _mmu2_eject_filament(0); });
  94. ACTION_ITEM(MSG_MMU2_FILAMENT1, [](){ _mmu2_eject_filament(1); });
  95. ACTION_ITEM(MSG_MMU2_FILAMENT2, [](){ _mmu2_eject_filament(2); });
  96. ACTION_ITEM(MSG_MMU2_FILAMENT3, [](){ _mmu2_eject_filament(3); });
  97. ACTION_ITEM(MSG_MMU2_FILAMENT4, [](){ _mmu2_eject_filament(4); });
  98. END_MENU();
  99. }
  100. //
  101. // MMU2 Menu
  102. //
  103. void action_mmu2_reset() {
  104. mmu2.init();
  105. ui.reset_status();
  106. }
  107. void menu_mmu2() {
  108. START_MENU();
  109. BACK_ITEM(MSG_MAIN);
  110. SUBMENU(MSG_MMU2_LOAD_FILAMENT, menu_mmu2_load_filament);
  111. SUBMENU(MSG_MMU2_LOAD_TO_NOZZLE, menu_mmu2_load_to_nozzle);
  112. SUBMENU(MSG_MMU2_EJECT_FILAMENT, menu_mmu2_eject_filament);
  113. ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_unload_filament);
  114. ACTION_ITEM(MSG_MMU2_RESET, action_mmu2_reset);
  115. END_MENU();
  116. }
  117. //
  118. // T* Choose Filament
  119. //
  120. inline void action_mmu2_choose(const uint8_t tool) {
  121. currentTool = tool;
  122. mmuMenuWait = false;
  123. }
  124. void menu_mmu2_choose_filament() {
  125. START_MENU();
  126. #if LCD_HEIGHT > 2
  127. STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_CENTER|SS_INVERT);
  128. #endif
  129. ACTION_ITEM(MSG_MMU2_FILAMENT0, [](){ action_mmu2_choose(0); });
  130. ACTION_ITEM(MSG_MMU2_FILAMENT1, [](){ action_mmu2_choose(1); });
  131. ACTION_ITEM(MSG_MMU2_FILAMENT2, [](){ action_mmu2_choose(2); });
  132. ACTION_ITEM(MSG_MMU2_FILAMENT3, [](){ action_mmu2_choose(3); });
  133. ACTION_ITEM(MSG_MMU2_FILAMENT4, [](){ action_mmu2_choose(4); });
  134. END_MENU();
  135. }
  136. //
  137. // MMU2 Filament Runout
  138. //
  139. void menu_mmu2_pause() {
  140. currentTool = mmu2.get_current_tool();
  141. START_MENU();
  142. #if LCD_HEIGHT > 2
  143. STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, SS_CENTER|SS_INVERT);
  144. #endif
  145. ACTION_ITEM(MSG_MMU2_RESUME, [](){ mmuMenuWait = false; });
  146. ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, [](){ mmu2.unload(); });
  147. ACTION_ITEM(MSG_MMU2_LOAD_FILAMENT, [](){ mmu2.load_filament(currentTool); });
  148. ACTION_ITEM(MSG_MMU2_LOAD_TO_NOZZLE, [](){ mmu2.load_filament_to_nozzle(currentTool); });
  149. END_MENU();
  150. }
  151. void mmu2_M600() {
  152. ui.defer_status_screen();
  153. ui.goto_screen(menu_mmu2_pause);
  154. mmuMenuWait = true;
  155. while (mmuMenuWait) idle();
  156. }
  157. uint8_t mmu2_choose_filament() {
  158. ui.defer_status_screen();
  159. ui.goto_screen(menu_mmu2_choose_filament);
  160. mmuMenuWait = true;
  161. while (mmuMenuWait) idle();
  162. ui.return_to_status();
  163. return currentTool;
  164. }
  165. #endif // HAS_LCD_MENU && ENABLED(PRUSA_MMU2_MENUS)