My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

mmu2.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #pragma once
  23. #include "../../inc/MarlinConfig.h"
  24. #if HAS_FILAMENT_SENSOR
  25. #include "../runout.h"
  26. #endif
  27. #if SERIAL_USB
  28. #define MMU_RX_SIZE 256
  29. #define MMU_TX_SIZE 256
  30. #else
  31. #define MMU_RX_SIZE 16
  32. #define MMU_TX_SIZE 16
  33. #endif
  34. struct E_Step;
  35. class MMU2 {
  36. public:
  37. MMU2();
  38. static void init();
  39. static void reset();
  40. static bool enabled() { return _enabled; }
  41. static void mmu_loop();
  42. static void tool_change(const uint8_t index);
  43. static void tool_change(const char *special);
  44. static uint8_t get_current_tool();
  45. static void set_filament_type(const uint8_t index, const uint8_t type);
  46. static bool unload();
  47. static void load_filament(uint8_t);
  48. static void load_all();
  49. static bool load_filament_to_nozzle(const uint8_t index);
  50. static bool eject_filament(const uint8_t index, const bool recover);
  51. private:
  52. static bool rx_str(FSTR_P fstr);
  53. static void tx_str(FSTR_P fstr);
  54. static void tx_printf(FSTR_P ffmt, const int argument);
  55. static void tx_printf(FSTR_P ffmt, const int argument1, const int argument2);
  56. static void clear_rx_buffer();
  57. static bool rx_ok();
  58. static bool rx_start();
  59. static void check_version();
  60. static void command(const uint8_t cmd);
  61. static bool get_response();
  62. static void manage_response(const bool move_axes, const bool turn_off_nozzle);
  63. static void load_to_nozzle();
  64. static void execute_extruder_sequence(const E_Step * sequence, int steps);
  65. static void filament_runout();
  66. #if HAS_PRUSA_MMU2S
  67. static bool mmu2s_triggered;
  68. static void check_filament();
  69. static bool can_load();
  70. static bool load_to_gears();
  71. #else
  72. FORCE_INLINE static bool load_to_gears() { return true; }
  73. #endif
  74. #if ENABLED(MMU_EXTRUDER_SENSOR)
  75. static void mmu_continue_loading();
  76. #endif
  77. static bool _enabled, ready, mmu_print_saved;
  78. static uint8_t cmd, cmd_arg, last_cmd, extruder;
  79. static int8_t state;
  80. static volatile int8_t finda;
  81. static volatile bool finda_runout_valid;
  82. static int16_t version, buildnr;
  83. static millis_t prev_request, prev_P0_request;
  84. static char rx_buffer[MMU_RX_SIZE], tx_buffer[MMU_TX_SIZE];
  85. static void set_runout_valid(const bool valid) {
  86. finda_runout_valid = valid;
  87. #if HAS_FILAMENT_SENSOR
  88. if (valid) runout.reset();
  89. #endif
  90. }
  91. };
  92. extern MMU2 mmu2;