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

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