My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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