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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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, PSTR(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_nozzl_e(const uint8_t tool) {
  39. _mmu2_load_filamentToNozzle(tool);
  40. ui.return_to_status();
  41. }
  42. inline void action_mmu2_load_filament_to_nozzle_0() { action_mmu2_load_filament_to_nozzl_e(0); }
  43. inline void action_mmu2_load_filament_to_nozzle_1() { action_mmu2_load_filament_to_nozzl_e(1); }
  44. inline void action_mmu2_load_filament_to_nozzle_2() { action_mmu2_load_filament_to_nozzl_e(2); }
  45. inline void action_mmu2_load_filament_to_nozzle_3() { action_mmu2_load_filament_to_nozzl_e(3); }
  46. inline void action_mmu2_load_filament_to_nozzle_4() { action_mmu2_load_filament_to_nozzl_e(4); }
  47. void _mmu2_load_filament(uint8_t index) {
  48. ui.return_to_status();
  49. ui.status_printf_P(0, PSTR(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
  50. mmu2.load_filament(index);
  51. ui.reset_status();
  52. }
  53. void action_mmu2_load_all() {
  54. for (uint8_t i = 0; i < EXTRUDERS; i++)
  55. _mmu2_load_filament(i);
  56. ui.return_to_status();
  57. }
  58. inline void action_mmu2_load_filament_0() { _mmu2_load_filament(0); }
  59. inline void action_mmu2_load_filament_1() { _mmu2_load_filament(1); }
  60. inline void action_mmu2_load_filament_2() { _mmu2_load_filament(2); }
  61. inline void action_mmu2_load_filament_3() { _mmu2_load_filament(3); }
  62. inline void action_mmu2_load_filament_4() { _mmu2_load_filament(4); }
  63. void menu_mmu2_load_filament() {
  64. START_MENU();
  65. MENU_BACK(MSG_MMU2_MENU);
  66. MENU_ITEM(function, MSG_MMU2_ALL, action_mmu2_load_all);
  67. MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_load_filament_0);
  68. MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_load_filament_1);
  69. MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_load_filament_2);
  70. MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_load_filament_3);
  71. MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_load_filament_4);
  72. END_MENU();
  73. }
  74. void menu_mmu2_load_to_nozzle() {
  75. START_MENU();
  76. MENU_BACK(MSG_MMU2_MENU);
  77. MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_load_filament_to_nozzle_0);
  78. MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_load_filament_to_nozzle_1);
  79. MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_load_filament_to_nozzle_2);
  80. MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_load_filament_to_nozzle_3);
  81. MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_load_filament_to_nozzle_4);
  82. END_MENU();
  83. }
  84. //
  85. // Eject Filament
  86. //
  87. void _mmu2_eject_filament(uint8_t index) {
  88. ui.reset_status();
  89. ui.return_to_status();
  90. ui.status_printf_P(0, PSTR(MSG_MMU2_EJECTING_FILAMENT), int(index + 1));
  91. if (mmu2.eject_filament(index, true)) ui.reset_status();
  92. }
  93. inline void action_mmu2_eject_filament_0() { _mmu2_eject_filament(0); }
  94. inline void action_mmu2_eject_filament_1() { _mmu2_eject_filament(1); }
  95. inline void action_mmu2_eject_filament_2() { _mmu2_eject_filament(2); }
  96. inline void action_mmu2_eject_filament_3() { _mmu2_eject_filament(3); }
  97. inline void action_mmu2_eject_filament_4() { _mmu2_eject_filament(4); }
  98. void action_mmu2_unload_filament() {
  99. ui.reset_status();
  100. ui.return_to_status();
  101. LCD_MESSAGEPGM(MSG_MMU2_UNLOADING_FILAMENT);
  102. idle();
  103. if (mmu2.unload()) ui.reset_status();
  104. }
  105. void menu_mmu2_eject_filament() {
  106. START_MENU();
  107. MENU_BACK(MSG_MMU2_MENU);
  108. MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_eject_filament_0);
  109. MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_eject_filament_1);
  110. MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_eject_filament_2);
  111. MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_eject_filament_3);
  112. MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_eject_filament_4);
  113. END_MENU();
  114. }
  115. //
  116. // MMU2 Menu
  117. //
  118. void action_mmu2_reset() {
  119. mmu2.init();
  120. ui.reset_status();
  121. }
  122. void menu_mmu2() {
  123. START_MENU();
  124. MENU_BACK(MSG_MAIN);
  125. MENU_ITEM(submenu, MSG_MMU2_LOAD_FILAMENT, menu_mmu2_load_filament);
  126. MENU_ITEM(submenu, MSG_MMU2_LOAD_TO_NOZZLE, menu_mmu2_load_to_nozzle);
  127. MENU_ITEM(submenu, MSG_MMU2_EJECT_FILAMENT, menu_mmu2_eject_filament);
  128. MENU_ITEM(function, MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_unload_filament);
  129. MENU_ITEM(function, MSG_MMU2_RESET, action_mmu2_reset);
  130. END_MENU();
  131. }
  132. //
  133. // T* Choose Filament
  134. //
  135. inline void action_mmu2_choose(const uint8_t tool) {
  136. currentTool = tool;
  137. mmuMenuWait = false;
  138. }
  139. inline void action_mmu2_choose0() { action_mmu2_choose(0); }
  140. inline void action_mmu2_choose1() { action_mmu2_choose(1); }
  141. inline void action_mmu2_choose2() { action_mmu2_choose(2); }
  142. inline void action_mmu2_choose3() { action_mmu2_choose(3); }
  143. inline void action_mmu2_choose4() { action_mmu2_choose(4); }
  144. void menu_mmu2_choose_filament() {
  145. START_MENU();
  146. #if LCD_HEIGHT > 2
  147. STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_CENTER|SS_INVERT);
  148. #endif
  149. MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_choose0);
  150. MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_choose1);
  151. MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_choose2);
  152. MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_choose3);
  153. MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_choose4);
  154. END_MENU();
  155. }
  156. //
  157. // MMU2 Filament Runout
  158. //
  159. inline void action_mmu2_M600_load_current_filament() { mmu2.load_filament(currentTool); }
  160. inline void action_mmu2_M600_load_current_filament_to_nozzle() { mmu2.load_filament_to_nozzle(currentTool); }
  161. inline void action_mmu2_M600_unload_filament() { mmu2.unload(); }
  162. inline void action_mmu2_M600_resume() { mmuMenuWait = false; }
  163. void menu_mmu2_pause() {
  164. currentTool = mmu2.get_current_tool();
  165. START_MENU();
  166. #if LCD_HEIGHT > 2
  167. STATIC_ITEM(MSG_MMU2_FILAMENT_CHANGE_HEADER, SS_CENTER|SS_INVERT);
  168. #endif
  169. MENU_ITEM(function, MSG_MMU2_RESUME, action_mmu2_M600_resume);
  170. MENU_ITEM(function, MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_M600_unload_filament);
  171. MENU_ITEM(function, MSG_MMU2_LOAD_FILAMENT, action_mmu2_M600_load_current_filament);
  172. MENU_ITEM(function, MSG_MMU2_LOAD_TO_NOZZLE, action_mmu2_M600_load_current_filament_to_nozzle);
  173. END_MENU();
  174. }
  175. void mmu2_M600() {
  176. ui.defer_status_screen();
  177. ui.goto_screen(menu_mmu2_pause);
  178. mmuMenuWait = true;
  179. while (mmuMenuWait) idle();
  180. }
  181. uint8_t mmu2_choose_filament() {
  182. ui.defer_status_screen();
  183. ui.goto_screen(menu_mmu2_choose_filament);
  184. mmuMenuWait = true;
  185. while (mmuMenuWait) idle();
  186. ui.return_to_status();
  187. return currentTool;
  188. }
  189. #endif // HAS_LCD_MENU && ENABLED(PRUSA_MMU2_MENUS)